Skip to content

Instantly share code, notes, and snippets.

@DominikDary
Last active August 29, 2015 14:16
Show Gist options
  • Save DominikDary/b8585beb8dfb1f6d9c92 to your computer and use it in GitHub Desktop.
Save DominikDary/b8585beb8dfb1f6d9c92 to your computer and use it in GitHub Desktop.
/**
*
*/
package io.selendroid.standalone.server.handler;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriverService;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
/**
* @author dary
*
*/
public class AndroidHybridAppChromeDriverTest {
@Test
public void testChromeDriver() throws Exception {
ChromeDriverService service = startChromeDriver();
DesiredCapabilities capa = new DesiredCapabilities();
capa.setCapability("platform", "android");
capa.setCapability("browserName", "android");
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("androidUseRunningApp", true);
options.setExperimentalOption("androidDeviceSerial", "emulator-5554");
options.setExperimentalOption("androidPackage",
"io.selendroid.androiddriver");
capa.setCapability("chromeOptions", options);
System.out.println("url: " + service.getUrl());
WebDriver driver = new RemoteWebDriver(service.getUrl(), capa);
System.out.println(driver.getPageSource());
driver.quit();
}
private ChromeDriverService startChromeDriver() throws Exception {
System.setProperty("webdriver.chrome.driver",
"/Users/dary.de/bin/chromedriver");
ChromeDriverService chromeDriverService = ChromeDriverService
.createDefaultService();
chromeDriverService.start();
return chromeDriverService;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment