Repository-Metriken
- Stars
- (3.184 Stars)
- PR-Merge-Metriken
- (PR-Metriken ausstehend)
Beschreibung
-
问题描述: 进入微信公众号之后切换webview,并点击元素跳转到下一个页面,再次切换webview并点击页面元素的时候提示Argument was an invalid selector
-
Macaca Version: 2.1.2
-
代码: public class Test4 {
BaseMacacaClient driver = new BaseMacacaClient();
@BeforeMethod public void setUp() throws Exception { JSONObject porps = new JSONObject(); porps.put("autoAcceptAlerts", true); porps.put("platformName", Config.ADR_PLATFORM_NAME); porps.put("udid", "192.168.100.117:15361"); porps.put("deviceName", "STF"); driver.setCurPlatform(PlatformType.ANDROID); porps.put("reuse", Config.REUSE); porps.put("package", "com.tencent.mm"); porps.put("activity", "com.tencent.mm.ui.LauncherUI"); // 关键是加上这段 porps.put("androidProcess", "com.tencent.mm:tools");
JSONObject desiredCapabilities = new JSONObject(); desiredCapabilities.put("desiredCapabilities", porps); driver.initDriver(desiredCapabilities);}
@Test public void test_case_1() throws Exception {
driver.sleep(2000); driver.elementByName("内部运营001").click(); driver.elementByName("我的服务").click(); driver.elementByName("个人主页").click(); Thread.sleep(5000);
// driver.switchFromNativeToWebView(); System.out.println(driver.contexts); switchToWebView(driver); Thread.sleep(2000); System.out.println("=========================="+driver.currentContext()); driver.elementByName("全部").click(); Thread.sleep(2000); System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"+driver.currentContext()); driver.switchFromeWebviewToNative(); Thread.sleep(2000); System.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"+driver.currentContext()); switchToWebView(driver); Thread.sleep(2000); System.out.println("###############################"+driver.currentContext()); driver.elementByName("已订业务").click(); }
public static MacacaClient switchToWebView(MacacaClient driver) throws Exception {
JSONArray contexts = driver.contexts();
return driver.context(contexts.get(contexts.size() - 1).toString());
}
@AfterMethod
public void tearDown() throws Exception {
Thread.sleep(5000);
driver.quit();
}
}
- 日志:
UIAutomatorWD http server ready macaca-android.js:303:10 [master] pid:12776 start app with: {"package":"com.tencent.mm","activity":"","androidProcess":"com.tencent.mm:tools"} responseHandler.js:49:14 [master] pid:12776 Send HTTP Respone to Client[2018-03-30 10:39:57]: {"sessionId":"de53ed02-6892-4746-9b17-7b94547c0c87","status":0,"value":"{"reuse":"3","package":"com.tencent.mm","activity":"com.tencent.mm.ui.LauncherUI","androidProcess":"com.tencent.mm:tools","platformName":"Android","udid":"192.168.100.117:15361","deviceName":"STF","autoAcceptAlerts":true}"} responseHandler.js:11:12 [master] pid:12776 Recieve HTTP Request from Client[2018-03-30 10:39:59]: method: POST url: /wd/hub/session/de53ed02-6892-4746-9b17-7b94547c0c87/element, jsonBody: {"using":"name","value":"内部运营001"} proxy.js:55:14 [master] pid:12776 Proxy: /wd/hub/session/:sessionId/accept_alert:POST to http://127.0.0.1:9009/wd/hub/session/:sessionId/accept_alert:POST with body: {} proxy.js:85:20 [master] pid:12776 Got response with status 200: {"status":0,"sessionId":null} proxy.js:55:14 [master] pid:12776 Proxy: /wd/hub/session/de53ed02-6892-4746-9b17-7b94547c0c87/element:POST to http://127.0.0.1:9009/wd/hub/session/:sessionId/element:POST with body: {"using":"name","value":"内部运营001"} proxy.js:85:20 [master] pid:12776 Got response with status 200: {"status":0,"value":{"ELEMENT":"1"},"sessionId":"de53ed02-6892-4746-9b17-7b94547c0c87"} session.js:120:14 [master] pid:12776 Send HTTP Respone to Client[2018-03-30 10:40:00]: {"status":0,"value":"{"ELEMENT":"1"}","sessionId":"de53ed02-6892-4746-9b17-7b94547c0c87"} responseHandler.js:11:12 [master] pid:12776 Recieve HTTP Request from Client[2018-03-30 10:40:00]: method: POST url: /wd/hub/session/de53ed02-6892-4746-9b17-7b94547c0c87/element/1/click, jsonBody: {} proxy.js:55:14 [master] pid:12776 Proxy: /wd/hub/session/:sessionId/accept_alert:POST to http://127.0.0.1:9009/wd/hub/session/:sessionId/accept_alert:POST with body: {} proxy.js:85:20 [master] pid:12776 Got response with status 200: {"status":0,"sessionId":":sessionId"} proxy.js:55:14 [master] pid:12776 Proxy: /wd/hub/session/de53ed02-6892-4746-9b17-7b94547c0c87/element/1/click:POST to http://127.0.0.1:9009/wd/hub/session/:sessionId/element/1/click:POST with body: {} proxy.js:85:20 [master] pid:12776 Got response with status 200: {"status":0,"sessionId":"de53ed02-6892-4746-9b17-7b94547c0c87"} session.js:120:14 [master] pid:12776 Send HTTP Respone to Client[2018-03-30 10:40:01]: {"status":0,"sessionId":"de53ed02-6892-4746-9b17-7b94547c0c87"} responseHandler.js:11:12 [master] pid:12776 Recieve HTTP Request from Client[2018-03-30 10:40:01]: method: POST url: /wd/hub/session/de53ed02-6892-4746-9b17-7b94547c0c87/element, jsonBody: {"using":"name","value":"我的服务"} proxy.js:55:14 [master] pid:12776 Proxy: /wd/hub/session/:sessionId/accept_alert:POST to http://127.0.0.1:9009/wd/hub/session/:sessionId/accept_alert:POST with body: {} proxy.js:85:20 [master] pid:12776 Got response with status 200: {"status":0,"sessionId":":sessionId"} proxy.js:55:14 [master] pid:12776 Proxy: /wd/hub/session/de53ed02-6892-4746-9b17-7b94547c0c87/element:POST to http://127.0.0.1:9009/wd/hub/session/:sessionId/element:POST with body: {"using":"name","value":"我的服务"} proxy.js:85:20 [master] pid:12776 Got response with status 200: {"status":0,"value":{"ELEMENT":"1"},"sessionId":"de53ed02-6892-4746-9b17-7b94547c0c87"} session.js:120:14 [master] pid:12776 Send HTTP Respone to Client[2018-03-30 10:40:03]: {"status":0,"value":"{"ELEMENT":"1"}","sessionId":"de53ed02-6892-4746-9b17-7b94547c0c87"} responseHandler.js:11:12 [master] pid:12776 Recieve HTTP Request from Client[2018-03-30 10:40:03]: method: POST url: /wd/hub/session/de53ed02-6892-4746-9b17-7b94547c0c87/element/1/click, jsonBody: {} proxy.js:55:14 [master] pid:12776 Proxy: /wd/hub/session/:sessionId/accept_alert:POST to http://127.0.0.1:9009/wd/hub/session/:sessionId/accept_alert:POST with body: {} proxy.js:85:20 [master] pid:12776 Got response with status 200: {"status":0,"sessionId":":sessionId"} proxy.js:55:14 [master] pid:12776 Proxy: /wd/hub/session/de53ed02-6892-4746-9b17-7b94547c0c87/element/1/click:POST to http://127.0.0.1:9009/wd/hub/session/:sessionId/element/1/click:POST with body: {} proxy.js:85:20 [master] pid:12776 Got response with status 200: {"status":0,"sessionId":"de53ed02-6892-4746-9b17-7b94547c0c87"} session.js:120:14 [master] pid:12776 Send HTTP Respone to Client[2018-03-30 10:40:04]: {"status":0,"sessionId":"de53ed02-6892-4746-9b17-7b94547c0c87"} responseHandler.js:11:12 [master] pid:12776 Recieve HTTP Request from Client[2018-03-30 10:40:04]: method: POST url: /wd/hub/session/de53ed02-6892-4746-9b17-7b94547c0c87/element, jsonBody: {"using":"name","value":"个人主页"} proxy.js:55:14 [master] pid:12776 Proxy: /wd/hub/session/:sessionId/accept_alert:POST to http://127.0.0.1:9009/wd/hub/session/:sessionId/accept_alert:POST with body: {} proxy.js:85:20 [master] pid:12776 Got response with status 200: {"status":0,"sessionId":":sessionId"} proxy.js:55:14 [master] pid:12776 Proxy: /wd/hub/session/de53ed02-6892-4746-9b17-7b94547c0c87/element:POST to http://127.0.0.1:9009/wd/hub/session/:sessionId/element:POST with body: {"using":"name","value":"个人主页"} proxy.js:85:20 [master] pid:12776 Got response with status 200: {"status":0,"value":{"ELEMENT":"1"},"sessionId":"de53ed02-6892-4746-9b17-7b94547c0c87"} session.js:120:14 [master] pid:12776 Send HTTP Respone to Client[2018-03-30 10:40:05]: {"status":0,"value":"{"ELEMENT":"1"}","sessionId":"de53ed02-6892-4746-9b17-7b94547c0c87"} responseHandler.js:11:12 [master] pid:12776 Recieve HTTP Request from Client[2018-03-30 10:40:05]: method: POST url: /wd/hub/session/de53ed02-6892-4746-9b17-7b94547c0c87/element/1/click, jsonBody: {} proxy.js:55:14 [master] pid:12776 Proxy: /wd/hub/session/:sessionId/accept_alert:POST to http://127.0.0.1:9009/wd/hub/session/:sessionId/accept_alert:POST with body: {} proxy.js:85:20 [master] pid:12776 Got response with status 200: {"status":0,"sessionId":":sessionId"} proxy.js:55:14 [master] pid:12776 Proxy: /wd/hub/session/de53ed02-6892-4746-9b17-7b94547c0c87/element/1/click:POST to http://127.0.0.1:9009/wd/hub/session/:sessionId/element/1/click:POST with body: {} proxy.js:85:20 [master] pid:12776 Got response with status 200: {"status":0,"sessionId":"de53ed02-6892-4746-9b17-7b94547c0c87"} session.js:120:14 [master] pid:12776 Send HTTP Respone to Client[2018-03-30 10:40:06]: {"status":0,"sessionId":"de53ed02-6892-4746-9b17-7b94547c0c87"} responseHandler.js:11:12 [master] pid:12776 Recieve HTTP Request from Client[2018-03-30 10:40:11]: method: GET url: /wd/hub/session/de53ed02-6892-4746-9b17-7b94547c0c87/contexts, jsonBody: {} Could not get the webview version! No webview version found from adb shell! responseHandler.js:49:14 [master] pid:12776 Send HTTP Respone to Client[2018-03-30 10:40:12]: {"sessionId":"de53ed02-6892-4746-9b17-7b94547c0c87","status":0,"value":"["NATIVE_APP"]"} responseHandler.js:11:12 [master] pid:12776 Recieve HTTP Request from Client[2018-03-30 10:40:12]: method: POST url: /wd/hub/session/de53ed02-6892-4746-9b17-7b94547c0c87/context, jsonBody: {"name":"NATIVE_APP"} responseHandler.js:49:14 [master] pid:12776 Send HTTP Respone to Client[2018-03-30 10:40:12]: {"sessionId":"de53ed02-6892-4746-9b17-7b94547c0c87","status":0,"value":null} responseHandler.js:11:12 [master] pid:12776 Recieve HTTP Request from Client[2018-03-30 10:40:14]: method: POST url: /wd/hub/session/de53ed02-6892-4746-9b17-7b94547c0c87/element, jsonBody: {"using":"name","value":"全部"} proxy.js:55:14 [master] pid:12776 Proxy: /wd/hub/session/:sessionId/accept_alert:POST to http://127.0.0.1:9009/wd/hub/session/:sessionId/accept_alert:POST with body: {} proxy.js:85:20 [master] pid:12776 Got response with status 200: {"status":13,"value":"An unknown server-side error occurred while processing the command.","sessionId":":sessionId"} proxy.js:55:14 [master] pid:12776 Proxy: /wd/hub/session/de53ed02-6892-4746-9b17-7b94547c0c87/element:POST to http://127.0.0.1:9009/wd/hub/session/:sessionId/element:POST with body: {"using":"name","value":"全部"} proxy.js:85:20 [master] pid:12776 Got response with status 200: {"status":0,"value":{"ELEMENT":"1"},"sessionId":"de53ed02-6892-4746-9b17-7b94547c0c87"} session.js:120:14 [master] pid:12776 Send HTTP Respone to Client[2018-03-30 10:40:15]: {"status":0,"value":"{"ELEMENT":"1"}","sessionId":"de53ed02-6892-4746-9b17-7b94547c0c87"} responseHandler.js:11:12 [master] pid:12776 Recieve HTTP Request from Client[2018-03-30 10:40:15]: method: POST url: /wd/hub/session/de53ed02-6892-4746-9b17-7b94547c0c87/element/1/click, jsonBody: {} proxy.js:55:14 [master] pid:12776 Proxy: /wd/hub/session/:sessionId/accept_alert:POST to http://127.0.0.1:9009/wd/hub/session/:sessionId/accept_alert:POST with body: {} proxy.js:85:20 [master] pid:12776 Got response with status 200: {"status":13,"value":"An unknown server-side error occurred while processing the command.","sessionId":":sessionId"} proxy.js:55:14 [master] pid:12776 Proxy: /wd/hub/session/de53ed02-6892-4746-9b17-7b94547c0c87/element/1/click:POST to http://127.0.0.1:9009/wd/hub/session/:sessionId/element/1/click:POST with body: {} proxy.js:85:20 [master] pid:12776 Got response with status 200: {"status":0,"sessionId":"de53ed02-6892-4746-9b17-7b94547c0c87"} session.js:120:14 [master] pid:12776 Send HTTP Respone to Client[2018-03-30 10:40:16]: {"status":0,"sessionId":"de53ed02-6892-4746-9b17-7b94547c0c87"} responseHandler.js:11:12 [master] pid:12776 Recieve HTTP Request from Client[2018-03-30 10:40:18]: method: GET url: /wd/hub/session/de53ed02-6892-4746-9b17-7b94547c0c87/contexts, jsonBody: {} Could not get the webview version! No webview version found from adb shell! responseHandler.js:49:14 [master] pid:12776 Send HTTP Respone to Client[2018-03-30 10:40:19]: {"sessionId":"de53ed02-6892-4746-9b17-7b94547c0c87","status":0,"value":"["NATIVE_APP"]"} responseHandler.js:11:12 [master] pid:12776 Recieve HTTP Request from Client[2018-03-30 10:40:19]: method: POST url: /wd/hub/session/de53ed02-6892-4746-9b17-7b94547c0c87/context, jsonBody: {"name":"NATIVE_APP"} responseHandler.js:49:14 [master] pid:12776 Send HTTP Respone to Client[2018-03-30 10:40:19]: {"sessionId":"de53ed02-6892-4746-9b17-7b94547c0c87","status":0,"value":null} responseHandler.js:11:12 [master] pid:12776 Recieve HTTP Request from Client[2018-03-30 10:40:21]: method: GET url: /wd/hub/session/de53ed02-6892-4746-9b17-7b94547c0c87/contexts, jsonBody: {} Could not get the webview version! No webview version found from adb shell! responseHandler.js:49:14 [master] pid:12776 Send HTTP Respone to Client[2018-03-30 10:40:22]: {"sessionId":"de53ed02-6892-4746-9b17-7b94547c0c87","status":0,"value":"["NATIVE_APP"]"} responseHandler.js:11:12 [master] pid:12776 Recieve HTTP Request from Client[2018-03-30 10:40:22]: method: POST url: /wd/hub/session/de53ed02-6892-4746-9b17-7b94547c0c87/context, jsonBody: {"name":"NATIVE_APP"} responseHandler.js:49:14 [master] pid:12776 Send HTTP Respone to Client[2018-03-30 10:40:22]: {"sessionId":"de53ed02-6892-4746-9b17-7b94547c0c87","status":0,"value":null} responseHandler.js:11:12 [master] pid:12776 Recieve HTTP Request from Client[2018-03-30 10:40:24]: method: POST url: /wd/hub/session/de53ed02-6892-4746-9b17-7b94547c0c87/element, jsonBody: {"using":"name","value":"已订业务"} proxy.js:55:14 [master] pid:12776 Proxy: /wd/hub/session/:sessionId/accept_alert:POST to http://127.0.0.1:9009/wd/hub/session/:sessionId/accept_alert:POST with body: {} proxy.js:85:20 [master] pid:12776 Got response with status 200: {"status":0,"sessionId":":sessionId"} proxy.js:55:14 [master] pid:12776 Proxy: /wd/hub/session/de53ed02-6892-4746-9b17-7b94547c0c87/element:POST to http://127.0.0.1:9009/wd/hub/session/:sessionId/element:POST with body: {"using":"name","value":"已订业务"} proxy.js:85:20 [master] pid:12776 Got response with status 200: {"status":32,"value":"Argument was an invalid selector (e.g. XPath/CSS).","sessionId":"de53ed02-6892-4746-9b17-7b94547c0c87"} session.js:120:14 [master] pid:12776 Send HTTP Respone to Client[2018-03-30 10:40:26]: {"status":32,"value":""Argument was an invalid selector (e.g. XPath/CSS)."","sessionId":"de53ed02-6892-4746-9b17-7b94547c0c87"} responseHandler.js:11:12 [master] pid:12776 Recieve HTTP Request from Client[2018-03-30 10:40:31]: method: DELETE url: /wd/hub/session/de53ed02-6892-4746-9b17-7b94547c0c87, jsonBody: {} session.js:91:12 [master] pid:12776 Delete session, sessionId: de53ed02-6892-4746-9b17-7b94547c0c87 responseHandler.js:49:14 [master] pid:12776 Send HTTP Respone to Client[2018-03-30 10:40:31]: {"sessionId":"de53ed02-6892-4746-9b17-7b94547c0c87","status":0}