Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Robot框架脚本和chromedriver在Android设备中打开Chrome浏览器?_Android_Robotframework_Selenium Chromedriver - Fatal编程技术网

使用Robot框架脚本和chromedriver在Android设备中打开Chrome浏览器?

使用Robot框架脚本和chromedriver在Android设备中打开Chrome浏览器?,android,robotframework,selenium-chromedriver,Android,Robotframework,Selenium Chromedriver,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上正确启动 from selenium import

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上正确启动

    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框架脚本时,实际问题就存在了。 我试过几种方法,但它总是在桌面Chrome浏览器上打开URL,而不是在手机(Nexus平板电脑)上

下面的RF脚本是我的最新尝试。 我认为这个问题在某种程度上与期望的_功能有关,但我还没有找到正确的定义方法

*** 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}

有人有同样的问题吗?我做错了什么?

所需的功能参数是。 在解决此问题之前,您可以使用更灵活的
Create Webdriver
关键字,而不是
openbrowser
。我不知道这是否是在Android上启动Chrome的最佳方式,但这里是您Python代码的直接翻译:

${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

非常感谢。现在它可以工作了,Chrome浏览器是在设备中打开的,而不是在桌面上。你不会相信我花了多少时间试图解决这个问题…你知道,我不确定上述是必要的。您是否尝试添加远程url=
http://localhost:9515
要打开浏览器吗?我认为唯一的区别是“browserName”:“chrome”、“platform”:“ANY”和“javascriptEnabled”的附加功能:True。