首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >driver.getContexts中缺少WEBVIEW上下文

driver.getContexts中缺少WEBVIEW上下文
EN

Stack Overflow用户
提问于 2021-05-16 21:08:38
回答 1查看 251关注 0票数 0

我有一个关于webdriver.io的问题,我正在使用一个react原生应用,.apk,webdriver/5.23.0 appium_version - 1.17.0

该应用程序之间有一个网页视图,以获取用户的信息。

问题是,我无法将WEBVIEW作为可用上下文之一获取,因此我无法导航到该webview,并在该webview中导航元素

当我在真实设备上的浏览器堆栈应用程序中手动尝试三星21上的apk时,我能够在inspect中看到webview,并且能够在inspect中查看元素。但是当我使用webdriver代码浏览相同的apk时,它找不到webview上下文。

任何帮助将非常感谢,我可以缩放和显示你的问题,如果你想看。

代码语言:javascript
运行
复制
code 
contexts = await browser.getContexts();
console.log('************ STEP 2 ************', JSON.stringify(contexts));
await browser.switchContext(contexts[0]);
const continue = await $("//*[@text='Continue']");
await continue.waitForDisplayed({
  timeout: 10000
});
await continue.click()

logs驱动程序日志

代码语言:javascript
运行
复制
2021-05-16T12:46:04.785Z INFO webdriver: [POST] https://hub-cloud.browserstack.com:443/wd/hub/session/b3cf72fbf8fdfb1db61055a650d0fbe627fa19b3/element/00810e16-1198-49b2-8c4c-5b4bcee09864/click
[0-0] 2021-05-16T12:46:09.905Z INFO webdriver: COMMAND getContexts()
[0-0] 2021-05-16T12:46:09.906Z INFO webdriver: [GET] https://hub-cloud.browserstack.com:443/wd/hub/session/b3cf72fbf8fdfb1db61055a650d0fbe627fa19b3/contexts
[0-0] 2021-05-16T12:46:10.014Z INFO webdriver: RESULT [ 'NATIVE_APP' ]
[0-0] ************ STEP 2 ************ ["NATIVE_APP"]
2021-05-16T12:46:10.017Z INFO webdriver: COMMAND switchContext("NATIVE_APP")
2021-05-16T12:46:10.018Z INFO webdriver: [POST] https://hub-cloud.browserstack.com:443/wd/hub/session/b3cf72fbf8fdfb1db61055a650d0fbe627fa19b3/context
2021-05-16T12:46:10.019Z INFO webdriver: DATA { name: 'NATIVE_APP' }

appium日志

代码语言:javascript
运行
复制
2021-05-16 12:46:08:332 - [HTTP] --> GET /wd/hub/session/91dd11eb-0bb0-4197-b404-9c1174bca8aa/contexts
2021-05-16 12:46:08:332 - [HTTP] {}
2021-05-16 12:46:08:334 - [debug] [MJSONWP (91dd11eb)] Calling AppiumDriver.getContexts() with args: ["91dd11eb-0bb0-4197-b404-9c1174bca8aa"]
2021-05-16 12:46:08:334 - [debug] [AndroidDriver] Getting a list of available webviews
2021-05-16 12:46:08:335 - [debug] [ADB] Running '/usr/local/.browserstack/android-sdk/platform-tools/adb -P 5037 -s RFCR204K71P shell cat /proc/net/unix'
2021-05-16 12:46:08:371 - [AndroidDriver] Retrieved potential webviews; will filter out ones with no active pages
2021-05-16 12:46:08:372 - [debug] [AndroidDriver] Found webviews: []
2021-05-16 12:46:08:373 - [debug] [AndroidDriver] Available contexts: ["NATIVE_APP"]
2021-05-16 12:46:08:373 - [debug] [MJSONWP (91dd11eb)] Responding to client with driver.getContexts() result: ["NATIVE_APP"]
2021-05-16 12:46:08:374 - [HTTP] <-- GET /wd/hub/session/91dd11eb-0bb0-4197-b404-9c1174bca8aa/contexts 200 42 ms - 86
2021-05-16 12:46:08:374 - [HTTP] 
2021-05-16 12:46:08:515 - [HTTP] --> POST /wd/hub/session/91dd11eb-0bb0-4197-b404-9c1174bca8aa/context
2021-05-16 12:46:08:515 - [HTTP] {"name":"NATIVE_APP"}
2021-05-16 12:46:08:516 - [debug] [MJSONWP (91dd11eb)] Calling AppiumDriver.setContext() with args: ["NATIVE_APP","91dd11eb-0bb0-4197-b404-9c1174bca8aa"]
2021-05-16 12:46:08:516 - [debug] [MJSONWP (91dd11eb)] Responding to client with driver.setContext() result: null
2021-05-16 12:46:08:517 - [HTTP] <-- POST /wd/hub/session/91dd11eb-0bb0-4197-b404-9c1174bca8aa/context 200 2 ms - 76
2021-05-16 12:46:08:517 - [HTTP] 
2021-05-16 12:46:08:568 - [HTTP] --> POST /wd/hub/session/91dd11eb-0bb0-4197-b404-9c1174bca8aa/element
2021-05-16 12:46:08:568 - [HTTP] {"using":"xpath","value":"//*[@text='Continue']"}
2021-05-16 12:46:08:570 - [debug] [MJSONWP (91dd11eb)] Calling AppiumDriver.findElement() with args: ["xpath","//*[@text='Continue']","91dd11eb-0bb0-4197-b404-9c1174bca8aa"]
2021-05-16 12:46:08:570 - [debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
2021-05-16 12:46:08:570 - [debug] [BaseDriver] Waiting up to 0 ms for condition
2021-05-16 12:46:08:570 - [debug] [WD Proxy] Matched '/element' to command name 'findElement'
2021-05-16 12:46:08:571 - [debug] [WD Proxy] Proxying [POST /element] to [POST http://127.0.0.1:8206/wd/hub/session/9b39fbd2-a3fc-4917-8f43-d7cf35514abc/element] with body: {"strategy":"xpath","selector":"//*[@text='Continue']","context":"","multiple":false}
2021-05-16 12:46:08:613 - [WD Proxy] Got response with status 404: {"sessionId":"9b39fbd2-a3fc-4917-8f43-d7cf35514abc","value":{"error":"no such element","message":"An element could not be located on the page using the given search parameters","stacktrace":"io.appium.uiautomator2.common.exceptions.ElementNotFoundException: An element could not be located on the page using the given search parameters\n\tat io.appium.uiautomator2.handler.FindElement.findElement(FindElement.java:102)\n\tat io.appium.uiautomator2.handler.FindElement.safeHandle(FindElement.java:72)\n\tat io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:38)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:252)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:242)\n\tat io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:51)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)\n\tat io.netty.channel.AbstractChannelHandlerCon...
2021-05-16 12:46:08:613 - [debug] [W3C] Matched W3C error code 'no such element' to NoSuchElementError
2021-05-16 12:46:08:614 - [debug] [MJSONWP (91dd11eb)] Encountered internal error running command: NoSuchElementError: An element could not be located on the page using the given search parameters.
2021-05-16 12:46:08:614 - [debug] [MJSONWP (91dd11eb)]     at AndroidUiautomator2Driver.findElOrEls (/nix/store/afabwd5rpmw8z0c4a61ssiq2g0622b6q-appium-1.17.0/node_modules/appium-uiautomator2-driver/node_modules/appium-android-driver/lib/commands/find.js:75:11)
2021-05-16 12:46:08:615 - [HTTP] <-- POST /wd/hub/session/91dd11eb-0bb0-4197-b404-9c1174bca8aa/element 500 46 ms - 164
2021-05-16 12:46:08:615 - [HTTP] 

我能在web上找到的最接近的问题在https://github.com/appium/appium/issues/6973下面

EN

回答 1

Stack Overflow用户

发布于 2021-05-17 11:09:48

作为调试措施,您是否可以运行下面提到的appium版本的测试( caps.setCapability("browserstack.appium_version","1.20.2");如果在更新后观察到相同的行为或写入support@browserstack.com

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67557045

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档