- Robot Framework Tutorial
- Robot Framework - Home
- Robot Framework - Overview
- Environment Setup
- Unix and Linux Installation
- Introduction to Ride
- First Test Case Using Ride
- Writing and Executing Test Cases
- Keyword and Data Driven Test Cases
- Working With Browsers Using Selenium Library
- Working With Textbox
- Working With Radio Button
- Working With Checkbox
- Working With Dropdown
- Working With Keywords
- Working With Variables
- Working With Command Line
- Working With Setup And Teardown
- Working with Built-In Library
- Working With External Database libraries
- Testing Login Page Using Robot Framework
- Robot Framework Useful Resources
- Robot Framework - Quick Guide
- Robot Framework - Useful Resources
- Robot Framework - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Robot Framework - Working With Textbox
For testing, it becomes important to understand how to interact with the browser and locate the html elements. It is very easy to work with input fields with robot framework. In this chapter, we will learn how to work with textbox using Selenium Library. To work with input field – textbox, we need the locator, which is the main unique identifier for that textbox and it can be id, name, class, etc.
In this chapter, we will discuss the following areas −
- Project Setup for Textbox Testing
- Enter Data in Search Textbox
- Click on Search Button
Project Setup for Textbox Testing
We will first create a project in Ride to work with browsers. Open ride using ride.py from the command line.
Click New Project and enter Name of your project as shown below.
The name given for the project is Textbox. Click OK to save the project. Right-click on the name of the project created and click on New Test Case −
Name your test case and click OK to save it. We are now done with the project setup. Further, we will write test cases for the textbox. Since we need Selenium library, we need to import the same in our project.
Click on your project on the left side and use Library from Add Import.
Upon clicking Library, a screen will appear where 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 show in red as in the following screenshot −
Enter Data in Textbox
We are now going to write test cases. The test case details will be as follows −
Open browser − URL − https://www.tutorialspoint.com/ in Chrome
Enter data in the search textbox in https://www.tutorialspoint.com/
To work with textbox, we need a locator. A locator is the identifier for the textbox like id, name, class, etc. For example, if you are using the −
name attribute of the textbox, it has to be name − Nameofthetextbox or name=Nameofthetextbox
id of the textbox, it will be id:idoftextbox or id=idoftextbox
class of the textbox, it will be class − classfortextbox or class=classfortextbox
Now, we will add the details of the test case for textbox in ride. Here are the keywords entered for textbox test case −
Open Browser − The keyword opens the browser for the given URL and the browser specified.
Input Text − This keyword works on the input type and will look for the locator name:search on the site https://www.tutorialspoint.com/ and angularjs is the value we want to type in the textbox.
Click button is used to click on the button with location class:gsc-search-button-v2.
We will now execute the same −
Upon clicking the Search icon, a screen will appear as shown in the following screenshot −
Let us now see the reports and the log details −
We have seen how to interact with the textbox using selenium library in robot framework.Using the keywords available with robot framework and the library imported we can locate the textbox and enter data and test the same.