Search in sources :

Example 46 with DesiredCapabilities

use of org.openqa.selenium.remote.DesiredCapabilities in project selenium_java by sergueik.

the class NgScrollableTableTest method setUp.

@Before
public void setUp() throws Exception {
    // change according to platform
    System.setProperty("webdriver.chrome.driver", osName.toLowerCase().startsWith("windows") ? new File("c:/java/selenium/chromedriver.exe").getAbsolutePath() : resolveEnvVars(chromeDriverPath));
    DesiredCapabilities capabilities = DesiredCapabilities.chrome();
    if (isMobile) {
        Map<String, String> mobileEmulation = new HashMap<>();
        mobileEmulation.put("deviceName", "Google Nexus 5");
        Map<String, Object> chromeOptions = new HashMap<>();
        chromeOptions.put("mobileEmulation", mobileEmulation);
        capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
        seleniumDriver = new ChromeDriver(capabilities);
        // set ignoreSynchronization to true to handle page sync ourselves
        // instead of using waitForAngular call in JProtractor
        ngDriver = new NgWebDriver(seleniumDriver, true);
    } else {
        seleniumDriver = new ChromeDriver(capabilities);
        ngDriver = new NgWebDriver(seleniumDriver, true);
    }
    ngDriver.get(baseUrl);
    ngDriver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    page = new NgScrollableTablePage();
    page.setDriver(ngDriver);
    JPageFactory.initElements(ngDriver, channel, page);
}
Also used : NgWebDriver(com.github.sergueik.jprotractor.NgWebDriver) HashMap(java.util.HashMap) NgScrollableTablePage(org.henrrich.jpagefactory.example.scrollabletable.NgScrollableTablePage) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver) File(java.io.File) Before(org.junit.Before)

Example 47 with DesiredCapabilities

use of org.openqa.selenium.remote.DesiredCapabilities in project selenium_java by sergueik.

the class NgMultiSelectTest method setUp.

@Before
public void setUp() throws Exception {
    // change according to platform
    // NOTE:
    // java.lang.IllegalStateException: The driver executable does not exist: /var/run/chromedriver
    // java.lang.IllegalStateException: The driver is not executable: /var/run/chromedriver
    System.setProperty("webdriver.chrome.driver", osName.toLowerCase().startsWith("windows") ? new File("c:/java/selenium/chromedriver.exe").getAbsolutePath() : resolveEnvVars(chromeDriverPath));
    DesiredCapabilities capabilities = DesiredCapabilities.chrome();
    if (isMobile) {
        Map<String, String> mobileEmulation = new HashMap<>();
        mobileEmulation.put("deviceName", "Google Nexus 5");
        Map<String, Object> chromeOptions = new HashMap<>();
        chromeOptions.put("mobileEmulation", mobileEmulation);
        capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
        seleniumDriver = new ChromeDriver(capabilities);
        // set ignoreSynchronization to true to handle page sync ourselves
        // instead of using waitForAngular call in JProtractor
        ngDriver = new NgWebDriver(seleniumDriver, true);
    } else {
        seleniumDriver = new ChromeDriver(capabilities);
        ngDriver = new NgWebDriver(seleniumDriver);
    }
    ngDriver.get(baseUrl);
    ngDriver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    page = new NgMultiSelectPage();
    page.setDriver(ngDriver);
    JPageFactory.initElements(ngDriver, channel, page);
}
Also used : NgWebDriver(com.github.sergueik.jprotractor.NgWebDriver) HashMap(java.util.HashMap) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver) File(java.io.File) Before(org.junit.Before)

Example 48 with DesiredCapabilities

use of org.openqa.selenium.remote.DesiredCapabilities in project selenium_java by sergueik.

the class NgQualityShepherdTest method setUp.

@Before
public void setUp() throws Exception {
    // change according to platformm
    System.setProperty("webdriver.chrome.driver", osName.toLowerCase().startsWith("windows") ? new File("c:/java/selenium/chromedriver.exe").getAbsolutePath() : resolveEnvVars(chromeDriverPath));
    DesiredCapabilities capabilities = DesiredCapabilities.chrome();
    if (isMobile) {
        Map<String, String> mobileEmulation = new HashMap<>();
        mobileEmulation.put("deviceName", "Google Nexus 5");
        Map<String, Object> chromeOptions = new HashMap<>();
        chromeOptions.put("mobileEmulation", mobileEmulation);
        capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
        seleniumDriver = new ChromeDriver(capabilities);
        // set ignoreSynchronization to true to handle page sync ourselves
        // instead of using waitForAngular call in JProtractor
        ngDriver = new NgWebDriver(seleniumDriver, true);
    } else {
        seleniumDriver = new ChromeDriver(capabilities);
        ngDriver = new NgWebDriver(seleniumDriver);
    }
    ngDriver.get(baseUrl);
    ngDriver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    page = new NgQualityShepherdPage();
    page.setDriver(ngDriver);
    JPageFactory.initElements(ngDriver, channel, page);
}
Also used : NgWebDriver(com.github.sergueik.jprotractor.NgWebDriver) HashMap(java.util.HashMap) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver) File(java.io.File) Before(org.junit.Before)

Example 49 with DesiredCapabilities

use of org.openqa.selenium.remote.DesiredCapabilities in project selenium_java by sergueik.

the class AppTest method setupBeforeSuite.

@BeforeSuite(alwaysRun = true)
public void setupBeforeSuite(ITestContext context) throws InterruptedException, MalformedURLException {
    selenium_host = context.getCurrentXmlTest().getParameter("selenium.host");
    selenium_port = context.getCurrentXmlTest().getParameter("selenium.port");
    selenium_browser = context.getCurrentXmlTest().getParameter("selenium.browser");
    selenium_run = context.getCurrentXmlTest().getParameter("selenium.run");
    // Remote Configuration
    if (selenium_browser.compareToIgnoreCase("remote") == 0) {
        String hub = "http://" + selenium_host + ":" + selenium_port + "/wd/hub";
        LoggingPreferences logging_preferences = new LoggingPreferences();
        logging_preferences.enable(LogType.BROWSER, Level.ALL);
        logging_preferences.enable(LogType.CLIENT, Level.INFO);
        logging_preferences.enable(LogType.SERVER, Level.INFO);
        if (selenium_browser.compareToIgnoreCase("chrome") == 0) {
            DesiredCapabilities capabilities = new DesiredCapabilities("chrome", "", Platform.ANY);
            capabilities.setBrowserName("chrome");
            capabilities.setCapability(CapabilityType.LOGGING_PREFS, logging_preferences);
            try {
                driver = new RemoteWebDriver(new URL("http://" + selenium_host + ":" + selenium_port + "/wd/hub"), capabilities);
            } catch (MalformedURLException ex) {
            }
        } else {
            DesiredCapabilities capabilities = new DesiredCapabilities("firefox", "", Platform.ANY);
            capabilities.setBrowserName("firefox");
            FirefoxProfile profile = new ProfilesIni().getProfile("default");
            capabilities.setCapability("firefox_profile", profile);
            capabilities.setCapability(CapabilityType.LOGGING_PREFS, logging_preferences);
            try {
                driver = new RemoteWebDriver(new URL("http://" + selenium_host + ":" + selenium_port + "/wd/hub"), capabilities);
            } catch (MalformedURLException ex) {
            }
        }
    } else // standalone
    {
        if (selenium_browser.compareToIgnoreCase("chrome") == 0) {
            System.setProperty("webdriver.chrome.driver", "c:/java/selenium/chromedriver.exe");
            DesiredCapabilities capabilities = DesiredCapabilities.chrome();
            LoggingPreferences logging_preferences = new LoggingPreferences();
            logging_preferences.enable(LogType.BROWSER, Level.ALL);
            capabilities.setCapability(CapabilityType.LOGGING_PREFS, logging_preferences);
            /*
			   prefs.js:user_pref("extensions.logging.enabled", true);
			   user.js:user_pref("extensions.logging.enabled", true);
			 */
            driver = new ChromeDriver(capabilities);
            driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
        } else {
            DesiredCapabilities capabilities = DesiredCapabilities.firefox();
            LoggingPreferences logging_preferences = new LoggingPreferences();
            logging_preferences.enable(LogType.BROWSER, Level.ALL);
            capabilities.setCapability(CapabilityType.LOGGING_PREFS, logging_preferences);
            driver = new FirefoxDriver(capabilities);
        }
    }
    try {
        driver.manage().window().setSize(new Dimension(600, 800));
        driver.manage().timeouts().pageLoadTimeout(50, TimeUnit.SECONDS);
        driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
    } catch (Exception ex) {
        System.out.println(ex.toString());
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) ProfilesIni(org.openqa.selenium.firefox.internal.ProfilesIni) FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) LoggingPreferences(org.openqa.selenium.logging.LoggingPreferences) Dimension(org.openqa.selenium.Dimension) FirefoxProfile(org.openqa.selenium.firefox.FirefoxProfile) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver) URL(java.net.URL) ServletException(javax.servlet.ServletException) URISyntaxException(java.net.URISyntaxException) JSONException(org.json.JSONException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) BindException(java.net.BindException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Example 50 with DesiredCapabilities

use of org.openqa.selenium.remote.DesiredCapabilities in project selenium_java by sergueik.

the class RecordSettingsBase method prepareRecord.

@Override
public void prepareRecord(int timeout) {
    this.proxy = new BrowserMobProxySupplier(timeout, requestFilter, responseFilter).get();
    Proxy seleniumProxy = new SeleniumProxySupplier(proxy).get();
    DesiredCapabilities desiredCapabilities = new DesiredCapabilitiesSupplier(seleniumProxy).get();
    this.driver = webDriverSupplier.get(desiredCapabilities);
    this.driver.manage().window().maximize();
}
Also used : DesiredCapabilitiesSupplier(com.hribol.automation.core.suppliers.DesiredCapabilitiesSupplier) Proxy(org.openqa.selenium.Proxy) BrowserMobProxy(net.lightbody.bmp.BrowserMobProxy) SeleniumProxySupplier(com.hribol.automation.core.suppliers.SeleniumProxySupplier) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) BrowserMobProxySupplier(com.hribol.automation.core.suppliers.BrowserMobProxySupplier)

Aggregations

DesiredCapabilities (org.openqa.selenium.remote.DesiredCapabilities)173 File (java.io.File)55 ChromeDriver (org.openqa.selenium.chrome.ChromeDriver)40 HashMap (java.util.HashMap)33 URL (java.net.URL)32 RemoteWebDriver (org.openqa.selenium.remote.RemoteWebDriver)29 ChromeOptions (org.openqa.selenium.chrome.ChromeOptions)28 Test (org.testng.annotations.Test)22 FirefoxDriver (org.openqa.selenium.firefox.FirefoxDriver)20 BeforeClass (org.junit.BeforeClass)19 FirefoxProfile (org.openqa.selenium.firefox.FirefoxProfile)18 TestSetup (com.coveros.selenified.utilities.TestSetup)17 PhantomJSDriver (org.openqa.selenium.phantomjs.PhantomJSDriver)15 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)14 Before (org.junit.Before)13 Test (org.junit.Test)13 MalformedURLException (java.net.MalformedURLException)12 WebDriver (org.openqa.selenium.WebDriver)12 Actions (org.openqa.selenium.interactions.Actions)12 Dimension (org.openqa.selenium.Dimension)11