問題描述
Ubuntu 14.04 上的自動化設(shè)置:
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 運(yùn)行以下示例測試時一切正常--> URL 在 Nexus 設(shè)備的 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()
但是當(dāng)我嘗試使用 Robot Framework 腳本進(jìn)行相同的工作時,實際問題存在.我已經(jīng)嘗試了幾種方法,但它總是只在桌面 Chrome 瀏覽器上打開 URL——而不是在移動設(shè)備(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 腳本是我最近的嘗試.我認(rèn)為問題在某種程度上與 desired_capabilities 有關(guān),但我只是沒有找到正確的定義方式
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?
推薦答案
所需的功能參數(shù)是 不是為本地網(wǎng)絡(luò)驅(qū)動程序處理.在解決此問題之前,您可以使用更靈活的 Create Webdriver
關(guān)鍵字代替 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
這篇關(guān)于使用機(jī)器人框架腳本和 chromedriver 在 Android 設(shè)備中打開 Chrome 瀏覽器?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!