首页 > 解决方案 > Appium提交网址

问题描述

我正在使用 Python 和 Android Chrome。我WebDriver是使用创建的WebDriver.Remote(host, caps)

我实际上想在隐身模式下使用 Chrome,但根据这里的问题似乎不可能。

但是有什么解决方法吗?例如,我可以将我的 url 提交到 Chrome 顶部的 url 栏吗?我试过driver.find_element_by_id('com.android.chrome:id/url_bar').submit()了,但它说没有实现。

标签: webdriverappiumappium-androidremotewebdriverpython-appium

解决方案


这是我的解决方法。解释在评论中。

# Open Menu/More Button
d.find_element_by_id('com.android.chrome:id/menu_button').click()

# Click On Incognito Mode
d.find_element_by_xpath('/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.ListView/android.widget.LinearLayout[3]').click()

# Find Url Bar on the top
url_bar = d.find_element_by_id('com.android.chrome:id/url_bar')

# Click on it which gives you another view.
url_bar.click()

# Set url and this gives you a list of options
url_bar.set_text('https://a.lianwifi.com/app_h5/jisu/wifiapk/sms.html?c=uvtest&type=1')

# Click the first one. This is the one that leads you to the page with your url.
d.find_element_by_xpath('/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.widget.ListView/android.view.ViewGroup[1]/android.view.ViewGroup').click()

推荐阅读