使用Robot Framework脚本和chromedriver在Android设备中打开Chrome浏览器? [英] Opening Chrome browser in Android device using Robot Framework script and chromedriver?
问题描述
在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平板电脑)上打开URL.
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
这篇关于使用Robot Framework脚本和chromedriver在Android设备中打开Chrome浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!