Java Code Examples for org.openqa.selenium.remote.CapabilityType

The following are top voted examples for showing how to use org.openqa.selenium.remote.CapabilityType. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: zucchini   File: SeleniumDriver.java   Source Code and License 8 votes vote down vote up
private static WebDriver createPhantomJSDriver(String driverPath) {

		DesiredCapabilities desiredCapabilities = DesiredCapabilities.phantomjs();
		desiredCapabilities.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, driverPath);
		desiredCapabilities.setCapability(CapabilityType.ELEMENT_SCROLL_BEHAVIOR, true);
		desiredCapabilities.setCapability(CapabilityType.TAKES_SCREENSHOT, true);
		desiredCapabilities.setCapability(CapabilityType.ENABLE_PROFILING_CAPABILITY, true);
		desiredCapabilities.setCapability(CapabilityType.HAS_NATIVE_EVENTS, true);

		desiredCapabilities.setJavascriptEnabled(true);

		ArrayList<String> cliArgs = new ArrayList<String>();
		cliArgs.add("--web-security=true");
		cliArgs.add("--ignore-ssl-errors=true");
		desiredCapabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, cliArgs);

		return new PhantomJSDriver(desiredCapabilities);
	}
 
Example 2
Project: packagedrone   File: TestSuite.java   Source Code and License 7 votes vote down vote up
protected static RemoteWebDriver createSauce ( final Platform os, final String browser, final String version ) throws MalformedURLException
{
    final DesiredCapabilities capabilities = new DesiredCapabilities ();
    capabilities.setBrowserName ( browser );
    if ( version != null )
    {
        capabilities.setVersion ( version );
    }
    capabilities.setCapability ( CapabilityType.PLATFORM, os );
    capabilities.setCapability ( CapabilityType.SUPPORTS_FINDING_BY_CSS, true );
    capabilities.setCapability ( "name", "Eclipse Package Drone Main Test" );

    if ( System.getenv ( "TRAVIS_JOB_NUMBER" ) != null )
    {
        capabilities.setCapability ( "tunnel-identifier", System.getenv ( "TRAVIS_JOB_NUMBER" ) );
        capabilities.setCapability ( "build", System.getenv ( "TRAVIS_BUILD_NUMBER" ) );
        capabilities.setCapability ( "tags", new String[] { "CI" } );
    }

    final RemoteWebDriver driver = new RemoteWebDriver ( new URL ( String.format ( "http://%s:%[email protected]%s/wd/hub", SAUCE_USER_NAME, SAUCE_ACCESS_KEY, SAUCE_URL ) ), capabilities );

    driver.setFileDetector ( new LocalFileDetector () );

    return driver;
}
 
Example 3
Project: spa-perf   File: SPAPerfChromeDriver.java   Source Code and License 7 votes vote down vote up
private static DesiredCapabilities getPerformanceLoggingCapabilities() {
    DesiredCapabilities caps = DesiredCapabilities.chrome();

    // Enable performance logging
    LoggingPreferences logPrefs = new LoggingPreferences();
    logPrefs.enable(LogType.PERFORMANCE, Level.ALL);
    caps.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);

    // Enable timeline tracing
    Map<String, Object> chromeOptions = new HashMap<String, Object>();
    Map<String, String> perfLoggingPrefs = new HashMap<String, String>();
    // Tracing categories, please note NO SPACE NEEDED after the commas
    perfLoggingPrefs.put("traceCategories", "blink.console,disabled-by-default-devtools.timeline");
    chromeOptions.put("perfLoggingPrefs", perfLoggingPrefs);
    //chromeOptions.put("debuggerAddress", "127.0.0.1:10134");
    caps.setCapability(ChromeOptions.CAPABILITY, chromeOptions);

    return caps;
}
 
Example 4
Project: NoraUi   File: DriverFactory.java   Source Code and License 6 votes vote down vote up
/**
 * Generates a phantomJs webdriver.
 *
 * @return
 *         A phantomJs webdriver
 * @throws TechnicalException
 *             if an error occured when Webdriver setExecutable to true.
 */
private WebDriver generatePhantomJsDriver() throws TechnicalException {
    final String pathWebdriver = DriverFactory.getPath(Driver.PHANTOMJS);
    if (!new File(pathWebdriver).setExecutable(true)) {
        throw new TechnicalException(Messages.getMessage(TechnicalException.TECHNICAL_ERROR_MESSAGE_WEBDRIVER_SET_EXECUTABLE));
    }
    logger.info("Generating Phantomjs driver ({}) ...", pathWebdriver);

    final DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_PAGE_CUSTOMHEADERS_PREFIX + "Accept-Language", "fr-FR");
    capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, pathWebdriver);
    capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);
    capabilities.setJavascriptEnabled(true);

    setLoggingLevel(capabilities);

    // Proxy configuration
    String proxy = "";
    if (Context.getProxy().getProxyType() != ProxyType.UNSPECIFIED && Context.getProxy().getProxyType() != ProxyType.AUTODETECT) {
        proxy = Context.getProxy().getHttpProxy();
    }
    capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS,
            new String[] { "--proxy=" + proxy, "--web-security=no", "--ignore-ssl-errors=true", "--ssl-protocol=tlsv1", "--webdriver-loglevel=NONE" });
    return new PhantomJSDriver(capabilities);
}
 
Example 5
Project: NoraUi   File: DriverFactory.java   Source Code and License 6 votes vote down vote up
/**
 * Generates a htmlunit webdriver.
 *
 * @return
 *         A htmlunit webdriver
 */
private WebDriver generateHtmlUnitDriver() {
    logger.info("Generating HtmlUnit driver...");
    final DesiredCapabilities capabilities = DesiredCapabilities.htmlUnit();
    capabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
    capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);
    capabilities.setJavascriptEnabled(true);

    setLoggingLevel(capabilities);

    // Proxy configuration
    if (Context.getProxy().getProxyType() != ProxyType.UNSPECIFIED && Context.getProxy().getProxyType() != ProxyType.AUTODETECT) {
        capabilities.setCapability(CapabilityType.PROXY, Context.getProxy());
    }
    return new HtmlUnitDriver(capabilities);
}
 
Example 6
Project: akita-testing-template   File: AkitaChromeDriverProvider.java   Source Code and License 6 votes vote down vote up
@Override
public WebDriver createDriver(DesiredCapabilities capabilities) {
    Map<String, Object> preferences = new Hashtable<>();
    preferences.put("profile.default_content_settings.popups", 0);
    preferences.put("download.prompt_for_download", "false");
    String downloadsPath = System.getProperty("user.home") + "/Downloads";
    preferences.put("download.default_directory", loadSystemPropertyOrDefault("fileDownloadPath", downloadsPath));
    preferences.put("plugins.plugins_disabled", new String[]{
            "Adobe Flash Player", "Chrome PDF Viewer"});
    ChromeOptions options = new ChromeOptions();
    options.setExperimentalOption("prefs", preferences);

    capabilities = DesiredCapabilities.chrome();
    capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
    capabilities.setCapability(ChromeOptions.CAPABILITY, options);
    return new ChromeDriver(capabilities);
}
 
Example 7
Project: Bytecoder   File: BytecoderUnitTestRunner.java   Source Code and License 6 votes vote down vote up
private WebDriver newDriverForTest() {
    ChromeOptions theOptions = new ChromeOptions();
    theOptions.addArguments("headless");
    theOptions.addArguments("disable-gpu");

    LoggingPreferences theLoggingPreferences = new LoggingPreferences();
    theLoggingPreferences.enable(LogType.BROWSER, Level.ALL);
    theOptions.setCapability(CapabilityType.LOGGING_PREFS, theLoggingPreferences);

    DesiredCapabilities theCapabilities = DesiredCapabilities.chrome();
    theCapabilities.setCapability(ChromeOptions.CAPABILITY, theOptions);

    return new RemoteWebDriver(DRIVERSERVICE.getUrl(), theCapabilities);
}
 
Example 8
Project: AutomationFrameworkTPG   File: DriverProperties.java   Source Code and License 6 votes vote down vote up
private WebDriver initIEDriver(String appURL) {
	System.out.println("Launching IE browser..");
	DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
	ieCapabilities.setJavascriptEnabled(true); 
	ieCapabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS,   
			true); 
	ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true); 
	ieCapabilities.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING,true);         
	ieCapabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR,UnexpectedAlertBehaviour.DISMISS); //Accept unexpected alerts 
	ieCapabilities.setCapability("requireWindowFocus", true); 
	ieCapabilities.setCapability("enablePersistentHover", false); 
	ieCapabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
	
	WebDriver driver=new InternetExplorerDriver(ieCapabilities);
	driver.manage().deleteAllCookies();
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    for(String winHandle : driver.getWindowHandles()){
       driver =  driver.switchTo().window(winHandle);
    }
    driver.get(appURL);
	return new WebDriverProxy().protect(driver);
}
 
Example 9
Project: Spring-Security-Third-Edition   File: SeleniumTestUtilities.java   Source Code and License 6 votes vote down vote up
public static WebDriver get64IEDriver()
{
	String path = System.getProperty("user.dir") + "\\Drivers\\IEDriverServer64.exe";
	System.setProperty("webdriver.ie.driver", path);
	DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
	caps.setCapability(CapabilityType.BROWSER_NAME, "IE");
	caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,	true);

	return new InternetExplorerDriver(caps);
}
 
Example 10
Project: webtester2-core   File: RemoteFactoryTest.java   Source Code and License 6 votes vote down vote up
@Test
public void capabilitiesAreSetWhenCreatingBrowser() throws MalformedURLException {

    given(configuration.getRemoteBrowserName()).willReturn("firefox");
    given(configuration.getRemoteBrowserVersion()).willReturn("46.0.1");
    given(configuration.getRemoteFirefoxMarionette()).willReturn(true);
    given(configuration.getRemoteHost()).willReturn("localhost");
    given(configuration.getRemotePort()).willReturn(4444);

    cut.createBrowser();

    then(webDriverProducer).should().apply(urlCaptor.capture(), capabilitiesCaptor.capture());

    URL url = urlCaptor.getValue();
    assertThat(url).hasProtocol("http").hasHost("localhost").hasPort(4444).hasPath("/wd/hub");

    DesiredCapabilities capabilities = capabilitiesCaptor.getValue();
    assertThat(capabilities.getCapability(CapabilityType.BROWSER_NAME)).isEqualTo("firefox");
    assertThat(capabilities.getCapability(CapabilityType.VERSION)).isEqualTo("46.0.1");
    assertThat(capabilities.getCapability(CapabilityType.PLATFORM)).isEqualTo(Platform.ANY);
    assertThat(capabilities.getCapability(CapabilityType.HAS_NATIVE_EVENTS)).isEqualTo(false);
    assertThat(capabilities.getCapability(CapabilityType.ACCEPT_SSL_CERTS)).isEqualTo(true);
    assertThat(capabilities.getCapability("marionette")).isEqualTo(true);

}
 
Example 11
Project: 0686OS   File: TestCommon.java   Source Code and License 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    Configuration.load();
    Configuration.print();
    
    System.setProperty("webdriver.gecko.driver", new File("drivers/geckodriver").getAbsolutePath());
    System.setProperty("webdriver.chrome.driver", new File("drivers/chromedriver").getAbsolutePath());
    
    DesiredCapabilities cap = new DesiredCapabilities();
    cap.setCapability(CapabilityType.BROWSER_NAME, "");
    cap.setCapability("platformVersion", Configuration.get("app_platformVersion"));
    cap.setCapability("platformName", "Android");
    cap.setCapability("app", new File(Configuration.get("app_path")).getAbsolutePath());
    cap.setCapability("deviceName", "Any");
    cap.setCapability("commandTimeout", "60");
    if (Configuration.platform().isWeb()) {
        Driver.add(Configuration.get("browser"), cap);
    } else {
        Driver.add(Configuration.get("driver_url"), Configuration.get("browser"), cap);
    }
    searchPage = PageFactory.init(SearchPage.class);
    searchPage.navigate();
}
 
Example 12
Project: jscoverproxy-maven-plugin   File: JSCoverProxyMavenMojo.java   Source Code and License 6 votes vote down vote up
private WebDriver getWebClient(int portForJSCoverProxy) {
    Proxy proxy = new Proxy().setHttpProxy("localhost:" + portForJSCoverProxy);
    DesiredCapabilities caps = new DesiredCapabilities();
    caps.setCapability(CapabilityType.PROXY, proxy);
    caps.setJavascriptEnabled(true);
    caps.setBrowserName(BrowserType.HTMLUNIT);
    return new HtmlUnitDriver(caps) {
        @Override
        protected WebClient modifyWebClient(WebClient client) {
            client.setScriptPreProcessor((htmlPage, sourceCode, sourceName, lineNumber, htmlElement) -> {
                if(removeJsSnippets != null && !removeJsSnippets.isEmpty()) {
                    for(String toReplace : removeJsSnippets) {
                        sourceCode = sourceCode.replace(toReplace, "");
                    }
                    return sourceCode;
                } else {
                    return sourceCode;
                }

            });
            return client;
        }
    };
}
 
Example 13
Project: aet   File: FirefoxWebDriverFactory.java   Source Code and License 6 votes vote down vote up
@Override
public WebCommunicationWrapper createWebDriver(ProxyServerWrapper proxyServer)
    throws WorkerException {
  try {
    Proxy proxy = proxyServer.seleniumProxy();
    proxyServer.setCaptureContent(true);
    proxyServer.setCaptureHeaders(true);

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(CapabilityType.PROXY, proxy);
    capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);

    FirefoxProfile fp = getFirefoxProfile();
    fp.setAcceptUntrustedCertificates(true);
    fp.setAssumeUntrustedCertificateIssuer(false);
    capabilities.setCapability(AetFirefoxDriver.PROFILE, fp);

    return new WebCommunicationWrapperImpl(getFirefoxDriver(fp, capabilities), proxyServer,
        requestExecutorFactory
            .createInstance());
  } catch (Exception e) {
    throw new WorkerException(e.getMessage(), e);
  }
}
 
Example 14
Project: seleniumtestsframework   File: IOsCapabilitiesFactory.java   Source Code and License 6 votes vote down vote up
public DesiredCapabilities createCapabilities(final DriverConfig cfg) {
    final DesiredCapabilities capabilities = new DesiredCapabilities();

    capabilities.setCapability("automationName", cfg.getAutomationName());
    capabilities.setCapability("platformName", cfg.getMobilePlatformName());

    // Set up version and device name else appium server would pick the only available emulator/device
    // Both of these are ignored for android for now
    capabilities.setCapability("platformVersion", cfg.getMobilePlatformVersion());
    capabilities.setCapability("deviceName", cfg.getDeviceName());

    capabilities.setCapability("app", cfg.getApp());
    capabilities.setCapability("appPackage", cfg.getAppPackage());
    capabilities.setCapability("appActivity", cfg.getAppActivity());

    capabilities.setCapability(CapabilityType.BROWSER_NAME, cfg.getBrowserName());
    capabilities.setCapability("newCommandTimeout", cfg.getNewCommandTimeout());

    return capabilities;
}
 
Example 15
Project: seleniumtestsframework   File: IPhoneCapabilitiesFactory.java   Source Code and License 6 votes vote down vote up
public DesiredCapabilities createCapabilities(final DriverConfig cfg) {
    DesiredCapabilities capabilities = new DesiredCapabilities();

    capabilities.setCapability("automationName", cfg.getAutomationName());
    capabilities.setCapability("platformName", cfg.getMobilePlatformName());

    // Set up version and device name else appium server would pick the only available emulator/device
    // Both of these are ignored for android for now
    capabilities.setCapability("platformVersion", cfg.getMobilePlatformVersion());
    capabilities.setCapability("deviceName", cfg.getDeviceName());

    capabilities.setCapability("app", cfg.getApp());
    capabilities.setCapability("appPackage", cfg.getAppPackage());
    capabilities.setCapability("appActivity", cfg.getAppActivity());

    capabilities.setCapability(CapabilityType.BROWSER_NAME, cfg.getBrowserName());
    capabilities.setCapability("newCommandTimeout", cfg.getNewCommandTimeout());

    return capabilities;
}
 
Example 16
Project: seleniumtestsframework   File: AndroidCapabilitiesFactory.java   Source Code and License 6 votes vote down vote up
public DesiredCapabilities createCapabilities(final DriverConfig cfg) {
    DesiredCapabilities capabilities = new DesiredCapabilities();

    capabilities.setCapability("automationName", cfg.getAutomationName());
    capabilities.setCapability("platformName", cfg.getMobilePlatformName());

    // Set up version and device name else appium server would pick the only available emulator/device
    // Both of these are ignored for android for now
    capabilities.setCapability("platformVersion", cfg.getMobilePlatformVersion());
    capabilities.setCapability("deviceName", cfg.getDeviceName());

    capabilities.setCapability("app", cfg.getApp());
    capabilities.setCapability("appPackage", cfg.getAppPackage());
    capabilities.setCapability("appActivity", cfg.getAppActivity());

    capabilities.setCapability(CapabilityType.BROWSER_NAME, cfg.getBrowserName());
    capabilities.setCapability("newCommandTimeout", cfg.getNewCommandTimeout());

    return capabilities;
}
 
Example 17
Project: Appium-Grid-For-Android   File: BaseTest.java   Source Code and License 6 votes vote down vote up
public void createDriver(){
	try	{
		port = appiumMan.startAppium(); 			// Start appium server			  
		  
		// create appium driver instance
		DesiredCapabilities capabilities = DesiredCapabilities.android();
		capabilities.setCapability("deviceName", deviceName);
		capabilities.setCapability("platformName", "android");
		capabilities.setCapability(CapabilityType.VERSION, osVersion);
		capabilities.setCapability(CapabilityType.BROWSER_NAME, "chrome");
		capabilities.setCapability("udid", deviceId);
			
		this.driver = new AndroidDriver(new URL("http://127.0.0.1:"+port+"/wd/hub"),capabilities);
	}
	catch(Exception e){
    	e.printStackTrace();
    }
}
 
Example 18
Project: Appium-Grid-For-Android   File: BaseTest.java   Source Code and License 6 votes vote down vote up
public void createDriver(String appPath){
	try	{
		port = appiumMan.startAppium(); 			// Start appium server			  
		  
		// create appium driver instance
		DesiredCapabilities capabilities = DesiredCapabilities.android();
		capabilities.setCapability("deviceName", deviceName);
		capabilities.setCapability("platformName", "android");
		capabilities.setCapability(CapabilityType.VERSION, osVersion);
		capabilities.setCapability("app", appPath);
		capabilities.setCapability("udid", deviceId);
			
		this.driver = new AndroidDriver(new URL("http://127.0.0.1:"+port+"/wd/hub"),capabilities);
	}
	catch(Exception e){
    	e.printStackTrace();
    }
}
 
Example 19
Project: AndroidRobot   File: ChromeDriverClient.java   Source Code and License 6 votes vote down vote up
public void createDriver(String pkg_name, String sn) {
    	if(this.driver == null) {
	        ChromeOptions chromeOptions = new ChromeOptions();
	        chromeOptions.setExperimentalOption("androidPackage", pkg_name);
	//        chromeOptions.setExperimentalOption("androidActivity", "com.eg.android.AlipayGphone.AlipayLogin");
	//        chromeOptions.setExperimentalOption("debuggerAddress", "127.0.0.1:9222");
	        chromeOptions.setExperimentalOption("androidUseRunningApp", true);
	        chromeOptions.setExperimentalOption("androidDeviceSerial", sn);
	//        Map<String, Object> chromeOptions = new HashMap<String, Object>();
	//        chromeOptions.put("androidPackage", "com.eg.android.AlipayGphoneRC");
	//        chromeOptions.put("androidActivity", "com.eg.android.AlipayGphone.AlipayLogin");
	        DesiredCapabilities capabilities = DesiredCapabilities.chrome();
	        LoggingPreferences logPrefs = new LoggingPreferences();
	        logPrefs.enable(LogType.PERFORMANCE, Level.ALL);
	        capabilities.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
	        capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
//	        capabilities.setCapability(CapabilityType., value);
	        if(ChromeService.getService() != null)
	        	driver = new RobotRemoteWebDriver(ChromeService.getService().getUrl(), capabilities);
    	}
    }
 
Example 20
Project: grid-refactor-remote-server   File: NewSession.java   Source Code and License 6 votes vote down vote up
@Override
public Response handle() throws Exception {
  // Handle the case where the client does not send any desired capabilities.
  sessionId = allSessions.newSession(desiredCapabilities != null
                                     ? desiredCapabilities : new DesiredCapabilities());

  Map<String, Object> capabilities =
      Maps.newHashMap(allSessions.get(sessionId).getCapabilities().asMap());

  // Only servers implementing the server-side webdriver-backed selenium need
  // to return this particular value
  capabilities.put("webdriver.remote.sessionid", sessionId.toString());

  if (desiredCapabilities != null) {
    LoggingManager.perSessionLogHandler().configureLogging(
        (LoggingPreferences)desiredCapabilities.getCapability(CapabilityType.LOGGING_PREFS));
  }
  LoggingManager.perSessionLogHandler().attachToCurrentThread(sessionId);

  Response response = new Response();
  response.setSessionId(sessionId.toString());
  response.setValue(capabilities);
  return response;
}
 
Example 21
Project: AppiumSauce   File: ParallelBrowserTest.java   Source Code and License 6 votes vote down vote up
/**
 * Constructs a new {@link org.openqa.selenium.remote.RemoteWebDriver} instance which is configured to use the capabilities defined by the {@link #browser},
 * {@link #version} and {@link #os} instance variables, and which is configured to run against ondemand.saucelabs.com, using
 * the username and access key populated by the {@link #authentication} instance.
 *
 * @throws Exception if an error occurs during the creation of the {@link org.openqa.selenium.remote.RemoteWebDriver} instance.
 */
@Before
public void setUp() throws Exception {

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(CapabilityType.BROWSER_NAME, browser);
    if (version != null) {
        capabilities.setCapability(CapabilityType.VERSION, version);
    }
    capabilities.setCapability(CapabilityType.PLATFORM, os);
    capabilities.setCapability("name", "Sauce Sample Test");
    this.driver = new RemoteWebDriver(new URL("http://" + SAUCE_USERNAME + ":" + SAUCE_KEY + "@ondemand.saucelabs.com:80/wd/hub")
            ,capabilities);
    this.sessionId = (((RemoteWebDriver) driver).getSessionId()).toString();

}
 
Example 22
Project: seauto   File: AbstractConfigurableDriverProvider.java   Source Code and License 6 votes vote down vote up
/**
 * Best found default capabilities for Internet Explorer
 * 
 * @return {@link DesiredCapabilities}
 */
protected DesiredCapabilities getInternetExplorerCapabilities()
{
  final DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();

  // get past certificate security warning pages
  capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);

  // setup native events and window focus
  // http://jimevansmusic.blogspot.com/2012/06/whats-wrong-with-internet-explorer.html
  capabilities.setCapability(InternetExplorerDriver.NATIVE_EVENTS, true);
  capabilities.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, true);

  // don't accept alerts automatically
  capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, false);

  return capabilities;
}
 
Example 23
Project: package-drone   File: TestSuite.java   Source Code and License 6 votes vote down vote up
protected static RemoteWebDriver createSauce ( final Platform os, final String browser, final String version ) throws MalformedURLException
{
    final DesiredCapabilities capabilities = new DesiredCapabilities ();
    capabilities.setCapability ( CapabilityType.BROWSER_NAME, browser );
    if ( version != null )
    {
        capabilities.setCapability ( CapabilityType.VERSION, version );
    }
    capabilities.setCapability ( CapabilityType.PLATFORM, os );
    capabilities.setCapability ( "name", "Package Drone Main Test" );

    final RemoteWebDriver driver = new RemoteWebDriver ( new URL ( String.format ( "http://%s:%[email protected]:80/wd/hub", SAUCE_USER_NAME, SAUCE_ACCESS_KEY ) ), capabilities );

    driver.setFileDetector ( new LocalFileDetector () );

    return driver;
}
 
Example 24
Project: AndroidAppsTestAutomationSamples   File: AddCustomerTest.java   Source Code and License 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    // このテストに必要なdesired capabilitiesを構築し、それに基づいたAndroidDriverインスタンスを生成する。
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
    capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator");
    // Selendroidモードで動作させるときには、AUTOMATION_NAMEを"Selendroid"にする。
    capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "Selendroid");
    capabilities.setCapability(MobileCapabilityType.APP_PACKAGE, "com.nowsprinting.hellotesting.appium");
    capabilities.setCapability(MobileCapabilityType.APP_ACTIVITY, "com.nowsprinting.hellotesting.app.CustomerListActivity");
    capabilities.setCapability("unicodeKeyboard", true);
    capabilities.setCapability("resetKeyboard", true);
    mDriver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
    // デフォルトのタイムアウト値を80秒とする。
    mDriver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
}
 
Example 25
Project: SeleniumGridScaler   File: AutomationRunRequest.java   Source Code and License 6 votes vote down vote up
/**
 * Returns true if this run request matches the capabilities passed in.  Includes browser, browser version, and OS
 * @param capabilities
 * @return
 */
public boolean matchesCapabilities(Map<String,Object> capabilities) {
    String capabilityBrowser = (String)capabilities.get(CapabilityType.BROWSER_NAME);
    String capabilityBrowserVersion = (String)capabilities.get(CapabilityType.VERSION);
    String capabilityOs = (String)capabilities.get(CapabilityType.PLATFORM);
    if(!AutomationUtils.lowerCaseMatch(browser, capabilityBrowser)) {
        return false;
    }
    if(browserVersion != null && !AutomationUtils.lowerCaseMatch(browserVersion,capabilityBrowserVersion))  {
        return false;
    }
    if(os != null && !AutomationUtils.lowerCaseMatch(os, capabilityOs)) {
        // If either OS has 'ANY' for the platform, that means it should be a match regardless and we don't have to count this as a non-match
        if(!AutomationUtils.lowerCaseMatch(os,"any") && !AutomationUtils.lowerCaseMatch(capabilityOs,"any")) {
            return false;
        }
    }
    return true;
}
 
Example 26
Project: SeleniumGridScaler   File: AutomationRequestMatcherTest.java   Source Code and License 6 votes vote down vote up
@Test
// Tests that a node in the Expired state is not considered as a free resource
public void testRequestNodeExpiredState() throws IOException, ServletException{
    String browser = "firefox";
    String nodeId = "nodeId";
    // Add a node that is not running to make sure its not included in the available calculation
    AutomationDynamicNode node = new AutomationDynamicNode("testUuid",nodeId,null,null,new Date(),10);
    node.updateStatus(AutomationDynamicNode.STATUS.EXPIRED);
    AutomationContext.getContext().addNode(node);
    ProxySet proxySet = new ProxySet(false);
    MockRemoteProxy proxy = new MockRemoteProxy();
    proxy.setCapabilityMatcher(new AutomationCapabilityMatcher());
    Map<String,Object> config = new HashMap<String, Object>();
    config.put(AutomationConstants.INSTANCE_ID, nodeId);
    proxy.setConfig(config);
    List<TestSlot> testSlots = new ArrayList<TestSlot>();
    Map<String,Object> capabilities = new HashMap<String,Object>();
    capabilities.put(CapabilityType.BROWSER_NAME,browser);
    testSlots.add(new TestSlot(proxy, SeleniumProtocol.WebDriver, null, capabilities));
    proxy.setTestSlots(testSlots);
    proxySet.add(proxy);
    AutomationContext.getContext().setTotalNodeCount(50);
    AutomationRequestMatcher requestMatcher = new AutomationRequestMatcher();
    int freeThreads = requestMatcher.getNumFreeThreadsForParameters(proxySet,new AutomationRunRequest(browser));
    Assert.assertEquals("Thread count should be correct due to an expired node", 0, freeThreads);
}
 
Example 27
Project: SeleniumGridScaler   File: AutomationRequestMatcherTest.java   Source Code and License 6 votes vote down vote up
@Test
// Tests that a node in the Terminated state without an instance id is still considered a valid resource
public void testRequestNodeTerminatedNoInstanceId() throws IOException, ServletException{
    String browser = "firefox";
    String nodeId = "nodeId";
    // Add a node that is not running to make sure its not included in the available calculation
    AutomationDynamicNode node = new AutomationDynamicNode("testUuid",nodeId,null,null,new Date(),10);
    node.updateStatus(AutomationDynamicNode.STATUS.TERMINATED);
    AutomationContext.getContext().addNode(node);
    ProxySet proxySet = new ProxySet(false);
    MockRemoteProxy proxy = new MockRemoteProxy();
    proxy.setCapabilityMatcher(new AutomationCapabilityMatcher());
    proxy.setMaxNumberOfConcurrentTestSessions(5);
    Map<String,Object> config = new HashMap<>();
    proxy.setConfig(config);
    List<TestSlot> testSlots = new ArrayList<TestSlot>();
    Map<String,Object> capabilities = new HashMap<String,Object>();
    capabilities.put(CapabilityType.BROWSER_NAME,browser);
    testSlots.add(new TestSlot(proxy, SeleniumProtocol.WebDriver, null, capabilities));
    proxy.setTestSlots(testSlots);
    proxySet.add(proxy);
    AutomationContext.getContext().setTotalNodeCount(50);
    AutomationRequestMatcher requestMatcher = new AutomationRequestMatcher();
    int freeThreads = requestMatcher.getNumFreeThreadsForParameters(proxySet,new AutomationRunRequest(browser));
    Assert.assertEquals("Node should be available since instance id was not on the node", 1, freeThreads);
}
 
Example 28
Project: SeleniumGridScaler   File: AutomationRequestMatcherTest.java   Source Code and License 6 votes vote down vote up
@Test
// Happy path that browsers matching shows correct free node count
 public void testRequestMatchingBrowsers() throws IOException, ServletException{
    String browser = "firefox";
    String nodeId = "nodeId";
    // Add a node that is not running to make sure its not included in the available calculation
    AutomationDynamicNode node = new AutomationDynamicNode("testUuid",nodeId,null,null,new Date(),50);
    AutomationContext.getContext().addNode(node);
    ProxySet proxySet = new ProxySet(false);
    MockRemoteProxy proxy = new MockRemoteProxy();
    proxy.setMaxNumberOfConcurrentTestSessions(50);
    proxy.setCapabilityMatcher(new AutomationCapabilityMatcher());
    Map<String,Object> config = new HashMap<String, Object>();
    config.put(AutomationConstants.INSTANCE_ID,nodeId);
    proxy.setConfig(config);
    Map<String,Object> capabilities = new HashMap<String,Object>();
    capabilities.put(CapabilityType.BROWSER_NAME,browser);
    TestSlot testSlot = new TestSlot(proxy, SeleniumProtocol.WebDriver,null,capabilities);
    proxy.setMultipleTestSlots(testSlot, 10);
    proxySet.add(proxy);
    AutomationContext.getContext().setTotalNodeCount(50);
    int freeThreads = new AutomationRequestMatcher().getNumFreeThreadsForParameters(proxySet,new AutomationRunRequest(browser));

    Assert.assertEquals("Thread count should be correct due to matching browser", 10, freeThreads);
}
 
Example 29
Project: SeleniumGridScaler   File: AutomationRequestMatcherTest.java   Source Code and License 6 votes vote down vote up
@Test
// Test that non-matching browsers do not contribute to the free node count
public void testRequestNonMatchingBrowsers() throws IOException, ServletException{
    String browser = "firefox";
    String nodeId = "nodeId";
    // Add a node that is not running to make sure its not included in the available calculation
    AutomationDynamicNode node = new AutomationDynamicNode("testUuid",nodeId,null,null,new Date(),50);
    AutomationContext.getContext().addNode(node);
    ProxySet proxySet = new ProxySet(false);
    MockRemoteProxy proxy = new MockRemoteProxy();
    proxy.setMaxNumberOfConcurrentTestSessions(50);
    proxy.setCapabilityMatcher(new AutomationCapabilityMatcher());
    Map<String,Object> config = new HashMap<String, Object>();
    config.put(AutomationConstants.INSTANCE_ID,nodeId);
    proxy.setConfig(config);
    Map<String,Object> capabilities = new HashMap<String,Object>();
    capabilities.put(CapabilityType.BROWSER_NAME,"doesntMatch");
    TestSlot testSlot = new TestSlot(proxy, SeleniumProtocol.WebDriver,null,capabilities);
    proxy.setMultipleTestSlots(testSlot, 10);
    proxySet.add(proxy);
    AutomationContext.getContext().setTotalNodeCount(50);
    int freeThreads = new AutomationRequestMatcher().getNumFreeThreadsForParameters(proxySet,new AutomationRunRequest(browser));

    Assert.assertEquals("Thread count should be correct due to matching OS", 0, freeThreads);
}
 
Example 30
Project: SeleniumGridScaler   File: AutomationRequestMatcherTest.java   Source Code and License 6 votes vote down vote up
@Test
// Makes sure that all matching slots will be included to match
public void testRequestAllTestSlotsIncluded() throws IOException, ServletException{
    String browser = "firefox";
    String nodeId = "nodeId";
    // Add a node that is not running to make sure its not included in the available calculation
    AutomationDynamicNode node = new AutomationDynamicNode("testUuid",nodeId,null,null,new Date(),50);
    AutomationContext.getContext().addNode(node);
    ProxySet proxySet = new ProxySet(false);
    MockRemoteProxy proxy = new MockRemoteProxy();
    proxy.setMaxNumberOfConcurrentTestSessions(10);
    proxy.setCapabilityMatcher(new AutomationCapabilityMatcher());
    Map<String,Object> config = new HashMap<String, Object>();
    config.put(AutomationConstants.INSTANCE_ID,nodeId);
    proxy.setConfig(config);
    Map<String,Object> capabilities = new HashMap<String,Object>();
    capabilities.put(CapabilityType.BROWSER_NAME,"firefox");
    TestSlot testSlot = new TestSlot(proxy, SeleniumProtocol.WebDriver,null,capabilities);
    proxy.setMultipleTestSlots(testSlot, 10);
    proxySet.add(proxy);
    AutomationContext.getContext().setTotalNodeCount(50);
    int freeThreads = new AutomationRequestMatcher().getNumFreeThreadsForParameters(proxySet,new AutomationRunRequest(browser));
    Assert.assertEquals("There should be no matching threads since the node limit was reached",10,freeThreads);
}
 
Example 31
Project: SeleniumGridScaler   File: AutomationRequestMatcherTest.java   Source Code and License 6 votes vote down vote up
@Test
// Tests that the correct number of slots match even when the max session config on node is less than
// the slot number
public void testRequestAllTestSlotsIncludedGreaterNodeLimit() throws IOException, ServletException{
    String browser = "firefox";
    String nodeId = "nodeId";
    // Add a node that is not running to make sure its not included in the available calculation
    AutomationDynamicNode node = new AutomationDynamicNode("testUuid",nodeId,null,null,new Date(),50);
    AutomationContext.getContext().addNode(node);
    ProxySet proxySet = new ProxySet(false);
    MockRemoteProxy proxy = new MockRemoteProxy();
    proxy.setMaxNumberOfConcurrentTestSessions(15);
    proxy.setCapabilityMatcher(new AutomationCapabilityMatcher());
    Map<String,Object> config = new HashMap<String, Object>();
    config.put(AutomationConstants.INSTANCE_ID,nodeId);
    proxy.setConfig(config);
    Map<String,Object> capabilities = new HashMap<String,Object>();
    capabilities.put(CapabilityType.BROWSER_NAME,"firefox");
    TestSlot testSlot = new TestSlot(proxy, SeleniumProtocol.WebDriver,null,capabilities);
    proxy.setMultipleTestSlots(testSlot, 10);
    proxySet.add(proxy);
    AutomationContext.getContext().setTotalNodeCount(50);
    int freeThreads = new AutomationRequestMatcher().getNumFreeThreadsForParameters(proxySet,new AutomationRunRequest(browser));
    Assert.assertEquals("There should be no matching threads since the node limit was reached",10,freeThreads);
}
 
Example 32
Project: SeleniumGridScaler   File: AutomationRequestMatcherTest.java   Source Code and License 6 votes vote down vote up
@Test
// Tests that the correct number of slots match even when the max session config on node is greater than
// the slot number
public void testRequestAllTestSlotsIncludedLessThanNodeLimit() throws IOException, ServletException{
    String browser = "firefox";
    String nodeId = "nodeId";
    // Add a node that is not running to make sure its not included in the available calculation
    AutomationDynamicNode node = new AutomationDynamicNode("testUuid",nodeId,null,null,new Date(),50);
    AutomationContext.getContext().addNode(node);
    ProxySet proxySet = new ProxySet(false);
    MockRemoteProxy proxy = new MockRemoteProxy();
    proxy.setMaxNumberOfConcurrentTestSessions(5);
    proxy.setCapabilityMatcher(new AutomationCapabilityMatcher());
    Map<String,Object> config = new HashMap<String, Object>();
    config.put(AutomationConstants.INSTANCE_ID,nodeId);
    proxy.setConfig(config);
    Map<String,Object> capabilities = new HashMap<String,Object>();
    capabilities.put(CapabilityType.BROWSER_NAME,"firefox");
    TestSlot testSlot = new TestSlot(proxy, SeleniumProtocol.WebDriver,null,capabilities);
    proxy.setMultipleTestSlots(testSlot, 10);
    proxySet.add(proxy);
    AutomationContext.getContext().setTotalNodeCount(50);
    int freeThreads = new AutomationRequestMatcher().getNumFreeThreadsForParameters(proxySet,new AutomationRunRequest(browser));
    Assert.assertEquals("There should be no matching threads since the node limit was reached",5,freeThreads);
}
 
Example 33
Project: SeleniumGridScaler   File: AutomationRequestMatcherTest.java   Source Code and License 6 votes vote down vote up
@Test
// Test to make sure an in progress counts against the free node count
public void testRequestNewRunNotStarted() throws IOException, ServletException{
    String browser = "firefox";
    String nodeId = "nodeId";
    // Add a node that is not running to make sure its not included in the available calculation
    AutomationDynamicNode node = new AutomationDynamicNode("testUuid",nodeId,null,null,new Date(),50);
    AutomationContext.getContext().addNode(node);
    String runId = "runId";
    AutomationContext.getContext().addRun(new AutomationRunRequest(runId,10,"firefox"));
    ProxySet proxySet = new ProxySet(false);
    MockRemoteProxy proxy = new MockRemoteProxy();
    proxy.setMaxNumberOfConcurrentTestSessions(50);
    proxy.setCapabilityMatcher(new AutomationCapabilityMatcher());
    Map<String,Object> config = new HashMap<String, Object>();
    config.put(AutomationConstants.INSTANCE_ID, nodeId);
    proxy.setConfig(config);
    Map<String,Object> capabilities = new HashMap<String,Object>();
    capabilities.put(CapabilityType.BROWSER_NAME,"firefox");
    TestSlot testSlot = new TestSlot(proxy, SeleniumProtocol.WebDriver,null,capabilities);
    proxy.setMultipleTestSlots(testSlot, 10);
    proxySet.add(proxy);
    AutomationContext.getContext().setTotalNodeCount(50);
    int freeThreads = new AutomationRequestMatcher().getNumFreeThreadsForParameters(proxySet,new AutomationRunRequest(browser));
    Assert.assertEquals("No nodes should be free since existing run hasn't started",0,freeThreads);
}
 
Example 34
Project: SeleniumGridScaler   File: AutomationRunContextTest.java   Source Code and License 6 votes vote down vote up
@Test
// Tests that the correct node count is returned when tests don't have a UUID
public void testNodesFreeNoUuid() {
    AutomationRunContext runContext = new AutomationRunContext();
    runContext.setTotalNodeCount(10);
    ProxySet proxySet = new ProxySet(false);
    MockRemoteProxy proxy = new MockRemoteProxy();
    proxy.setCapabilityMatcher(new AutomationCapabilityMatcher());
    Map<String,Object> capabilities = new HashMap<>();
    capabilities.put(CapabilityType.PLATFORM,"linux");
    capabilities.put(CapabilityType.BROWSER_NAME,"chrome");
    TestSlot testSlot = new TestSlot(proxy, SeleniumProtocol.WebDriver,null,capabilities);
    testSlot.getNewSession(capabilities);
    proxy.setMultipleTestSlots(testSlot,5);
    proxySet.add(proxy);
    int freeThreads = runContext.getTotalThreadsAvailable(proxySet);
    Assert.assertEquals(5,freeThreads);
}
 
Example 35
Project: SeleniumGridScaler   File: AutomationRunContextTest.java   Source Code and License 6 votes vote down vote up
@Test
// Tests that the correct node count is returned when tests don't have a UUID
public void testNodesFreeWithUuid() {
    AutomationRunContext runContext = new AutomationRunContext();
    runContext.setTotalNodeCount(10);
    ProxySet proxySet = new ProxySet(false);
    MockRemoteProxy proxy = new MockRemoteProxy();
    proxy.setCapabilityMatcher(new AutomationCapabilityMatcher());
    Map<String,Object> capabilities = new HashMap<>();
    capabilities.put(CapabilityType.PLATFORM,"linux");
    capabilities.put(CapabilityType.BROWSER_NAME,"chrome");
    capabilities.put(AutomationConstants.UUID,"testUuid");
    TestSlot testSlot = new TestSlot(proxy, SeleniumProtocol.WebDriver,null,capabilities);
    testSlot.getNewSession(capabilities);
    proxy.setMultipleTestSlots(testSlot,5);
    proxySet.add(proxy);
    int freeThreads = runContext.getTotalThreadsAvailable(proxySet);
    Assert.assertEquals(5,freeThreads);
}
 
Example 36
Project: SeleniumGridScaler   File: AutomationRunContextTest.java   Source Code and License 6 votes vote down vote up
@Test
// Tests that a new run is counted instead of tests in progress
public void testNewRunIsCounted() {
    String uuid = "testUuid";
    AutomationRunContext runContext = new AutomationRunContext();
    runContext.setTotalNodeCount(10);
    ProxySet proxySet = new ProxySet(false);
    MockRemoteProxy proxy = new MockRemoteProxy();
    proxy.setCapabilityMatcher(new AutomationCapabilityMatcher());
    Map<String,Object> capabilities = new HashMap<>();
    capabilities.put(CapabilityType.PLATFORM,"linux");
    capabilities.put(CapabilityType.BROWSER_NAME,"chrome");
    capabilities.put(AutomationConstants.UUID,uuid);
    AutomationRunRequest request = new AutomationRunRequest(uuid,10,"chrome");
    runContext.addRun(request);
    TestSlot testSlot = new TestSlot(proxy, SeleniumProtocol.WebDriver,null,capabilities);
    testSlot.getNewSession(capabilities);
    proxy.setMultipleTestSlots(testSlot,5);
    proxySet.add(proxy);
    int freeThreads = runContext.getTotalThreadsAvailable(proxySet);
    Assert.assertEquals(0,freeThreads);
}
 
Example 37
Project: SeleniumGridScaler   File: AutomationRunContextTest.java   Source Code and License 6 votes vote down vote up
@Test
// Tests that for an old run, the in progress tests are counted
public void testOldRunInProgress() {
    String uuid = "testUuid";
    AutomationRunContext runContext = new AutomationRunContext();
    runContext.setTotalNodeCount(10);
    ProxySet proxySet = new ProxySet(false);
    MockRemoteProxy proxy = new MockRemoteProxy();
    proxy.setCapabilityMatcher(new AutomationCapabilityMatcher());
    Map<String,Object> capabilities = new HashMap<>();
    capabilities.put(CapabilityType.PLATFORM,"linux");
    capabilities.put(CapabilityType.BROWSER_NAME,"chrome");
    capabilities.put(AutomationConstants.UUID,uuid);
    AutomationRunRequest request = new AutomationRunRequest(uuid,10,"chrome","23","linux", AutomationUtils.modifyDate(new Date(),-5,Calendar.MINUTE));
    runContext.addRun(request);
    TestSlot testSlot = new TestSlot(proxy, SeleniumProtocol.WebDriver,null,capabilities);
    testSlot.getNewSession(capabilities);
    int inProgressTests = 5;
    proxy.setMultipleTestSlots(testSlot,inProgressTests);
    proxySet.add(proxy);
    int freeThreads = runContext.getTotalThreadsAvailable(proxySet);
    Assert.assertEquals("Free threads should reflect in progress test count",inProgressTests,freeThreads);
}
 
Example 38
Project: SeleniumGridScaler   File: AutomationRunRequestTest.java   Source Code and License 6 votes vote down vote up
@Test
// Tests that a platform of 'ANY' matches another otherwise non-matching OS
public void testOsMatchesAnyRequests() {
    String uuid = "testUuid";
    String browser = "firefox";
    String browserVersion = "25";
    String os = "ANY";
    Map<String,Object> map = new HashMap<>();
    map.put(CapabilityType.BROWSER_NAME,browser);
    map.put(CapabilityType.VERSION,browserVersion);
    map.put(CapabilityType.PLATFORM,os);
    AutomationRunRequest first = new AutomationRunRequest(uuid,null,browser,browserVersion,"linux");
    AutomationRunRequest second = AutomationRunRequest.requestFromCapabilities(map);
    Assert.assertTrue("Requests should be equal", first.matchesCapabilities(second));
    Assert.assertTrue("Requests should be equal", second.matchesCapabilities(first));
}
 
Example 39
Project: seletest   File: ConfigurationDriver.java   Source Code and License 6 votes vote down vote up
/**
 * android capabilities bean
 * @param appPath String path to apk stored
 * @param appActivity String activity to launch
 * @param appPackage String package of app
 * @param autolaunch String autolaunch specifies if application will be autolaunched or not
 * @return DesiredCapabilities
 */
@Bean
@Lazy(true)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public DesiredCapabilities androidcapabilities(String appPath, String appActivity, String appPackage, String autolaunch){
    File app=new File(appPath);
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(CapabilityType.PLATFORM, MobilePlatform.ANDROID);
    capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, "300");//how long (in seconds) Appium will wait for a new command from the client before assuming the client quit and ending the session
    capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
    capabilities.setCapability("autoLaunch", Boolean.parseBoolean(autolaunch));
    capabilities.setCapability(MobileCapabilityType.APP_ACTIVITY,appActivity);
    capabilities.setCapability(MobileCapabilityType.APP_PACKAGE, appPackage);
    capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID);
    capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "emulator");
    return capabilities;
}
 
Example 40
Project: seletest   File: ConfigurationDriver.java   Source Code and License 6 votes vote down vote up
/**
 * iOS capabilities bean
 * @param appPath String path to app or ipa stored
 * @param udid String udid of the device
 * @param bundleId String bundleid is the package name in iOS
 * @param autolaunch String autolaunch specifies if application will be autolaunched or not
 * @return DesiredCapabilities
 */
@Bean
@Lazy(true)
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public DesiredCapabilities iOScapabilities(String appPath, String udid, String bundleId, String autolaunch){
    File app=new File(appPath);
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(CapabilityType.PLATFORM, MobilePlatform.IOS);
    capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, "300");//how long (in seconds) Appium will wait for a new command from the client before assuming the client quit and ending the session
    capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
    capabilities.setCapability("autoLaunch", Boolean.parseBoolean(autolaunch));
    capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.IOS);
    capabilities.setCapability(MobileCapabilityType.APP_PACKAGE, bundleId);
    capabilities.setCapability("udid", udid);
    capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "emulator");
    return capabilities;
}