webdriverappiumappium-androidremotewebdriverpython-appium

Appium Submit Url


I am using Python and Android Chrome. And my WebDriver is created using WebDriver.Remote(host, caps)

I actually want to use Chrome in incognito mode but it seems not possible according to the question here.

But are there any workaround? For example, can I submit my url to the url bar of Chrome at the top? I have tried driver.find_element_by_id('com.android.chrome:id/url_bar').submit() but it says not implemented.


Solution

  • This is my workaround. Explanations are in the comments.

    # 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()