Posts

Showing posts with the label Selenium Webdriver

How to Take Screenshots with Selenium WebDriver

Image
While performing manual testing we often take screenshots of the broken pages or bugs to use them as evidence and they are very useful in convincing the developers. Similarly, in automation Selenium provides us the commands to capture screenshots of the webpages. In this tutorial, we will learn to take full screenshots and partial screenshots of the webpage which is currently under test. We can also write some code logic to capture screenshots on every failure screen. That's a bit advanced-level concept. But in this post, we'll learn to take screenshots whenever we want. We also have to do some file-handling operations while taking and saving screenshots with Selenium WebDriver. Table of Contents:

How to Automate Google Search with Selenium WebDriver

Image
In this post, you will learn to automate Google Search using Selenium Webdriver with Java. This is a real-time example of Explicit wait command. Google search is an Ajax call. We will handle this Ajax call using the Explicit wait command of Selenium Webdriver. We can also say that we'll automate the auto-suggestion feature of search in this post. 1. What is Ajax search? Ajax stands for Asynchronous JavaScript and XML. Ajax is a new technology for creating faster and more interactive web applications. What Ajax does is: Update a web page without reloading/refreshing it Read data from the server after the page is loaded When you write something into a Search Box say "app" and it shows you similar search options that are Ajax. And you can automate that auto-suggestion box with the help of Explicit command in Selenium WebDriver . Google search is the best example of Ajax. In the case of Google search, you simply type any keyword in the search bar and just below the s

Implement Code Re-usability in Selenium Automation Framework

Image
In this post, you will learn kind of coding pattern which is very helpful in maintaining our automation code. This post is written insight to help beginners. We'll learn that instead of writing a linear script, we should create page (action) methods which in general contain actions which we are going to perform on our web software. Let's say, we have a login functionality in our software and we have to automate it. In that case we'll create a method named login and write the commands like, entering username, password and click login in that method. Now we can use that method wherever we need it in other test cases as well. Benefits of using action methods are: Code Re-usability Better maintainability of code Sample Program for Re-Usable Action Methods: package com . techlistic . tute ; import org.junit.Assert ; import org.junit.Test ; import org.openqa.selenium.By ; import org.openqa.selenium.WebDriver ; import org.openqa.selenium.WebElement ; import o

Mastering Locators in Selenium WebDriver: The Ultimate Guide with Examples

Image
Selenium is a popular open-source tool used for automating web browsers. It allows testers to write scripts in various programming languages such as Java, Python, C#, and Ruby to automate web applications. One of the critical aspects of Selenium automation is identifying web elements on a web page using locators. In this blog, we will discuss locators in Selenium and how to find them. Locators are nothing but a way to locate web elements on a web page. Selenium WebDriver provides a set of locators that can be used to identify web elements on a web page.  1. The various types of locators supported by Selenium WebDriver are: 1. ID Locator: This locator is the most common and efficient way to locate an element on a web page. Each web element on a page should have a unique ID. You can use the ID Locator to find an element using its ID. 2. Name Locator: The Name Locator is another way to locate an element using its name attribute. This is particularly useful when you want to locate m