背景:被测应用有部分功能是 html5 实现的,目前准备使用 appium 来进行自动化脚本的编写
出现问题功能点的流程介绍:
流程:JS 调用 prompt 函数,java 端进行拦截,如果发现是 h5 的调用,就不会弹框,进行逻辑处理。
预期结果:点击修改密码 webview,打开密码修改页面
实际结果:触发 webview,打开一个对话框 (对话框只能关闭应用,不然对话框没法取消) --这种情况,在手工测试不存在
以下为尝试的一些功能代码
//第一种方法
driver.findElement(By.id("changePassBtn")).click();
/第二种方法
JavascriptExecutor jse = (JavascriptExecutor) driver;
jse.executeAsyncScript("document.getElementById('changePassBtn').click()");/
/* 第三种方法
TouchAction touch = new TouchAction(driver);
WebElement we = driver.findElement(By.linkText("修改密码"));
driver.performTouchAction(touch.press(we));
Thread.sleep(2000);*/
配置信息:
appium 1.2.0.0
android4.4.4
win7 64bit
appium 日志:
ERROR: debug: Appium request initiated at /wd/hub/session/063c92cb-338f-0946-7720-20fbca1e38b8/element
ERROR: debug: Request received with params: {"using":"id","value":"changePassBtn"}
ERROR: debug: Proxying command to localhost:8080
ERROR: debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/session/063c92cb-338f-0946-7720-20fbca1e38b8/element,method:POST,json:{using:id,value:changePassBtn}"}
ERROR: debug: Proxied response received with status 200: {"value":{"ELEMENT":":wdc:1410545493144"},"status":0,"sessionId":"063c92cb-338f-0946-7720-20fbca1e38b8"}
info: <-- POST /wd/hub/session/063c92cb-338f-0946-7720-20fbca1e38b8/element 200 383.973 ms - 104
info: --> POST /wd/hub/session/063c92cb-338f-0946-7720-20fbca1e38b8/element/%3Awdc%3A1410545493144/click {"id":":wdc:1410545493144"}
ERROR: debug: Appium request initiated at /wd/hub/session/063c92cb-338f-0946-7720-20fbca1e38b8/element/%3Awdc%3A1410545493144/click
ERROR: debug: Request received with params: {"id":":wdc:1410545493144"}
ERROR: debug: Proxying command to localhost:8080
ERROR: debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/session/063c92cb-338f-0946-7720-20fbca1e38b8/element/%3Awdc%3A1410545493144/click,method:POST,json:{id::wdc:1410545493144}"}
ERROR: debug: Proxied response received with status 200: {"value":"","status":0,"sessionId":"063c92cb-338f-0946-7720-20fbca1e38b8"}
info: <-- POST /wd/hub/session/063c92cb-338f-0946-7720-20fbca1e38b8/element/%3Awdc%3A1410545493144/click 200 824.407 ms - 74
info: --> DELETE /wd/hub/session/063c92cb-338f-0946-7720-20fbca1e38b8 {}
ERROR: debug: Appium request initiated at /wd/hub/session/063c92cb-338f-0946-7720-20fbca1e38b8
info: Shutting down appium session
ERROR: debug: Request received with params: {}
ERROR: debug: Stopping selendroid server
ERROR: debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/session/063c92cb-338f-0946-7720-20fbca1e38b8,method:DELETE"}
ERROR: debug: executing: "D:\AndroidSDK\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe" -s 03b9af73f0b4ff81 shell "am force-stop cn.uc.gamesdk.demo"
ERROR: debug: [SELENDROID] mSeq=0 mSystemUiVisibility=0x0
ERROR: debug: [SELENDROID] mSystemDecorRect=[0,0][1080,665] last=[0,0][1080,665]
ERROR: debug: Stopping logcat capture
ERROR: debug: Logcat terminated with code null, signal SIGTERM
info: <-- DELETE /wd/hub/session/063c92cb-338f-0946-7720-20fbca1e38b8 200 597.623 ms - 76 {"status":0,"value":null,"sessionId":"063c92cb-338f-0946-7720-20fbca1e38b8"}
ERROR: debug: Cleaning up appium session
ERROR: debug: Responding to client with success: {"status":0,"value":null,"sessionId":"063c92cb-338f-0946-7720-20fbca1e38b8"}