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)
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()
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.
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?
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
来源:https://stackoverflow.com/questions/34507901/opening-chrome-browser-in-android-device-using-robot-framework-script-and-chrome