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

查看:32
本文介绍了使用 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 版本 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天全站免登陆