背景: 小弟要测试一个 hybrid 类型的 app。apk 进来跳转到 webview,现在能够显示 webview 的内容,却不能进行测试操作。
手机是 Android 4.2.2,电脑是 windows。 代码如下:
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("device","Android");
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability(CapabilityType.VERSION, "4.2");
capabilities.setCapability(CapabilityType.PLATFORM, "WINDOWS");
capabilities.setCapability("app-package", "com.paic.mobileoa");
capabilities.setCapability("app-activity", ".LoadingActivity");
remoteWebDriver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}
@After
public void tearDown() throws Exception {
driver.quit();
}
@Test
public void addContact(){
try{
Thread.sleep(20000);
}catch(Exception e){
e.printStackTrace();
}
remoteWebDriver.switchTo().window("WEBVIEW");
remoteWebDriver.findElement(By.name("待处理文件")).click();
remoteWebDriver.executeScript("mobile: leaveWebView");
报错信息:
报错说:
debug: Request received with params: {"name":"WEBVIEW"}
Responding to client that a method is not implemented 为什么啊??
同样的,我在手机上跑 sample 里面那个 AndroidContactsTest.java 就没有问题。
debug: Appium request initiated at /wd/hub/session/bd62b7a5-c2dd-4545-9f56-594957055823
debug: Request received with params: {}
info: Responding to client with success: {"status":0,"value":{"platform":"WINDOWS","browserN
ame":"","version":"4.2","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled"
:true,"databaseEnabled":false,"app-package":"com.paic.mobileoa","device":"Android","app-acti
vity":".LoadingActivity"},"sessionId":"bd62b7a5-c2dd-4545-9f56-594957055823"}
GET /wd/hub/session/bd62b7a5-c2dd-4545-9f56-594957055823 200 9ms - 388b
debug: Appium request initiated at /wd/hub/session/bd62b7a5-c2dd-4545-9f56-594957055823/wind
ow
debug: Request received with params: {"name":"WEBVIEW"}
info: Responding to client that a method is not implemented
POST /wd/hub/session/bd62b7a5-c2dd-4545-9f56-594957055823/window 501 15ms - 180b