【问题标题】:how to resolve urlopen error in robotframework?如何解决机器人框架中的 urlopen 错误?
【发布时间】:2018-11-20 09:27:46
【问题描述】:

代码 下面是计算器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 错误未知 url 类型:= http

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

【问题讨论】:

    标签: robotframework appium-android


    【解决方案1】:

    缺少 AppiumServer URL 上的端口,来自示例:

    http://localhost:4723/wd/hub

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

    http://127.0.0.1:443/wd/hub

    【讨论】:

    • 感谢您的 cmets。它无法正常工作。存在同样的错误
    猜你喜欢
    • 1970-01-01
    • 2020-05-04
    • 1970-01-01
    • 1970-01-01
    • 2019-07-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-23
    相关资源
    最近更新 更多