I want to use appium to automate browser on android phone,but I don't know how to set the capability.
First, I have enabled USB debugging on my Android device in the developer options.
Second, adb was working well, i can see the device id.
Third, I started Appium.exe from Appium for windows and writed some code by JAVA, but I don't know how to set the capability on Android browser.
public class Test {
private WebDriver driver;
@Before
public void setUp() throws Exception {
DesiredCapabilities capabilities = new DesiredCapabilities();
//------------I don't know how to set the capability------------//
capabilities.setCapability(CapabilityType.VERSION, "2.3.7");
capabilities.setCapability(CapabilityType.PLATFORM, "WINDOWS");
//--------------------------------------------------------------//
driver = new SwipeableWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}
@Test
public void testcase_001() throws Exception{
driver.get("http://www.google.com");
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("lst-ib")));
WebElement keyword = driver.findElement(By.name("lst-ib"));
keyword.sendKeys("appium");
driver.findElement(By.id("btnK")).click();
Thread.sleep(5000);
}
@After
public void tearDown() throws Exception {
driver.quit();
}
public class SwipeableWebDriver extends RemoteWebDriver implements HasTouchScreen {
private RemoteTouchScreen touch;
public SwipeableWebDriver(URL remoteAddress, Capabilities desiredCapabilities) {
super(remoteAddress, desiredCapabilities);
touch = new RemoteTouchScreen(getExecuteMethod());
}
public TouchScreen getTouch() {
return touch;
}
}
}
Many thanks.
Try this
Try something as next:
It should lunch Chrome driver.
Try this code using Android Driver:
Note: Use selenium version 2.48.2 (latest version) to make the android driver run without any error.
You can try with this capability type: CapabilityType.BROWSER_NAME --- "Browser"
This code is working on my end: