Appium appium+ios Native 无法切换 WebView(python)

雨过天晴 · 2021年11月03日 · 最后由 XU 回复于 2022年03月14日 · 3694 次阅读

在用 appium 做 iOS 混合 APP 自动化时,碰到了无法获取 webView 上下文的问题,参考社区中http://testerhome.com/topics/10951###的帖子,依然未解决问题, 仍然只能获取到 Native,麻烦大佬们给个指点

iOS 版本 15.1

Appium 版本 1.21.0

Appium 日志:

[info] [35m[HTTP][39m [37m-->[39m [37mGET[39m [37m/wd/hub/session/7654404f-1ba4-48d3-9dd9-ecff0cf9795a/contexts[39m
[info] [35m[HTTP][39m [90m{}[39m
[debug] [35m[W3C (7654404f)][39m Calling AppiumDriver.getContexts() with args: ["7654404f-1ba4-48d3-9dd9-ecff0cf9795a"]
[debug] [35m[XCUITest][39m Executing command 'getContexts'
[debug] [35m[XCUITest][39m Getting list of available contexts
[debug] [35m[iOS][39m Retrieving contexts and views
[debug] [35m[XCUITest][39m Selecting by url: false 
[info] [35m[RemoteDebugger][39m Remote Debugger version 8.13.2
[debug] [35m[RemoteDebugger][39m useNewSafari --> false
[debug] [35m[RemoteDebugger][39m Checking which communication style to use (non-Safari on platform version '15.1')
[debug] [35m[RemoteDebugger][39m Platform version equal or higher than '12.2': true
[warn] [35m[RemoteDebugger][39m Setting communication protocol: using Target-based communication
[debug] [35m[RemoteDebugger][39m Sending connection key request
[debug] [35m[RemoteDebugger][39m Sending '_rpc_reportIdentifier:' message (id: 0): 'setConnectionKey'
[debug] [35m[RemoteDebugger][39m Sending to Web Inspector took 1ms
[debug] [35m[RemoteDebugger][39m Sending connection key request
[debug] [35m[RemoteDebugger][39m Sending '_rpc_reportIdentifier:' message (id: 2): 'setConnectionKey'
[debug] [35m[RemoteDebugger][39m Sending to Web Inspector took 1ms
[debug] [35m[RemoteDebugger][39m Selecting application
[debug] [35m[RemoteDebugger][39m No applications currently connected.
[debug] [35m[XCUITest][39m No web frames found.
[debug] [35m[W3C (7654404f)][39m Responding to client with driver.getContexts() result: ["NATIVE_APP"]
[info] [35m[HTTP][39m [37m<-- GET /wd/hub/session/7654404f-1ba4-48d3-9dd9-ecff0cf9795a/contexts [39m[32m200[39m [90m132 ms - 24[39m
[info] [35m[HTTP][39m [90m[39m
[debug] [35m[RemoteDebugger][39m Received connected automation availability state: "WIRAutomationAvailabilityNotAvailable"
[debug] [35m[RemoteDebugger][39m Received connected applications list: PID:546, PID:540, PID:2855, PID:3621
[debug] [35m[RemoteDebugger][39m Received connected driver list: {}
共收到 7 条回复 时间 点赞

你有用 ios-webkit- debug- proxy 这个工具吗?

尝试输入两次 self.driver.contexts,再次进行 switch_to.context

用开发打 debug 包试一下

我也是参照了 那个文章这么做的 但是好像就是只有一个上下文 没有 WebView

我也遇到了这个问题,请问楼主有解决吗?

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册