The ride is a testing editor for the robot framework. Going further, we will write test cases in the ride. To open the Ride editor, we have run the below command
In this section, we are going to discuss the Options and Features which are available in the Ride editor IDE. These Options and Features will help us to test our projects.
Go to File and click on the New project as shown in the below image
Once you click on the New Project, the following dialog box will appear
Enter the name of the project, and the created path is the path where the file is getting saved. If required, you can change the location of the file. The project can be saved either Folder or a Directory.
We can also save the project file like ROBOT, TXT, TSV, or HTML.
I am creating a Directory by the name called Demo in my framework directory
The Name of the project has shown on the left side, and on the right side, we can see the three tabs Edit, Text edit, and Run.
The Edit has a lot of options on UI as shown in the below image, in this section we can add data required to run our test cases and also we can import the Library, Resources, and Variables and also we can add scalar, List and Dict.
The details added in the Edit tab can be seen in the Text Edit tab, we can also write the code here.
If there is any change added in the Text edit, it will be seen in the edit section, and hence, both Edit and Text edit are dependent on each other and any changes done will be seen on both.
Once the test cases are ready, we can use the third Tab
The Run UI is as shown above, and it will come with options like Start, Stop, Pause, Debug, Continue, and Next, step over. You can also create a Report, Log for the test cases.
I have successfully created the new project Demo if you right-click on the Demo, you will get different options, To create Test cases, first, we have to create New Suite.
Create a New Suite, Demo1 and click
Right-click on the demo1 test suite and select the New Test Case
The New Test Case will appear as shown below, I am creating the new test case by the name First Test Case and click on ok.
Once the test case is saved, the test case page will appear as shown below
The Test case has options like Documentation, Setup, Teardown, Tags, Timeout, and Template. There is an Edit button across each option, by clicking on it, a screen will appear, wherein you can enter the details for each option.
Documentation : The documentation is used to add the details about the test cases, which may help for future references.
Setup and Teardown : If there is a setup assigned to the test case, this will execute before the test case execution and the test setup that will be executed after the test case is done for teardown.
Tags : The tags are used for tagging the test cases; this can be used to include or exclude specific test cases. We can also specify the critical test cases over here.
Timeout: This can be used to set a timeout on the test cases.
Template: The Template has the keywords to be used for the test cases; it is mostly used for the data-driven test case. The high-level user-defined keywords are specified in the template, and test cases are used to pass data to the keyword.
The Robot framework test cases are keyword-based, and we can write the test cases by using the built-in keywords or by importing from the library. We can also create user-defined keywords, variables, etc.
The Search keyword option can be used to search keywords
To get the list of all the keywords which are available, enter
Ctrl+Alt+SpaceIn the tabular column, you will get the possible keywords.
The following example demonstrates creating a simple test case
First, open the command prompt and then type below command to open the Ride editor
python.exe -c "from robotide import main; main()"
And the next step is to create a new directory, I have already created a test case by the name
first test case, now open the test case and enter the test case.
Search for the should be equal keyword by pressing
Ctrl+Alt+Space button simultaneously
And pass the two integer values
4 and 4in the next column
Whenever we write the test case in the script format, the same thing will be reflected in the text editor as well.
Run button and select the First Test Case, on the left side corner and then click on the
As soon as you press the
start button, the editor will ask to save the changes and run the test cases, press
The output of the test case will be displayed as shown below
You can see that the above test case, 1 passed and 0 failed, and the robot framework also provides the detailed log and the detailed report
Just click on the log option on the top of the UI
The complete log report is as shown below
If you click on the
+ Suite demo1 option in the below, you will see the complete details of the demo1
In the same way, if you click on the
+ Test, you will see the details of the First Test Case
The Robot framework also provides which keyword we have used in the test case.
Consider another test case which contains wrong arguments for
should be equal keyword
If we run the above test case, if the test case is wrong, then the output is highlighted and showed as one failed.
And if you open the log report
And the Test Execution log is, therefore, when the test case fails, then the log color will be changed to red.
Library: The test library provides the actual testing capabilities to the robot framework by providing the keywords. There are several standard libraries that are bundled with the framework, they are Internal library and External library.
The libraries are mainly used externally in test data, but they can also be used in custom test libraries if there is a need. Especially the built-in library is often useful when there is a need to interact with the framework.
We can import the external libraries such as Selenium Library, Excel library, and Database library into the robot framework either by
To install the selenium library into the robot framework Navigate to the link SeleniumLibrary
The GitHub page will open, click on the
clone/download and then select the download the Zip.
Once you click on
Download Zip and select the path to save the selenium master file
Once the file completes it's downloading, go to the file location and extract the file from the Zip format. Open the extracted file, and you can see the selenium setup file.
Open the Python file location and then save the extracted selenium library-master file inside the
python 37 folders.
Now, right-click on the
link path and copy the address of the setup file
Now, open the command prompt and directed to the setup folder and then, pass the command as
Now you have successfully installed selenium library
Now open the Ride editor through command prompt and open the project and click on the Library which is present at the right corner, the library page will open, now add the name of the library as SeleniumLibrary and click on ok.
If the library is installed successfully, it will be displayed on the page as shown below
While importing the library, if you made any spelling mistake also, the file will be displayed in red color only.
We have successfully installed Selenium library, by using the selenium library let us create a web-based test case:
The steps to create a web-based test case is as follow :
First, open the Ride editor, and then right-click on the project and select the New Suite
Create a new test suite as WebAutomation and click on ok
Right-click on Web Automation and create a new test case as OpenBrowser and click on the Ok button.
Open the WebAutomation and import the selenium library in that
We have successfully imported Selenium Library into Web Automation. Open test case and check for the keyword open browser, it will show you the necessary things to create an open browser such as URL and then the Browser.
If you scroll down, the keyword show you what kind of browsers it will support for
Now, pass the arguments as
www.google.com and the browser like
Select the test case and click on the Run button and then click on the Start, we will get an error while executing the test case.
Open the log report and then open the test page, you will find the error message as
Message: WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
Copy the link address and paste in the browser, the chrome driver page will open
Click on the downloads, and there you will get all the versions of chrome, before downloading, first check which version of chrome you are using.
For that right-click on the three dots(:) on the right upper corner of the windows and then select the help and then click on about google chrome
Currently, I am using 77.0 version
Go back to the chrome driver download page, and it says that if you are using the google 77 version then download the ChromeDriver 77.0.3865.40
Click on the link and download, and the index page will open, select the win32
Once it completes downloading, extract the file from the zip format and then copy and paste it inside the script file of the python37
Go back to the test case and Run the Web Automation test case; it will successfully open the web browser.
The Next thing is, we have to close the browser, for that, open the test script and select the keyword as the close browser.
Run the test case again.
User-Defined Keywords Using Python in Robot Framework
To install the Excel Library, copy the given link pip install robotframework-excellibrary and paste it into the command prompt.
But when I run the above command in the command prompt, I got the following error
ERROR: Command errored out with exit status 1: command: 'c:usersuserappdatalocalprogramspythonpython37python.exe' -c 'import sys, setuptools, tokenize; sys.argv = '"'"'C:UsersUserAppDataLocalTemppip-install-nhlb8x5h obotframework-excellibrarysetup.py'"'"'; __file__='"'"'C:UsersUserAppDataLocalTemppip-install-nhlb8x5h obotframework-excellibrarysetup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"' '"'"', '"'"' '"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:UsersUserAppDataLocalTemppip-install-nhlb8x5h obotframework-excellibrarypip-egg-info' cwd: C:UsersUserAppDataLocalTemppip-install-nhlb8x5h obotframework-excellibrary Complete output (5 lines): Traceback (most recent call last): File "<string>", line 1, in <module> File "C:UsersUserAppDataLocalTemppip-install-nhlb8x5h obotframework-excellibrarysetup.py", line 23, in <module> execfile(join(dirname(__file__), 'ExcelLibrary', 'version.py')) NameError: name 'execfile' is not defined ---------------------------------------- ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
To install the excellibrary through GitHub, navigate to the given link https://github.com/NaviNet/robotframework-excellibrary
Click on Clone/Download and then click on Downloadzip
Save the Zip file inside the python37 folder
Now, extract the zip file inside the python folder only
Now, open the excel library folder, you will see the setup file, right-click on the link, and open the command prompt.
Now, open the Ride editor and right-click on the project and then select the new resource
Once the resource has been created successfully, then it will be displayed on the left side corner.
Now, right-click on the Resource and create a scalar variable and give the value as 10
Create another one scalar variable as cmp2 and pass the value as ten only.
And define a keyword by right-clicking on the Userdefinedkeywords Resource and select the new user define keyword, and give the name as Comparevariables and click ok.
And find the keyword should be equal as integer and pass the new scalar variables
Create a new test case as TC06 and then try to use the keyword Comparevariables; it will not shown any keywords, this is because we have not imported the resources file over here.
Click on Save all, and then open the test suite and click on the Resource, the resource page will open and select the browser and select the userdefinedkeywords.txt file and click ok
You can see the userdefinedkeyword is displayed in the test suite
Now, open the TC06 test case and try to find the Comparevariable keyword by pressing ctrl+alt+space, you will find the keyword
Now select the test case and click on the Run and then click on the start button, the output is:
The Log report is
The Test execution log report
We can also execute the test cases through the command line.
Open the command prompt and open the ride editor
Next, open the project and then open the test suite, in the test suite page, you will the address path of the project saved.
Copy the address link and open the command prompt and directed to the project directory and then pass the command as the
robot name of the test suite
Once you press Enter the test case will be displayed on the command prompt
Of we do not want to run the complete test suite, you can also run the particular test case by using the following command
robot -t testname
And the below link provided you with the various command-line options