[英]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.