[英]How can I get the current URL or the URL clicked on and save it as a string in python?
[英]Appium + android + python how to get URL that I've just clicked?
我有这样的环境Appium + android Simulator + python。 我必须测试这种情况:
我不能使用常用代码:
driver.current_url()
因为它返回此错误:
Method has not yet been implemented
我不知道如何获得这个 URL。 可能有人在这个问题上有经验吗?
它失败可能是因为您没有切换上下文:在使用应用程序时,您正在使用NATIVE_APP
上下文,但是一旦您打开 WebView,您至少会获得一次额外的上下文
webview = driver.contexts[1]
driver.switch_to.context(webview)
url = self.driver.current_url()
这是一个基本示例,当然您需要检查上下文名称,而不是像我的示例中那样放置 index=1
您可以在此处找到更多示例
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.