gpt4 book ai didi

android - 无法将上下文设置为 WEBVIEW

转载 作者:搜寻专家 更新时间:2023-11-01 09:29:27 31 4
gpt4 key购买 nike

我正在测试使用 Appium C# 绑定(bind)使用 Ionic(Cordova、AngularJS)构建的混合应用程序。与具有 id 属性的元素交互取得一定成功。能够将 css 选择器与 FindElementByCssSelector 一起使用会让我的生活轻松很多,但是您不能将其与 NATIVE_APP 上下文一起使用。

[debug] [MJSONWP] Calling AppiumDriver.findElement() with args: ["css selector", "button[ng-click='something']","0ab74e91-afc4-4f90-8702-f2be13f235c5"]
[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator

所以我需要将上下文切换到 WEBVIEW 才能使用 css 选择器。该应用程序是使用 WebView.setWebContentsDebuggingEnabled(true) 构建的。我已经验证了可用的上下文如下:

ReadOnlyCollection<string> contexts = device.Contexts;

上下文是 NATIVE_APPWEBVIEW_com.blah.myapp。我因此切换到 webview:

device.Context = "WEBVIEW_com.blah.myapp";

设置正常,但 Chromedriver 最终失败并显示 chrome not reachable。这是日志记录信息。对于 chromdriver 错误,我不知道下一步该去哪里。

[debug] [MJSONWP] Responding to client with driver.getContexts() result: ["NATIVE_APP","WEBVIEW_com.blah.myapp"]
[HTTP] <-- GET /wd/hub/session/ad3e9aee-d794-43d9-9896-497846dec4f4/contexts 200 230 ms - 119
[HTTP] --> POST /wd/hub/session/ad3e9aee-d794-43d9-9896-497846dec4f4/context {"name":"WEBVIEW_com.blah.myapp"}
[debug] [MJSONWP] Calling AppiumDriver.setContext() with args: ["WEBVIEW_com.blah.myapp","ad3e9aee-d794-43d9-9896-497846dec4f4"]
[debug] [AndroidDriver] Getting a list of available webviews
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\Users\xxxxx\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","0123456789ABCDEF","shell","cat","/proc/net/unix"]
[debug] [AndroidDriver] Found webviews: ["WEBVIEW_com.blah.myapp"]
[debug] [AndroidDriver] Available contexts: ["NATIVE_APP","WEBVIEW_com.blah.myapp"]
[debug] [AndroidDriver] Connecting to chrome-backed webview context 'WEBVIEW_com.blah.myapp'
[debug] [AndroidDriver] A port was not given, using random port: 8000
[debug] [Chromedriver] Changed state to 'starting'
[Chromedriver] Set chromedriver binary as: C:\Users\xxxxx\AppData\Roaming\npm\node_modules\appium\node_modules\appium-chromedriver\chromedriver\win\chromedriver.exe
[debug] [Chromedriver] Killing any old chromedrivers, running: FOR /F "usebackqtokens=5" %a in (`netstat -nao ^| findstr /R /C:"8000 "`) do (FOR /F "usebackq"%b in (`TASKLIST /FI "PID eq %a" ^| findstr /I chromedriver.exe`) do (IF NOT %b=="" TASKKILL /F /PID %a))
[Chromedriver] No old chromedrivers seemed to exist
[debug] [Chromedriver] Cleaning any old adb forwarded port socket connections
[debug] [ADB] List forwarding ports
[debug] [ADB] Running 'C:\Users\xxxxx\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","0123456789ABCDEF","forward","--list"]
[debug] [ADB] Removing forwarded port socket connection: 12980
[debug] [ADB] Running 'C:\Users\xxxxx\AppData\Local\Android\Sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","0123456789ABCDEF","forward","--remove","tcp:12980"]
[Chromedriver] Spawning chromedriver with: C:\Users\xxxxx\AppData\Roaming\npm\node_modules\appium\node_modules\appium-chromedriver\chromedriver\win\chromedriver.exe --url-base=wd/hub --port=8000 --adb-port=5037 --verbose
[debug] [Chromedriver] Chromedriver version: '2.34.522940'
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8000/wd/hub/status] with no body
[debug] [JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"\",\"status\":0,\"value\":{\"build\":{\"version\":\"alpha\"},\"os\":{\"arch\":\"x86_64\",\"name\":\"Windows NT\",\"version\":\"6.1.7601 SP1\"}}}"
[debug] [JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8000/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.blah.myapp","androidUseRunningApp":true,"androidDeviceSerial":"0123456789ABCDEF"}}}
[HTTP] <-- POST /wd/hub/session/ad3e9aee-d794-43d9-9896-497846dec4f4/context - - ms - -
[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"bbe4bf5c4a6bdd020f27e07624258589","status":100,"value":{"message":"chrome not reachable\n (Driver info: chromedriver=2.34.522940 (1a76f96f66e3ca7b8e57d503b4dd3bccfba87af1),platform=Windows NT 6.1.7601 SP1 x86_64)"}}
[Chromedriver] Error: Failed to start Chromedriver session: An error occurred (Original error: chrome not reachable (Driver info: chromedriver=2.34.522940 (1a76f96f66e3ca7b8e57d503b4dd3bccfba87af1),platform=Windows NT 6.1.7601 SP1 x86_64))

编辑:使用 Appium 1.7.2-beta5(在以前的版本上有同样的失败)Android 7.0和6.0,真机和模拟器

最佳答案

这是 Appium & Chromedriver 的一个持续问题, 没有针对每种情况的确切解决方案,因此您必须尝试不同的解决方案:

  1. 试用最新的测试版 - 1.8.0-beta 可用:
npm uninstall -g appium && npm install -g appium@beta
  1. 使用这些 instructions 尝试不同版本的 chromedriver :

    • 下载并解压 chromedriver
    • 使用下载的 chromedriver 路径启动 appium 服务器
    appium --chromedriver-executable /path/to/my/chromedriver
    • 运行你的测试,看看它是否有效

您还可以在 this issue 上跟踪进度特定于 1.7.2-beta 和 Android 6。

关于android - 无法将上下文设置为 WEBVIEW,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48310994/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com