Executing PyCharm Tests Using Robot Framework

I started using PyCharm with a framework robot

but ran into a problem. How can I run my tests? Every time I right click on my tests folder, I get an Empty Suit message from the console log.

Is there a way to run each test individually, like right-clicking on a test case and clicking the test run button?

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    

      

+7


source to share


5 answers


I used the Intellibot PyCharm Plugin for Robot Framework.

To run the tests, we can do the following configuration:



  • Go to File> Preferences> External Tools
  • Click the + button in the External Tools panel
  • In the New Tool dialog box, enter the following values:
    • Name: Robot
    • Program: [Path to Pybot.bat eg C: \ Python27 \ Scripts \ Pybot.bat]
    • Parameters: $ FileName $
    • Working directory: $ FileDir $
  • Click "OK"

Once the above configuration is done, we will get the Robot option on the test context menu in the IDE. Select this option to run the test suite in PyCharm.

+6


source


The easiest way is to create a launch configuration and then use the launch commands.

Here is an example screenshot - it is called in the Run-> Run Configurations menu, explained below:

Sample RF run config in PyCharm

1) in the screenshot - the location of the RF run.py file - it is located in the Lib \ site-packages \ robot directory in your python installation - or in virtualenv as in the case shown.

2) is the same Python interpreter - make sure it's the same as the one used in 1) (or it might get confused :)

3) are parameters that you usually pass to the robot when running from the command line. The minimum is to specify the path to the kits to be run - the last parameter in the screenshot.



PyCharm does not have the ability to "run this specific test case" by right clicking on it - because the RF depends on this information (in the specific case) to be provided in the CLI.

This case selection can be done in several ways - just look at the Robotframework execution selectors (by tags, by case names, etc.). All these parameters are set in the "Script parameters:" field in the launch configuration; for example, to run tests with the Sanity tag, use --include sanity to run a specific test case - --name "My test case", etc.


By the way, one of the greatest advantages of using run configurations is that you can debug the execution, i.e. use IDE for what works best for it :)

The launch configuration is independent of which plugin is installed, although IntelliBot is a "must" prerequisite for developing cases IMO, as you can see from the steps it has nothing to do with execution / launch.

+3


source


How to run tests via test configuration 1) Add a new Python configuration to the Run / Debug Configurations dialog (Run → Edit Configurations ...) with the following settings Set 'Script to point to the run.py file in the RobotFramework folder. Set 'Script parameters to the list of parameters with which you want to run your tests. (these are the parameters you pass to the pybot command). Set "Working Directory to Working Directory of Test Project

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

2) Run the configuration, which you can run by clicking the run button. And look at the test result in the test output window.

How to run tests with one click (from context menu) What you can do is configure an external tool in Pycharm / IntellijIDEA to do this. 1) Open "File" → "Preferences" (Alt + F7) and find "External tools", click "Add" to add a new configuration, and set the fields and not the following values ​​to the external tool

The duplicated values ​​are here:

C:\Python27\Scripts\pybot.bat
<your variables> --test "$SelectedText$" TestSuite
$ProjectFileDir$

      

Save changes

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

By the way, 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 it a check.

0


source


I followed the steps below. The easiest way is to create a run configuration and then use the Run commands.

Here is an example screenshot - it is called in the Run-> Run Configurations menu, following explanations:

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

0


source


To integrate Robot Framework into PyCharm make sure you are using IntelliBot @SeleniumLibary Patched plugin

go to File - Settings - Plugins - (Search IntelliBot)

0


source







All Articles