简体   繁体   English

如何使用 python 比较机器人框架的数据输出

[英]How can i compare data output from robot framework by using python

here's my robot code这是我的机器人代码

Database-Keywords-Test

connect to database using custom params  cx_Oracle    ${DB_CONNECT_STRING}

${queryResults}=   Query  Select * from QA_USER.SealTest_Security_A order by SECURITY_ID
Log  ${queryResults}

${queryResults1}=   Query  Select * from QA_USER.SealTest_Security_B order by SECURITY_ID
Log  ${queryResults1}

The Robot Framework is written in Python, which makes for a number of good entry points. Robot Framework 是用 Python 编写的,它提供了许多很好的切入点。

You have to make a design decision (or determine the design decision already made by your team) around which to use.您必须围绕要使用的设计决策(或确定您的团队已经做出的设计决策)。

Robot native solution机器人原生解决方案

If the results from the two tables in your system are meant to be identical, you might be able to just use a built-in Robot framework keyword directly and not call out to Python at all.如果您系统中两个表的结果是相同的,您也许可以直接使用内置的 Robot 框架关键字,而根本不调用 Python。

*** Settings ***
 Documentation    Exercise database keywords (Robot-only).
 Library          Collections
 Library          # <Database library implied above>

*** Test Cases ***
User Settings Test
    [Documentation]    User details db comparison (Database-Keywords-Test)
   ${queryResultsA}=   Query  Select * from QA_USER.SealTest_Security_A order by SECURITY_ID
   ${queryResultsB}=   Query  Select * from QA_USER.SealTest_Security_B order by SECURITY_ID
    Lists Should Be Equal  ${queryResultsA}  ${queryResultsB}

Robot invoking Python solution机器人调用Python解决方案

If you want Robot to drive Python, ie you invoke robot as the main entry point, you can import Python modules using the Library keyword.如果想让Robot 驱动Python,即调用robot 作为主要入口点,可以使用Library 关键字导入Python 模块。

Robot test case:机器人测试案例:

*** Settings ***
 Documentation    Exercise database keywords (call out to Python).
 Library          userManagement
 Library          # <Database library implied above>

*** Test Cases ***
User Settings Test
    [Documentation]    User details db comparison (Database-Keywords-Test)
   ${queryResultsA}=   Query  Select * from QA_USER.SealTest_Security_A order by SECURITY_ID
   ${queryResultsB}=   Query  Select * from QA_USER.SealTest_Security_B order by SECURITY_ID
    ${diff} = Compare Users  ${userResultsA}  ${userResultsB}
    Should Be Empty  ${diff}

Python library userManagement.py: Python 库 userManagement.py:

class UserManagement:

    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'

    def compareUsers(self,userResultsA,userResultsB):
        # diff implementation depends on the structure of user results
        # which are not shared in the question, but will be related to the 
        # database library you are using, perhaps a list of 
        # rows or dictionaries
        ...
        return diff

http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#creating-test-library-class-or-module http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#creating-test-library-class-or-module

Python invoking Robot solution Python调用Robot解决方案

If you want python to drive Robot, you can access the API from Python https://robot-framework.readthedocs.io/en/latest/如果你想让python驱动Robot,你可以从Python访问API https://robot-framework.readthedocs.io/en/latest/

The above are some directly related stubs that hopefully let you see the mapping and get off the ground.以上是一些直接相关的存根,希望能让您看到映射并开始工作。 Using that starting point, I suggest working through the documentation links carefully for next steps.使用该起点,我建议仔细阅读文档链接以进行后续步骤。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Robot 框架,如何解析 XML 并验证数据? - Using Robot framework, how can I parse XML and verify the data? 如何使用python(机器人框架)将.properties文件中的数据读取到.robot文件中 - how to read data from .properties file into .robot file using python(robot framework) 如何使用python在机器人框架中迭代具有不同值的测试 - How can I iterate tests with different values in robot framework with python 如何在 python 中下载并保存图像机器人框架? - How can I download and save image robot framework in python? 如何使用 Robot Framework 测试 python function? - How do I test a python function using Robot Framework? 如何使用Python从此网页获取输出数据? - How can I get output data from this webpage using Python? 如何使用机器人框架从文件浏览器中选择PC中的文件? - How can I select files from PC in the file explorer using robot framework? 无论如何都可以在没有 .robot/.txt 脚本的情况下运行机器人框架,或者我可以从一些数据生成 .robot/.txt 文件吗? - Is there anyway to run robot framework without a .robot/.txt script, or can I generate .robot/.txt file from some data? 如何将图像与机器人框架进行比较 - How to compare image with robot framework 在python中使用机器人框架 - Using the robot framework in python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM