我想使用appium在

Android手机上自动化浏览器,但我不知道如何设置功能.

首先,我在开发人员选项中在我的Android设备上启用了USB调试.

其次,adb运行良好,我可以看到设备ID.

第三,我从Appium for Windows启动了Appium.exe,并通过JAVA编写了一些代码,但我不知道如何在Android浏览器上设置该功能.

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;

}

}

}

非常感谢.

Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐