Posts

Showing posts with the label Selenium Webdriver

What are Selenium Locators and Find Element Commands?

Image
Selenium Locators Locators are used to tell Selenium that on which GUI element (text box, radio boxes, links, buttons etc.) action has to be performed. We must have basic knowledge of HTML in order to learn locator techniques. There are total of 8 locators  by which we can find element in Selenium WebDriver. Here is the list: ID Class Name Name Link Text Partial Link Text Tag Name Xpaths CSS Selector Selenium Locators Video Tutorial (YouTube) 1. Locate by ID, Name and ClassName These three are the most common type of locators.  Id, Name and ClassName are the attributes used along with html tags.  These attributes are given by Front-end developers for CSS designing. Automation testers make use of these attributes for locating elements. Example HTML Code for Login Page using Id, Name and ClassName attributes: " <html> <title>Sample Login Page </title> <body>           <input type='text' id='username' name=&

What is Actions Class in Selenium WebDriver?

Image
In this tutorial we will cover Action class and its commands. It is considered as the Advanced Selenium Commands. What is Action Class in Selenium WebDriver? Actions class is used to handle Keyboard and Mouse Events. You need to import org.openqa.selenium.interactions.Actions in order to use Actions class. This class includes keyboard and mouse actions such as double click, right click, drag & drop, mouse hover and clicking multiple elements. It's commands can be broadly classified in two groups: Keyboard Events Mouse Events Create object of Actions class: // Create object of Actions class Actions actions = new Actions(driver); 1. Keyboard Events Listing down some of the methods to perform keyboard events: i. keyDown( KeyCode )   - Performs key press without releasing it. Parameters  -  Key_Code For e.g., Keys.ALT, Keys.SHIFT or Keys.CONTROL ii. keyUp( KeyCode )  - Performs a key release. It has to be used after keyDown to release the key. Parameters

What is Robot Class in Selenium WebDriver?

Image
Selenium can't interact with Window dialogs on it's own. You all must know that Selenium can only handle browser windows and not OS windows. So, when we have to upload any file on a webpage and as soon as we click on the Browse or Upload button, a windows tab opens up from which we have to select the file. We cannot handle that windows tab directly with Selenium WebDriver. But we can use other libraries and integrate them with Selenium code to handle window based dialogs. Robot class is one of them. We can use Robot class to upload or download a file using selenium. What is Robot Class in Selenium WebDriver? Robot Class is used to perform Keyboard actions. It has direct support to perform actions like press and release key. Robot class has key codes for each key present on the keyboard. So, if we want to press any key, then we need to call that key code. In automation we make use of Robot class to handle Windows tabs by interacting with them via virtual keyboard. One i

Handle Static and Dynamic Web Table in Selenium WebDriver

Image
In this post, we will learn how to automate web table with Selenium Webdriver. It's always tricky to fetch data from a web table using Selenium and when the table structure keeps changing every time on the basis of data to be shown then it becomes more challenging task to automate it. First let's learn how to read data from a web table with Selenium. Table of Content 1. What is Web Table? Types of Web Table Static Table Dynamic Table 2. Automate Reading data from Static Web Table with Selenium Practice Exercises for automating Static Table Solution Code for Static Table Code Explanation 3. Automate Handling Dynamic Web Table with Selenium Practice Exercises for automating Dynamic Table Solution Code for Dynamic Table Code Explanation 1. What is a Web Table? A web table is a way of representing data in rows and columns. It's the html representation of MS-Excel table. Web table has various html tags that automation engineer should be aware of like., table, th, tr, td. Let'