0

我尝试在我的android中打开chrome浏览器,使用robotframework和这个脚本

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

我尝试使用 Robot Framework 脚本和 chromedriver 在 Android 设备中打开 Chrome 浏览器中的实现?
但仍然失败。在我运行这个测试之前,我的 andorid 中是否有任何设置?必须创建一个测试服务器还是什么?感谢您的帮助

4

1 回答 1

0

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

*** 变量 ***

*** 测试用例 *** AndroidConnection #${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
于 2021-11-18T10:22:06.910 回答