Search in sources :

Example 71 with DesiredCapabilities

use of org.openqa.selenium.remote.DesiredCapabilities in project java-client by appium.

the class SelendroidModeTest method beforeClass.

/**
 * initialization.
 */
@BeforeClass
public static void beforeClass() {
    AppiumServiceBuilder builder = new AppiumServiceBuilder();
    service = builder.build();
    service.start();
    File appDir = new File("src/test/java/io/appium/java_client");
    File app = new File(appDir, "ApiDemos-debug.apk");
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator");
    capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
    capabilities.setCapability(AndroidMobileCapabilityType.SELENDROID_PORT, SELENDROID_PORT);
    capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.SELENDROID);
    driver = new AndroidDriver<>(service.getUrl(), capabilities);
    driver.context("NATIVE_APP");
}
Also used : AppiumServiceBuilder(io.appium.java_client.service.local.AppiumServiceBuilder) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 72 with DesiredCapabilities

use of org.openqa.selenium.remote.DesiredCapabilities in project java-client by appium.

the class IOSMobileBrowserCompatibilityTest method setUp.

/**
 * The setting up.
 */
@Before
public void setUp() {
    service = AppiumDriverLocalService.buildDefaultService();
    service.start();
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, MobileBrowserType.SAFARI);
    capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "9.2");
    capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone Simulator");
    // sometimes environment has performance problems
    capabilities.setCapability(IOSMobileCapabilityType.LAUNCH_TIMEOUT, 500000);
    driver = new IOSDriver<>(service.getUrl(), capabilities);
    PageFactory.initElements(new AppiumFieldDecorator(driver, 5, TimeUnit.SECONDS), this);
}
Also used : AppiumFieldDecorator(io.appium.java_client.pagefactory.AppiumFieldDecorator) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) Before(org.junit.Before)

Example 73 with DesiredCapabilities

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

the class ChromePagePerformanceObjectTest method beforeClass.

@SuppressWarnings("deprecation")
@BeforeClass
public static void beforeClass() throws IOException {
    getOsName();
    System.setProperty("webdriver.chrome.driver", osName.toLowerCase().startsWith("windows") ? new File("c:/java/selenium/chromedriver.exe").getAbsolutePath() : "/var/run/chromedriver");
    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);
    for (String option : (new String[] { "allow-running-insecure-content", "allow-insecure-localhost", "enable-local-file-accesses", "disable-notifications", /* "start-maximized" , */
    "browser.download.folderList=2", "--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"  , */
    })) {
        options.addArguments(option);
    }
    // options for headless
    if (headless) {
        // headless option arguments
        for (String option : (osName.toLowerCase().startsWith("windows")) ? new String[] { "headless", "disable-gpu", "disable-plugins", "window-size=1200x600", "window-position=-9999,0" } : new String[] { "headless", "disable-gpu", "remote-debugging-port=9222", "window-size=1200x600" }) {
            options.addArguments(option);
        }
    // on Windows need ChromeDriver 2.31 / Chrome 60 to support headless
    // With earlier versions of chromedriver: chrome not reachable...
    // https://developers.google.com/web/updates/2017/04/headless-chrome
    // https://stackoverflow.com/questions/43880619/headless-chrome-and-selenium-on-windows
    }
    // 
    capabilities.setBrowserName(DesiredCapabilities.chrome().getBrowserName());
    capabilities.setCapability(ChromeOptions.CAPABILITY, options);
    capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
    driver = new ChromeDriver(capabilities);
    try {
        // origin:
        // https://www.tutorialspoint.com/sqlite/sqlite_java.htm
        Class.forName("org.sqlite.JDBC");
        // String dbURL = "jdbc:sqlite:performance.db";
        conn = DriverManager.getConnection("jdbc:sqlite:performance.db");
        if (conn != null) {
            // System.out.println("Connected to the database");
            DatabaseMetaData databaseMetadata = conn.getMetaData();
            System.out.println("Driver name: " + databaseMetadata.getDriverName());
            System.out.println("Driver version: " + databaseMetadata.getDriverVersion());
            System.out.println("Product name: " + databaseMetadata.getDatabaseProductName());
            System.out.println("Product version: " + databaseMetadata.getDatabaseProductVersion());
            createNewTable();
        // insertData("name", 1.0);
        // conn.close();
        }
    } catch (ClassNotFoundException | SQLException ex) {
        ex.printStackTrace();
    } finally {
    }
    assertThat(driver, notNullValue());
}
Also used : HashMap(java.util.HashMap) SQLException(java.sql.SQLException) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) ChromeOptions(org.openqa.selenium.chrome.ChromeOptions) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver) DatabaseMetaData(java.sql.DatabaseMetaData) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 74 with DesiredCapabilities

use of org.openqa.selenium.remote.DesiredCapabilities in project ghostdriver by detro.

the class BaseTest method configure.

@BeforeClass
public static void configure() throws IOException {
    // Read config file
    sConfig = new Properties();
    sConfig.load(new FileReader(CONFIG_FILE));
    // Prepare capabilities
    sCaps = new DesiredCapabilities();
    sCaps.setJavascriptEnabled(true);
    sCaps.setCapability("takesScreenshot", false);
    String driver = sConfig.getProperty("driver", DRIVER_PHANTOMJS);
    // Fetch PhantomJS-specific configuration parameters
    if (driver.equals(DRIVER_PHANTOMJS)) {
        // "phantomjs_exec_path"
        if (sConfig.getProperty("phantomjs_exec_path") != null) {
            sCaps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, sConfig.getProperty("phantomjs_exec_path"));
        } else {
            throw new IOException(String.format("Property '%s' not set!", PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY));
        }
        // "phantomjs_driver_path"
        if (sConfig.getProperty("phantomjs_driver_path") != null) {
            System.out.println("Test will use an external GhostDriver");
            sCaps.setCapability(PhantomJSDriverService.PHANTOMJS_GHOSTDRIVER_PATH_PROPERTY, sConfig.getProperty("phantomjs_driver_path"));
        } else {
            System.out.println("Test will use PhantomJS internal GhostDriver");
        }
    }
    // Disable "web-security", enable all possible "ssl-protocols" and "ignore-ssl-errors" for PhantomJSDriver
    // sCaps.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, new String[] {
    // "--web-security=false",
    // "--ssl-protocol=any",
    // "--ignore-ssl-errors=true"
    // });
    ArrayList<String> cliArgsCap = new ArrayList<String>();
    cliArgsCap.add("--web-security=false");
    cliArgsCap.add("--ssl-protocol=any");
    cliArgsCap.add("--ignore-ssl-errors=true");
    sCaps.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, cliArgsCap);
    // Control LogLevel for GhostDriver, via CLI arguments
    sCaps.setCapability(PhantomJSDriverService.PHANTOMJS_GHOSTDRIVER_CLI_ARGS, new String[] { "--logLevel=" + (sConfig.getProperty("phantomjs_driver_loglevel") != null ? sConfig.getProperty("phantomjs_driver_loglevel") : "INFO") });
}
Also used : DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) ArrayList(java.util.ArrayList) FileReader(java.io.FileReader) IOException(java.io.IOException) Properties(java.util.Properties) BeforeClass(org.junit.BeforeClass)

Example 75 with DesiredCapabilities

use of org.openqa.selenium.remote.DesiredCapabilities in project java.webdriver by sayems.

the class IEBrowser method getDesiredCapabilities.

@Override
public DesiredCapabilities getDesiredCapabilities(Proxy proxySettings) {
    DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
    capabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
    capabilities.setCapability(InternetExplorerDriver.ENABLE_PERSISTENT_HOVERING, true);
    capabilities.setCapability("requireWindowFocus", true);
    capabilities.setCapability("screenResolution", "1280x1024");
    return addProxySettings(capabilities, proxySettings);
}
Also used : DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities)

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