【问题标题】:Open chrome browser in android, using robotframework在android中打开chrome浏览器,使用robotframework
【发布时间】:2017-02-19 20:47:24
【问题描述】:

我尝试在我的 android 中打开 chrome 浏览器,使用带有此脚本的机器人框架

*** Settings ***
Documentation     A resource for global
Library           Selenium2Library      timeout=15


*** Variable ***
${COMMAND_EXECUTOR}   http://localhost:4723/wd/hub
${BROWSER}            Chrome
${PLATFORM_NAME}      Android
${UDID}               FF786D96CB71039D

*** Test Case ***
Test Case Open Chrome In Real Device
  Open Android Browser        https://www.google.co.id

*** Keywords ***
Open Android Browser
  [Documentation]     To open android default browser (not chrome) and go to provided URL
  [Arguments]         ${url}
  ${capabilities}=    Create Dictionary   browserName=${BROWSER}    platformName=${PLATFORM_NAME} udid=${UDID}   deviceName=${PLATFORM_NAME}
  Create Webdriver    Remote  command_executor=${COMMAND_EXECUTOR}    desired_capabilities=${capabilities}
  Go To               ${url}

问题是当我尝试运行它时,得到一个错误

==============================================================================
Testcase 2 :: A resource for global
==============================================================================
[ WARN ] Keyword 'Capture Page Screenshot' could not be run on failure: No browser is open
Test Case Open Chrome In Real Device                                  | FAIL |
URLError: <urlopen error [Errno 10061] No connection could be made because the target machine actively refused it>
------------------------------------------------------------------------------
Testcase 2 :: A resource for global                                   | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
==============================================================================

我尝试来自Opening Chrome browser in Android device using Robot Framework script and chromedriver? 的实现,
但还是失败了。在我运行这个测试之前,我的 andorid 中是否有任何设置?必须创建一个测试服务器还是什么?感谢您的帮助

【问题讨论】:

  • 你使用的是 Appium 还是 Selenium Grid?
  • 我正在使用使用 selenium 的机器人框架。
  • 您需要有一个服务器来与您的设备通信(我需要设置 Android 和 iOS 测试,我正在考虑使用 Appium)。见appium.io设置Appium然后设置jollychang.github.io/robotframework-appiumlibrary但是用这个方案控制Android的浏览器可能并不容易,因为我们将使用两个Webdriver服务器。

标签: android robotframework selenium2library


【解决方案1】:

*** 设置 *** 图书馆 SeleniumLibrary 图书馆馆藏

*** 变量 ***

*** 测试用例 *** 安卓连接 #${COptions}= 评估 sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver ${Options} 创建字典 androidPackage com.android.chrome #${prefs} 创建字典 profile.default_content_setting_values.geolocation=1 #${v} 创建字典首选项 ${prefs}

#${kwag}  Create Dictionary     chromeOptions=${COptions}
${caps}    Create Dictionary    chromeOptions    ${Options}
#Set to Dictionary    ${caps}   add_experimental_option    ${v}
Set to Dictionary    ${caps}    platformName    Android
Set to Dictionary    ${caps}    platformVersion    9.0
Set To Dictionary    ${caps}    deviceName    emulator-5554
Set To Dictionary    ${caps}    browserName    Chrome
Set To Dictionary    ${caps}   autoGrantPermissions     true
 Set To Dictionary    ${caps}     autoAcceptAlerts   true
#set to dictionary    ${caps}    chromeOptions   ${kwag}
Create Webdriver    Remote    command_executor=http://localhost:4723/wd/hub     desired_capabilities=${caps}
go to   https://the-internet.herokuapp.com/geolocation
#appium --allow-insecure chromedriver_autodownload

【讨论】:

    猜你喜欢
    • 2019-04-12
    • 2013-08-17
    • 2020-09-01
    • 2020-02-06
    • 2014-04-22
    • 2016-03-01
    • 2014-08-06
    • 2017-01-13
    • 1970-01-01
    相关资源
    最近更新 更多