使用Appium在真实的Android设备上以隐身模式打开Chrome [英] Open Chrome in incognito mode on real Android Device using Appium

查看:310
本文介绍了使用Appium在真实的Android设备上以隐身模式打开Chrome的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Appium在Android版Chrome上测试我的网站. 我想为Android版Chrome添加一些选项,例如隐身模式和禁用缓存的功能.我尝试使用以下示例代码,但无法正常工作. Appium可以在我的Android设备上打开Chrome,但是它不处于隐身模式,因此不会禁用浏览器的缓存.

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.

这是我的Python脚本的代码段:

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

我的环境如下:

  • Mac OS X 10.12
  • Android 7.1.1
  • Appium 1.6.4(dmg软件包)
  • Python 3.6和Appium的Python包装器
  • Chrome v.61.0.3163.98

我不确定我的错误在这里.也许,我没有正确使用chromeOptions参数,但是我没有找到正确的方法来利用它.

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.

推荐答案

Appium Selenium中的移动设备驱动程序实例不支持设置隐身/私人模式的功能

The capabilities to set incognito/Private mode are not supported for mobile device driver instances in Appium Selenium

这篇关于使用Appium在真实的Android设备上以隐身模式打开Chrome的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆