• Running tests on PyCharm using Robot Framework


    问题:

    I started using PyCharm with the robot framework, but i'm facing an issue. how can i run my tests ? All the time i right click on my tests folder, i get an Empty test suit message from the console log.

    Is there anyway to run each test separatly like right click on the test case and hit the test runner ?

    This is my code:

    *** Settings ***
    Library     Selenium2Library
    Resource    /steps/keywords.txt
    
    *** Variables ***
    ${URL}         http://www.google.com
    
    *** Keywords ***
    Open browser with URL
        [arguments]     ${url}
        Open Browser    ${url}  browser=gc
    
    Set input on text box
        [arguments]     ${xpath}    ${text}
        Input text      ${xpath}    ${text}
    
    Push button
        [arguments]     ${button}
        Click Button    ${button}
    
    *** Test Cases ***
    Google Access
        Open browser with URL   ${URL}
        Set input on text box   //*[@id="gbqfq"]    Critical Software
        Push button             //*[@id="gbqfba"]
    
        #Close Browser    

    回答1:

    I have used the Intellibot PyCharm plugin for Robot Framework.

    For running the tests, we can do the below configuration:

    1. Go to File > Settings > External Tools
    2. Click '+' button under 'External Tools' panel
    3. In the 'Create Tool' dialog, enter the below values:
      • Name: Robot
      • Program: [Path of Pybot.bat e.g.C:Python27ScriptsPybot.bat]
      • Parameters: $FileName$
      • Working Directory: $FileDir$
    4. Click OK

    Once the above configuration is done, we get the option 'Robot' in the context menu on the test in the IDE. Choose that option to run your test suite in PyCharm.



    回答2:

    The most straightforward way is to create a run configuration, and then using the Run commands.

    Here's a sample screenshot - it's invoked in the menu Run->Run Configurations, explanations follows:

    Sample RF run config in PyCharm

    1) in the screenshot is the location of the RF run.py file - it is located in the directory Libsite-packages obot in your python install - or virtualenv as in the shown case.

    2) is the very same python interpreter - make sure it's the same as the one used in 1) (or it may get messy :)

    3) are the parameters you'd normally pass on to robot when running it from the command line. The bare minimum is to provide the path to the suite(s) that must be ran - the last parameter in the example screenshot.

    PyCharm doesn't have the option to "run this specific test case" by right-clicking on it - because RF depends this information to be provided on the CLI.
    This can be done in a number of ways - all involving setting it in the "Script parameters:" box in the run config; for example, to run tests having a tag Sanity, use --include sanity, to run a specific test case - --name "My test case", and so on.

    By the way, one of the greatest benefits of using run configuraitons is that you can debug the execution - i.e. using an IDE for what it's best suited :)

    A run configuration does not depend on any plugin being installed - IntelliBot is an "absolute must" developing the cases, but as can be seen from the steps, it had no time for the execution.



    回答3:

    How to run tests through test configuration 1) Add a new Python configuration in ‘Run/Debug Configurations’ dialogue (Run -> Edit Configurations…) with next settings Set ‘Script’ to point to the run.py file in RobotFramework folder. Set ‘Script parameter’s to the list of parameters you want to execute your tests with. (these are the parameters you pass to pybot command). Set ‘Working directory’ to the test project working directory

    Save it and it will create a new configuration for you.

    2) Run configuration that you will be able to run by pressing run button. And see the test output in tests output window.

    How to run tests with one click (from the context menu) What you could do is to setup the external tool in Pycharm/IntellijIDEA to do it. 1) Open File -> Settings (Alt+F7) and search for 'External Tools', click Add to add new configuration and set fields not next values external tool

    Duplicated values here:

    C:Python27Scriptspybot.bat
    <your variables> --test "$SelectedText$" TestSuite
    $ProjectFileDir$

    Save the changes

    2) Run tests by highlighting test case name and running external tool: right click -> External tool -> Individual test

    BTW, you can also debug your tests (python code) from test configs. Hope it helps.

    I have a detailed blog post on how to run tests with Pycharm/IntellijIDEA, feel free to give to it a check.



    回答4:

    I followed the steps mention for The most straightforward way is to create a run configuration, and then using the Run commands.

    Here's a sample screenshot - it's invoked in the menu Run->Run Configurations, explanations follows:

    However I am getting below error. Parsing 'sample.robot' failed: Data source does not exist.

    转载:https://www.e-learn.cn/content/wangluowenzhang/447834

  • 相关阅读:
    UIButton 动态改变文本闪烁问题
    利用GDataXML解析XML文件
    限制键盘只能输入数字
    获得view所在的控制器
    使用Canvas绘制简单的时钟控件
    Spring整合ActiveMq消息队列
    Symmetric Key Encryption DES
    OSPF 高级实验
    OSPF 基础实验
    EIGRP 高级实验
  • 原文地址:https://www.cnblogs.com/keepSmile/p/10337499.html
Copyright © 2020-2023  润新知