简体   繁体   中英

How to store the result of a python function in robot framework and display it in Reports?

I am testing an app that uses Bluetooth, I have a python function that connects it to a server and displays some strings. I want to store that strings in variable and compare it with it other strings.

I have stored the results in the result variable but can use it compare the strings

*** Settings ***
Library         AppiumLibrary     run_on_failure=Capture Page Screenshot
Library         String
Library         bt.py
*** Variable ***
${appium_1}=     http://0.0.0.0:4723/wd/hub
${platform_name}=    android
${platformVersion}=         9
${deviceName}=          b6722e70
${app}=      /home/user/Downloads/pre-prod.apk
${result}
*** Test Cases ***
App_Test_1
[Documentation]    Test Case to Login
Open Application        ${appium_1}     
platformName=${platform_name}       deviceName=${deviceName}        
app=${app}     
Capture Page Screenshot
Click Element   id=com.vendekin:id/intro_btn_skip
Sleep   4
Wait Until Element Is Visible   id=com.vendekin:id/phone
input text      id=com.vendekin:id/phone    
Click Element   id=com.vendekin:id/login
Sleep   5
Wait Until Element Is Visible   id=com.vendekin:id/otp  
Click Element   id=com.vendekin:id/otp
sleep  15
Wait Until Element Is Visible   id=com.vendekin:id/login
Click Element   id=com.vendekin:id/login
Sleep   6
Input Text  id=com.vendekin:id/promocode    010331
sleep   2
click element   id=com.vendekin:id/add
${result}=           connect     29476601-52BE-11CB-8642-D50A896F8D2A
log  ${result}
capture page screenshot
quit application

I expected that the output of the function would be stored in the result as a string to compare but it shows "None"

For a variable to get the return value of a function, that function must return it in the first place. Getting a None means your function doesn't (or returns a literal None :).

So connect must be something like this:

def connect(data):
    output = does_its_magic(data)
    return output

如果在不使用机械手框架的情况下在本地执行功能,则返回的功能是什么?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM