Working With Browsers Using Selenium Library

In this chapter, we will learn how to work with browsers using Robot Framework and Selenium Library in ride.
Project setup in Ride
Import Selenium Library
Test case using Chrome Browser
Test case using Firefox Browser
We will first create a project in Ride to work with browsers. Open ride using ride.py from the command line.
Click on New Project and give name to your project.
The name given is BrowserTestCases. Click OK to save the project. Right-click on the name of the project created and click on New Test Case −
Give name to the test case and click OK.
We are done with the project setup. Now, we will write test cases for the browser.
To work with browsers, we need selenium library to be imported in robot. We can do that as follows −
Go to https://robotframework.org/
On the left side, select the LIBRARIES option.
Select External option from above and it will list you all the libraries available to be used.
Click SeleniumLibrary.
You will be redirected to the github repo as shown below −
For Installation of seleniumlibrary, we can use the command from the github and install it using pip.
pip install --upgrade robotframework-seleniumlibrary

Selenium library gets installed inside the lib folder in python as follows −
Once the installation is done, we have to import the library in Ride as shown in the below steps.
Click on your project on the left side and use Library from Add Import −
Upon clicking Library, a screen will appear wherein you need to enter the library name −
Click OK and the library will get displayed in the settings.
The name given has to match with the name of the folder installed in site-packages. In case the names do not match, the library name will be in red as shown below −
Library import in red is as good as the library does not exist inside python. Now, we have completed selenium library import.
To work with Chrome browser in Robot, we need to first install the drivers for chrome to work with Selenium. The drives are available on Selenium site − https://www.seleniumhq.org/.
Click Download Selenium as in the above screenshot.
In download section, go to Third Party Browser Drivers NOT DEVELOPED by seleniumhq and select Google Chrome driver as shown in highlighted section below
Here we have a list of the various drivers available for browsers. For Chrome, click Google Chrome Driver and download the latest driver as per you operating system.
Click on the latest release. It will display the downloads as per the operating system – windows, linux and mac.
Download the version as per your operating system from the above list. It downloads the zip file. Once the file downloads, unzip it and copy the .exe driver file to python folder.
We are copying the file to C:\Python27\Scripts.
Now we are done installing the driver for chrome. We can get started with writing test case that will open browser and close browser.
Go back to ride and enter the keywords for opening the browser.
Ride helps you with keywords to be used with its built-in tool. Enter the command and press ctrl+spacebar. You will get all the details of the command as shown below
It gives the details of the command and also examples on how to use it. In the test case, we will open the site https://www.tutorialspoint.com/ in chrome and the test case details will be as follows −
Let us now run this test case to see the output −
The test case has passed; we can see the site is opened in chrome browser.
We will add more test cases as follows −
Open Browser − URL − https://www.tutorialspoint.com/ in Chrome browser
Open Browser − URL − https://www.tutorialspoint.com/ in Chrome browser
Capture Page Screenshot − name of the image is page.png
Capture Page Screenshot − name of the image is page.png
Close browser
Close browser
Here are the details of the report and log for above test cases executed.
Install the driver for Firefox and save it in python scripts folder.
We have seen how to install Selenium library and the browser drivers to work with browsers in Robot framework. Using the selenium library keywords, we can open any given link in the browsers and interact with it. The details of the test-case execution are available in the form of reports and logs, which give the time taken for execution.

    17 Lectures 
     1 hours 

 Musab Zayadneh

    11 Lectures 
     31 mins

 Musab Zayadneh

    20 Lectures 
     1.5 hours 

 Maksym Rudnyi

    25 Lectures 
     3 hours 

 Kamal Kishor Girdher

    16 Lectures 
     3.5 hours 

 Onur

    10 Lectures 
     34 mins

 Ashraf Said
 Print
 Add Notes
 Bookmark this page