如何解决机器人框架中的urlopen错误?

时间:2018-06-11 07:30:59

标签: robotframework appium-android

代码     下面用于计算机android程序测试的示例代码使用了robotframework AppiumLibrary

*** Settings ***
Library           AppiumLibrary     run_on_failure=Log Source
#Library           Selenium2Library
#Library           OperatingSystem

#Setup    Open    Calculator
#Teardown    Close    Application

*** Variables ***
${DEV.APPIUM_SERVER}    =   https://127.0.0.1/wd/hub
${DEV.PLATFORM_VERSION}     =   7.0.1
${DEV.PLATFORM_NAME}    =   Android
${DEV.DEVICE_NAME}  =   device1 
${DEV.PACKAGE_NAME} =   com.google.android.calculator
${DEV.ACTIVITY_NAME}    =   com.android.calculator2.Calculator

#Elements locators for various
${EQUALS_SIGN}  =   xpath=//*[contains(@text,'=')]
${DISPLAYED_RESULT} =   xpath=//*[contains(@resource-id,'id/result')]


${td_Digit1}    =   5
${td_Digit2}    =   2
${td_Expcted_Addition_Result}   =   7
${td_Expected_Subtraction_Result}   =   3

*** Keywords ***    
Open Calculator App
    Open Application    ${DEV.APPIUM_SERVER}    platformName=${DEV.PLATFORM_NAME}   platformVersion=${DEV.PLATFORM_VERSION}     deviceName=${DEV.DEVICE_NAME}   appPackage=${DEV.PACKAGE_NAME}      appActivity=${DEV.ACTIVITY_NAME}


Enter Digits And Operator
    [Arguments]     ${digit1}   ${digit2}   ${operator}
    Click Element    xpath=//*[contains(@test,'${digit1}')]
    Click Element    xpath=//*[contains(@text,'${operator}')]
    Click Element    xpath=//*[contains(@text,'${digit2}')]

View Result

    Click Elemet    ${EQUALS_SIGN}
Verify Result
    [Arguments]  ${expected_result}
    ${displayed_result} = Get Element Attribute  ${DISPLAYED_RESULT}  text
    Should Be Equal  ${displayed_result}  ${expcted_result}

*** Test Cases ***
Test Case 1: Addition
    Open Calculator App
    Enter Digits And Operator   ${td_Digit1}    ${td_Digit2}    +
    View Result
    Verify Result

运行以下错误后的代码

测试案例1:添加 URLError:urlopen错误未知网址类型:= http

Appium服务器已在系统中运行。请帮我找错误

1 个答案:

答案 0 :(得分:0)

在示例中缺少AppiumServer URL上的端口:

http://localhost:4723/wd/hub

在你的情况下(如果真的是HTTPS到localhost),也许你可以尝试:

http://127.0.0.1:443/wd/hub