Search in sources :

Example 31 with DesiredCapabilities

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

the class ParallelTest method setUp.

@Parameters(value = { "browser", "version", "platform" })
@BeforeClass
public void setUp(String browser, String version, String platform) throws MalformedURLException, InterruptedException, WebDriverException {
    DesiredCapabilities capability = new DesiredCapabilities();
    capability.setCapability("platform", platform);
    capability.setCapability("browserName", browser);
    capability.setCapability("browserVersion", version);
    capability.setCapability("project", "P1");
    capability.setCapability("build", "1.0");
    driver = new RemoteWebDriver(new URL("http://" + USERNAME + ":" + ACCESS_KEY + "@hub.browserstack.com/wd/hub"), capability);
}
Also used : RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) URL(java.net.URL) BeforeClass(org.testng.annotations.BeforeClass) Parameters(org.testng.annotations.Parameters)

Example 32 with DesiredCapabilities

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

the class AppTest method setup.

@BeforeClass
public static void setup() throws IOException {
    // System.out.println(System.getProperty("user.dir"));
    FirefoxProfile profile = new FirefoxProfile();
    try {
        profile.addExtension(new File(System.getProperty("user.dir") + "/src/main/resources/firefox"));
    } catch (IOException e) {
        e.printStackTrace();
    }
    // http://www.programcreek.com/java-api-examples/index.php?api=org.openqa.selenium.firefox.FirefoxProfile
    // http://www.atetric.com/atetric/javadoc/org.seleniumhq.selenium/selenium-firefox-driver/2.43.1/src-html/org/openqa/selenium/firefox/FirefoxProfile.html
    profile.setPreference("app.update.enabled", false);
    // Setting preferences
    // profile.setPreference("extensions.firebug.currentVersion", "2.0");
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setBrowserName("firefox");
    capabilities.setPlatform(org.openqa.selenium.Platform.ANY);
    capabilities.setCapability(FirefoxDriver.PROFILE, profile);
    driver = new RemoteWebDriver(capabilities);
    driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
}
Also used : RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) IOException(java.io.IOException) FirefoxProfile(org.openqa.selenium.firefox.FirefoxProfile) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 33 with DesiredCapabilities

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

the class SearchTest method setUp.

@Before
public void setUp() throws Exception {
    DesiredCapabilities capabilities = new DesiredCapabilities("firefox", "", Platform.ANY);
    WebDriver seleniumDriver = new FirefoxDriver(capabilities);
    // new ChromeDriver()
    // ChromeDriverManager.getInstance().setup();
    // java.lang.NoClassDefFoundError:
    // org/openqa/selenium/remote/service/DriverService$Builder
    steps = new WebDriverSteps(seleniumDriver);
}
Also used : WebDriver(org.openqa.selenium.WebDriver) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) WebDriverSteps(my.company.steps.WebDriverSteps) FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) Before(org.junit.Before)

Example 34 with DesiredCapabilities

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

the class AngularAndWebDriverTest method setupBrowser.

@SuppressWarnings("deprecation")
private void setupBrowser(String browser) {
    System.setProperty("webdriver.chrome.driver", (new File("c:/java/selenium/chromedriver.exe")).getAbsolutePath());
    DesiredCapabilities capabilities = DesiredCapabilities.chrome();
    ChromeOptions chromeOptions = new ChromeOptions();
    Map<String, Object> chromePrefs = new HashMap<>();
    chromePrefs.put("profile.default_content_settings.popups", 0);
    String downloadFilepath = System.getProperty("user.dir") + System.getProperty("file.separator") + "target" + System.getProperty("file.separator");
    chromePrefs.put("download.prompt_for_download", "false");
    chromePrefs.put("download.directory_upgrade", "true");
    chromePrefs.put("plugins.always_open_pdf_externally", "true");
    chromePrefs.put("download.default_directory", downloadFilepath);
    chromePrefs.put("enableNetwork", "true");
    chromeOptions.setExperimentalOption("prefs", chromePrefs);
    for (String optionAgrument : (new String[] { "--user-agent=Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20120101 Firefox/33.0", "--allow-running-insecure-content", "--allow-insecure-localhost", "--enable-local-file-accesses", "--disable-notifications", "--disable-save-password-bubble", /* "start-maximized" , */
    "--browser.download.folderList=2", "--disable-web-security", "--no-proxy-server", "--browser.helperApps.neverAsk.saveToDisk=image/jpg,text/csv,text/xml,application/xml,application/vnd.ms-excel,application/x-excel,application/x-msexcel,application/excel,application/pdf", String.format("--browser.download.dir=%s", downloadFilepath) /* "--user-data-dir=/path/to/your/custom/profile"  , */
    })) {
        chromeOptions.addArguments(optionAgrument);
    }
    capabilities.setBrowserName(DesiredCapabilities.chrome().getBrowserName());
    capabilities.setCapability(org.openqa.selenium.chrome.ChromeOptions.CAPABILITY, chromeOptions);
    capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
    driver = new ChromeDriver(capabilities);
}
Also used : HashMap(java.util.HashMap) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) ChromeOptions(org.openqa.selenium.chrome.ChromeOptions) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver) File(java.io.File)

Example 35 with DesiredCapabilities

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

the class TestWithData method beforeSuite.

@BeforeSuite
public void beforeSuite() {
    System.setProperty("webdriver.chrome.driver", (new File("c:/java/selenium/chromedriver.exe")).getAbsolutePath());
    DesiredCapabilities capabilities = DesiredCapabilities.chrome();
    ChromeOptions options = new ChromeOptions();
    Map<String, Object> chromePrefs = new HashMap<>();
    chromePrefs.put("profile.default_content_settings.popups", 0);
    String downloadFilepath = System.getProperty("user.dir") + System.getProperty("file.separator") + "target" + System.getProperty("file.separator");
    chromePrefs.put("download.default_directory", downloadFilepath);
    chromePrefs.put("enableNetwork", "true");
    options.setExperimentalOption("prefs", chromePrefs);
    options.addArguments("allow-running-insecure-content");
    options.addArguments("allow-insecure-localhost");
    options.addArguments("enable-local-file-accesses");
    options.addArguments("disable-notifications");
    // options.addArguments("start-maximized");
    options.addArguments("browser.download.folderList=2");
    options.addArguments("--browser.helperApps.neverAsk.saveToDisk=image/jpg,text/csv,text/xml,application/xml,application/vnd.ms-excel,application/x-excel,application/x-msexcel,application/excel,application/pdf");
    options.addArguments("browser.download.dir=" + downloadFilepath);
    // options.addArguments("user-data-dir=/path/to/your/custom/profile");
    capabilities.setBrowserName(DesiredCapabilities.chrome().getBrowserName());
    capabilities.setCapability(ChromeOptions.CAPABILITY, options);
    capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
    driver = new ChromeDriver(capabilities);
    actions = new Actions(driver);
    driver.manage().timeouts().setScriptTimeout(scriptTimeout, TimeUnit.SECONDS);
    wait = new WebDriverWait(driver, flexibleWait);
    wait.pollingEvery(pollingInterval, TimeUnit.MILLISECONDS);
    screenshot = ((TakesScreenshot) driver);
    js = ((JavascriptExecutor) driver);
    mySheet = getSpreadSheet();
}
Also used : JavascriptExecutor(org.openqa.selenium.JavascriptExecutor) HashMap(java.util.HashMap) Actions(org.openqa.selenium.interactions.Actions) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) ChromeOptions(org.openqa.selenium.chrome.ChromeOptions) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver) File(java.io.File) TakesScreenshot(org.openqa.selenium.TakesScreenshot) BeforeSuite(org.testng.annotations.BeforeSuite)

Aggregations

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