机器人世界的新手。我编写了一个ppython程序,使用pandas比较CSV文件的三个逗号的值。到目前为止,一切都很好。该程序成功运行。但是,我需要使用机器人框架来创建测试用例并将结果显示为通过或失败。下面是python程序:
import pandas as pd
# Reading the CSV file
df = pd.read_csv(r'xl1.csv', skipinitialspace=True, sep=',')
# Summation pf the two columns and giving results
sum1 = df['Gross_Salary'].sum()
sum2 = df['Deduction'].sum()
diff = sum1 - sum2
if diff == df['Net_Salary'].sum():
print("Pass")
else:
print("Fail")
上面的代码正在读取CSV文件,并添加两列,然后将该值与第三列进行比较。如果它们匹配,则“通过”,否则“失败”
Gross_Salary Deduction Net_Salary
100 20 80
2000 200 1500
300 0 300
下面是机器人代码:
*** Settings ***
Library SeleniumLibrary
Library Process
Library BuiltIn
*** Test Cases ***
PandaTest
${result}= run process python <path_to_xl_parse.py>
BuiltIn.Should Be Equal As Strings ${result.rc} PASS
我遇到错误:
PandaTest | FAIL |
2 != PASS
------------------------------------------------------------------------------
Pan | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
请帮助,谢谢
“通过”不等于“通过”。您应该在两个代码中使用相同的字符串。
并使用
Log ${result}
首先查看脚本的内容。搜索错误时,打印值始终是一个好主意。