Ubuntu 14.04 上的自动化设置:
Automation setup on Ubuntu 14.04:
Robot Framework 2.9.2 (Python 2.7.6 on linux2)
selenium2library-1.7.4
ChromeDriver 2.20.353124
Device under testing: Nexus 7 (KitKat 4.4, Chrome v. 47)
使用 Python 运行以下示例测试时一切正常--> URL 在 Nexus 设备的 Chrome 上正确启动.
Everything works fine when running this following example test with Python --> URL is launched properly on Chrome in Nexus device.
from selenium import webdriver
capabilities = {
'chromeOptions': {
'androidPackage': 'com.android.chrome',
}
}
driver = webdriver.Remote('http://localhost:9515', capabilities)
driver.get('http://google.com')
driver.quit()
但是当我尝试使用 Robot Framework 脚本进行相同的工作时,实际问题存在.我已经尝试了几种方法,但它总是只在桌面 Chrome 浏览器上打开 URL——而不是在移动设备(Nexus 平板电脑)中.
But actual problem exists when I try to get the same working with Robot Framework script. I've tried several ways but always it just opens URL on desktop Chrome browser - not in mobile (Nexus tablet) as it should be.
以下 RF 脚本是我最近的尝试.我认为问题在某种程度上与 desired_capabilities 有关,但我只是没有找到正确的定义方式
The following RF script was my latest try. I think problem is related somehow to desired_capabilities but I just haven't find the correct way how it should be defined
*** Settings ***
Library Selenium2Library
*** Variables ***
${chromedriver} http://localhost:9515
${android} = Create List androidPackage com.android.chrome
${desired_capabilities} = Create Dictionary {chromedriver} chromeOptions ${android}
*** Keywords ***
Open Page
Open Browser http://www.google.com
... browser=chrome
... desired_capabilities=${desired_capabilities}
有人遇到同样的问题吗?我做错了什么?
Anyone had same issue? What I'm doing wrong?
所需的功能参数是 不是为本地网络驱动程序处理.在解决此问题之前,您可以使用更灵活的 Create Webdriver
关键字代替 Open Browser
.我不能说这是否是在 Android 上启动 Chrome 的最佳方式,但这里是您的 Python 代码的直接翻译:
The desired capabilities argument is not processed for local webdrivers.
Until that is resolved you can use the more flexible Create Webdriver
keyword instead of Open Browser
. I cannot speak to whether this is the best way to launch Chrome on Android, but here is a direct translation of your Python code:
${options}= Create Dictionary androidPackage=com.android.chrome
${caps}= Create Dictionary chromeOptions=${options}
Create Webdriver Remote command_executor=http://localhost:9515 desired_capabilities=${caps}
Go To http://google.com
Close Browser
这篇关于使用机器人框架脚本和 chromedriver 在 Android 设备中打开 Chrome 浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!