测试积点老人 发表于 2020-2-10 13:07:24

在微信切换 webview 时遇到 Original error

在微信切换 webview 时遇到 Original error: unknown error: Failed to get PID for com.tencent.mm:tools
##前置条件:
1.真机 OPPO R11st
2.安卓版本 7.1.1
3.真机webview 66.0.3359.126(chrome浏览器和微信内嵌webview同此版本)
4.appium 1.15.1
###代码
public static void main(String[] args) throws Exception {

   //创建配置对象
    DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
    desiredCapabilities.setCapability("deviceName","OPPO R11st");
    //测试平台
    desiredCapabilities.setCapability("platformName", "Android");
    //安卓系统版本
    desiredCapabilities.setCapability("paltformVersion", "7.1.1");
    desiredCapabilities.setCapability("appPackage", "com.tencent.mm");
    desiredCapabilities.setCapability("appActivity", ".ui.LauncherUI");
    //不清除数据启动
    desiredCapabilities.setCapability("noReset", "True");
    desiredCapabilities.setCapability("recreateChromeDriverSessions","True");
    //自动化引擎(解决输入框不能输入的问题)
    desiredCapabilities.setCapability("automationName", "uiautomator2");
    // 支持X5内核应用自动化配置
    desiredCapabilities.setCapability("recreateChromeDriverSessions", true);
    ChromeOptions options = new ChromeOptions();
    options.setExperimentalOption("androidProcess", "com.tencent.mm:tools");
    desiredCapabilities.setCapability(ChromeOptions.CAPABILITY, options);
    desiredCapabilities.setCapability("browserName","");

<p>//创建驱动
    androidDriver = new AndroidDriver(new URL("<a href="http://127.0.0.1:4723/wd/hub">http://127.0.0.1:4723/wd/hub</a>"), desiredCapabilities);
    //元素超时等待
    androidDriver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
    weChat();
    //关闭驱动
    androidDriver.quit();</p><p>}</p><p> public static void weChat() throws Exception {
   Thread.sleep(5000);
   androidDriver.findElementById("com.tencent.mm:id/r_").click();
   androidDriver.findElementById("com.tencent.mm:id/m7").sendKeys("接口测试号");
   androidDriver.findElementById("com.tencent.mm:id/s7").click();
   androidDriver.findElementByAndroidUIAutomator("new UiSelector().text(\"贷款\")").click();
   androidDriver.findElementByAndroidUIAutomator("new UiSelector().text(\"卢贝尔TEST\")").click();
   Thread.sleep(15000);
   Set<String> context = androidDriver.getContextHandles();
   for(String contextname : context){
      System.out.println(contextname);//打印
      if(contextname.equals("WEBVIEW_com.tencent.mm:tools"))
            androidDriver.context(contextname);
      }
   System.out.println(androidDriver.findElementsByXPath("//*").toString());
   System.out.println("进来了。。。。。。");
   androidDriver.findElementByXPath("//*[@id=\"app\"]/div/div/div/img").click();
   androidDriver.findElementByXPath("//*[@id=\"app\"]/div/div/div/div/input").sendKeys("13983871447");
   androidDriver.findElementByXPath("//*[@id=\"app\"]/div/div/div/div/div").sendKeys("qwe000111");
   androidDriver.findElementByXPath("//*[@id=\"app\"]/div/div/div/input").click();
   Thread.sleep(25000);
}
##appium详细信息
###这里可以看到pid是被找到了的
Parsed pid: '21104' pkg: 'com.tencent.mm:tools' from
   USER      PID   PPIDVSIZERSSFRZ          WCHAN            PCNAME
   u0_a297   21104 997   3907284 381152 efg         0 0000000000 S com.tencent.mm:tools
Returning process name: 'com.tencent.mm:tools'
Parsed pid: '20267' pkg: 'com.tencent.mm' from
   USER      PID   PPIDVSIZERSSFRZ          WCHAN            PCNAME
   u0_a297   20267 997   3487468 300536 efg         0 0000000000 S com.tencent.mm
Returning process name: 'com.tencent.mm'
Parsed pid: '20643' pkg: 'com.tencent.mm:appbrand0' from
   USER      PID   PPIDVSIZERSSFRZ          WCHAN            PCNAME
   u0_a297   20643 997   3474560 255204 unk         0 0000000000 S com.tencent.mm:appbrand0
Returning process name: 'com.tencent.mm:appbrand0'
Parsed pid: '21040' pkg: 'com.tencent.mm:toolsmp' from
   USER      PID   PPIDVSIZERSSFRZ          WCHAN            PCNAME
   u0_a297   21040 997   3227048 264568 unk         0 0000000000 S com.tencent.mm:toolsmp
Returning process name: 'com.tencent.mm:toolsmp'
Found webviews: ["WEBVIEW_com.tencent.mm:tools","WEBVIEW_com.tencent.mm:appbrand0","WEBVIEW_com.tencent.mm","WEBVIEW_com.tencent.mm:toolsmp"]
Available contexts:
##appium报错信息
Starting MJSONWP Chromedriver session with capabilities: {
   "desiredCapabilities": {
   "chromeOptions": {
       "androidPackage": "com.tencent.mm",
       "androidUseRunningApp": true,
       "androidProcess": "com.tencent.mm:tools",
       "args": [],
       "extensions": [],
       "androidDeviceSerial": "8905da57"
   },
   "loggingPrefs": {
       "browser": "ALL"
   }
   }
}
Matched '/session' to command name 'createSession'
Proxying to with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.tencent.mm","androidUseRunningApp":true,"androidProcess":"com.tencent.mm:tools","args":[],"extensions":[],"androidDeviceSerial":"8905da57"},"loggingPrefs":{"browser":"ALL"}}}
Got response with status 200: {"sessionId":"db8120c4243d3b2e3714bb62b5357a5b","status":13,"value":{"message":"unknown error: Failed to get PID for the following process: com.tencent.mm:tools\n(Driver info: chromedriver=2.40.565498 (ea082db3280dd6843ebfb08a625e3eb905c4f5ab),platform=Windows NT 6.1.7601 SP1 x86_64)"}}
Determined the downstream protocol as 'MJSONWP'
The response has an unknown format
Matched JSONWP error code 13 to UnknownError
Failed to start Chromedriver session: An unknown server-side error occurred while processing the command. Original error: unknown error: Failed to get PID for the following process: com.tencent.mm:tools
   (Driver info: chromedriver=2.40.565498 (ea082db3280dd6843ebfb08a625e3eb905c4f5ab),platform=Windows NT 6.1.7601 SP1 x86_64)
Matched '/session' to command name 'createSession'
Proxying to with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.tencent.mm","androidUseRunningApp":true,"androidProcess":"com.tencent.mm:tools","args":[],"extensions":[],"androidDeviceSerial":"8905da57"},"loggingPrefs":{"browser":"ALL"}}}
Got response with status 200: {"sessionId":"41893d46f51c7c60c153a16cd7cfe42f","status":13,"value":{"message":"unknown error: Failed to get PID for the following process: com.tencent.mm:tools\n(Driver info: chromedriver=2.40.565498 (ea082db3280dd6843ebfb08a625e3eb905c4f5ab),platform=Windows NT 6.1.7601 SP1 x86_64)"}}
Determined the downstream protocol as 'MJSONWP'
The response has an unknown format
Matched JSONWP error code 13 to UnknownError
Failed to start Chromedriver session: An unknown server-side error occurred while processing the command. Original error: unknown error: Failed to get PID for the following process: com.tencent.mm:tools</p>


jingzizx 发表于 2020-2-11 10:52:09

不清楚
页: [1]
查看完整版本: 在微信切换 webview 时遇到 Original error