I'm using Appium to test my website on Chrome for Android. I would like to add some options to Chrome for Android such as the incognito mode and the possibility to disable the cache. I tried with the following sample code but it doesn't work properly. Appium is able to open Chrome on my Android device, but it isn't in incognito mode and hence it doesn't disable the browser's cache.
Here there is the code snippet of my Python script:
import appium
from time import sleep
desired_caps = {
'platformName' : 'Android',
'platformVersion' : '7.1.1',
'deviceName' : 'ZX1G423BZQ',
'browserName' : 'Chrome',
'chromeOptions': {'args':['--incognito', '--disable-cache']}
}
driver = appium.webdriver.Remote("http://127.0.0.1:4723/wd/hub", desired_caps)
driver.get("http://www.google.com")
timings = driver.execute_script('return performance.timing')
print(timings)
driver.quit();
My environment is as follow:
- Mac OS X 10.12
- Android 7.1.1
- Appium 1.6.4 (the dmg package)
- Python 3.6 and the Python wrapper to Appium
- Chrome v. 61.0.3163.98
I'm not sure what my mistake is here. Maybe, I'm not using the chromeOptions argument properly, but I didn't find the right way to exploit it.
The capabilities to set incognito/Private mode are not supported for mobile device driver instances in Appium Selenium
来源:https://stackoverflow.com/questions/46568714/open-chrome-in-incognito-mode-on-real-android-device-using-appium