Search in sources :

Example 1 with InternetExplorerDriver

use of org.openqa.selenium.ie.InternetExplorerDriver in project antlr4 by antlr.

the class BaseExplorerTest method initWebDriver.

@Before
public void initWebDriver() {
    System.setProperty("webdriver.ie.driver", "C:\\Program Files (x86)\\Selenium\\IEDriverServer.exe");
    driver = new InternetExplorerDriver();
}
Also used : InternetExplorerDriver(org.openqa.selenium.ie.InternetExplorerDriver) Before(org.junit.Before)

Example 2 with InternetExplorerDriver

use of org.openqa.selenium.ie.InternetExplorerDriver in project page-factory-2 by sbtqa.

the class TagWebDriver method createDriver.

private static void createDriver() throws UnsupportedBrowserException, MalformedURLException {
    DesiredCapabilities capabilities = new WebDriverCapabilitiesParser().parse();
    if (!PROPERTIES.getProxy().isEmpty()) {
        Proxy seleniumProxy = ProxyConfigurator.configureProxy();
        capabilities.setCapability(CapabilityType.PROXY, seleniumProxy);
    }
    String browserName = getBrowserName();
    capabilities.setBrowserName(browserName);
    String webDriverUrl = PROPERTIES.getWebDriverUrl();
    if (!webDriverUrl.isEmpty()) {
        setWebDriver(createRemoteWebDriver(webDriverUrl, capabilities));
    } else {
        if (browserName.equalsIgnoreCase(FIREFOX)) {
            setWebDriver(new FirefoxDriver(capabilities));
        } else if (browserName.equalsIgnoreCase(SAFARI)) {
            setWebDriver(new SafariDriver(capabilities));
        } else if (browserName.equalsIgnoreCase(CHROME)) {
            WebDriverManagerConfigurator.configureDriver(ChromeDriverManager.getInstance(), CHROME);
            setWebDriver(new ChromeDriver(capabilities));
        } else if (browserName.equalsIgnoreCase(IE)) {
            WebDriverManagerConfigurator.configureDriver(InternetExplorerDriverManager.getInstance(), IE);
            setWebDriver(new InternetExplorerDriver(capabilities));
        } else {
            throw new UnsupportedBrowserException("'" + browserName + "' is not supported yet");
        }
    }
    webDriver.manage().timeouts().pageLoadTimeout(PageFactory.getTimeOutInSeconds(), TimeUnit.SECONDS);
    setBrowserSize();
    webDriver.get(PROPERTIES.getStartingUrl());
}
Also used : UnsupportedBrowserException(ru.sbtqa.tag.pagefactory.exceptions.UnsupportedBrowserException) Proxy(org.openqa.selenium.Proxy) FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) InternetExplorerDriver(org.openqa.selenium.ie.InternetExplorerDriver) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) WebDriverCapabilitiesParser(ru.sbtqa.tag.pagefactory.support.capabilities.WebDriverCapabilitiesParser) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver) SafariDriver(org.openqa.selenium.safari.SafariDriver)

Example 3 with InternetExplorerDriver

use of org.openqa.selenium.ie.InternetExplorerDriver in project Payara by payara.

the class SeleniumHelper method getSeleniumInstance.

public SeleniumWrapper getSeleniumInstance() {
    if (selenium == null) {
        if (Boolean.parseBoolean(SeleniumHelper.getParameter("debug", "false"))) {
            logger.log(Level.INFO, "Creating new selenium instance");
        }
        String browser = getParameter("browser", "firefox");
        if ("firefox".equals(browser)) {
            driver = new FirefoxDriver();
        } else if ("chrome".equals(browser)) {
            driver = new ChromeDriver();
        } else if ("ie".contains(browser)) {
            driver = new InternetExplorerDriver();
        }
        elementFinder = new ElementFinder(driver);
        selenium = new SeleniumWrapper(driver, getBaseUrl());
        selenium.setTimeout("90000");
        // Make sure the server has started and the user logged in
        (new BaseSeleniumTestClass()).openAndWait("/", BaseSeleniumTestClass.TRIGGER_COMMON_TASKS, 480);
    }
    selenium.windowFocus();
    selenium.windowMaximize();
    selenium.setTimeout("90000");
    return selenium;
}
Also used : FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) InternetExplorerDriver(org.openqa.selenium.ie.InternetExplorerDriver) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver) BaseSeleniumTestClass(org.glassfish.admingui.devtests.BaseSeleniumTestClass)

Example 4 with InternetExplorerDriver

use of org.openqa.selenium.ie.InternetExplorerDriver in project archiva by apache.

the class WebdriverUtility method newWebDriver.

public static WebDriver newWebDriver(String seleniumBrowser, String seleniumHost, int seleniumPort, boolean seleniumRemote) {
    log.info("WebDriver {}, {}, {}, {}", seleniumBrowser, seleniumHost, seleniumPort, seleniumRemote);
    if (seleniumRemote && StringUtils.isEmpty(seleniumHost)) {
        throw new IllegalArgumentException("seleniumHost must be set, when seleniumRemote=true");
    }
    try {
        if (StringUtils.contains(seleniumBrowser, "chrome")) {
            ChromeOptions options = new ChromeOptions();
            options.addArguments("start-maximized");
            if (seleniumRemote) {
                DesiredCapabilities capabilities = DesiredCapabilities.chrome();
                capabilities.setCapability(ChromeOptions.CAPABILITY, options);
                return new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), capabilities);
            } else {
                return new ChromeDriver(options);
            }
        }
        if (StringUtils.contains(seleniumBrowser, "safari")) {
            if (seleniumRemote) {
                return new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), DesiredCapabilities.safari());
            } else {
                return new SafariDriver();
            }
        }
        if (StringUtils.contains(seleniumBrowser, "iexplore")) {
            if (seleniumRemote) {
                return new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), DesiredCapabilities.internetExplorer());
            } else {
                new InternetExplorerDriver();
            }
        }
        if (StringUtils.contains(seleniumBrowser, "firefox")) {
            if (seleniumRemote) {
                return new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), DesiredCapabilities.firefox());
            } else {
                return new FirefoxDriver();
            }
        }
        DesiredCapabilities capabilities = DesiredCapabilities.htmlUnit();
        capabilities.setJavascriptEnabled(true);
        capabilities.setVersion("firefox-52");
        WebDriver driver;
        if (seleniumRemote) {
            driver = new RemoteWebDriver(new URL("http://" + seleniumHost + ":" + seleniumPort + "/wd/hub"), capabilities);
        } else {
            driver = new HtmlUnitDriver(capabilities) {

                @Override
                protected WebClient modifyWebClient(WebClient client) {
                    client.getOptions().setThrowExceptionOnFailingStatusCode(false);
                    client.getOptions().setThrowExceptionOnScriptError(false);
                    client.getOptions().setCssEnabled(true);
                    return client;
                }
            };
        }
        return driver;
    } catch (MalformedURLException e) {
        throw new RuntimeException("Initializion of remote driver failed");
    }
}
Also used : WebDriver(org.openqa.selenium.WebDriver) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) MalformedURLException(java.net.MalformedURLException) InternetExplorerDriver(org.openqa.selenium.ie.InternetExplorerDriver) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) WebClient(com.gargoylesoftware.htmlunit.WebClient) URL(java.net.URL) SafariDriver(org.openqa.selenium.safari.SafariDriver) HtmlUnitDriver(org.openqa.selenium.htmlunit.HtmlUnitDriver) FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) ChromeOptions(org.openqa.selenium.chrome.ChromeOptions) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver)

Example 5 with InternetExplorerDriver

use of org.openqa.selenium.ie.InternetExplorerDriver in project jmeter-plugins by undera.

the class InternetExplorerDriverConfigTest method shouldQuitWebDriverAndStopServiceWhenQuitBrowserIsInvoked.

@Test
public void shouldQuitWebDriverAndStopServiceWhenQuitBrowserIsInvoked() throws Exception {
    InternetExplorerDriver mockInternetExplorerDriver = mock(InternetExplorerDriver.class);
    InternetExplorerDriverService mockService = mock(InternetExplorerDriverService.class);
    when(mockService.isRunning()).thenReturn(true);
    config.getServices().put(config.currentThreadName(), mockService);
    config.quitBrowser(mockInternetExplorerDriver);
    verify(mockInternetExplorerDriver).quit();
    assertThat(config.getServices(), is(Collections.<String, InternetExplorerDriverService>emptyMap()));
    verify(mockService, times(1)).stop();
}
Also used : InternetExplorerDriver(org.openqa.selenium.ie.InternetExplorerDriver) InternetExplorerDriverService(org.openqa.selenium.ie.InternetExplorerDriverService) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

InternetExplorerDriver (org.openqa.selenium.ie.InternetExplorerDriver)21 ChromeDriver (org.openqa.selenium.chrome.ChromeDriver)11 FirefoxDriver (org.openqa.selenium.firefox.FirefoxDriver)11 DesiredCapabilities (org.openqa.selenium.remote.DesiredCapabilities)11 ChromeOptions (org.openqa.selenium.chrome.ChromeOptions)6 RemoteWebDriver (org.openqa.selenium.remote.RemoteWebDriver)6 URL (java.net.URL)5 Test (org.junit.Test)5 HtmlUnitDriver (org.openqa.selenium.htmlunit.HtmlUnitDriver)5 InternetExplorerDriverService (org.openqa.selenium.ie.InternetExplorerDriverService)5 SafariDriver (org.openqa.selenium.safari.SafariDriver)5 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5 WebDriver (org.openqa.selenium.WebDriver)4 EdgeDriver (org.openqa.selenium.edge.EdgeDriver)4 PhantomJSDriver (org.openqa.selenium.phantomjs.PhantomJSDriver)4 File (java.io.File)3 FirefoxProfile (org.openqa.selenium.firefox.FirefoxProfile)3 FirefoxOptions (org.openqa.selenium.firefox.FirefoxOptions)2 InternetExplorerOptions (org.openqa.selenium.ie.InternetExplorerOptions)2 Actions (org.openqa.selenium.interactions.Actions)2