Posts

Showing posts with the label Selenium Webdriver

Handle Multiple Browser Tabs and Alerts with Selenium WebDriver

Image
In this tutorial, we will learn to handle multiple browser tabs within a single Selenium script. Selenium WebDriver does not provide any commands for this task.  But we can make use of the existing Selenium commands in a smarter way to automate this scenario. Although this scenario is quite rare and you will not encounter it usually. 1. Handle Multiple Browser Tabs with Selenium Use Selenium Actions Class to Handle Multiple Browser Tabs Actions Class in Selenium is a special class which provides us very useful commands, which helps us to replicate Keyboard and Mouse events i.e., press/release any Key, move cursor, drag and drop, right click, double click etc. You can learn about Actions Class in detail here .  In our scenario, we'll make use of Key control commands of Actions class to automate open and automate multiple browsers. Let's understand the whole code logic step by step. 1.1. Launch google.com with Selenium WebDriver This is the most common part, we'll launc

Find Broken Links on Webpage with Selenium Automation

Image
As an Automation Tester, you get to play with links present on the website. Links are one of the most important parts of the webpage. So, it's always important to not leave any broken links on any website. Testing the links manually could be a tough and time taking task. In this post, we'll learn to automate URL link testing. 1. What is a Broken Link? A broken link is a URL that is not working or not reachable. There are multiple reasons for its dis-functioning. There are different HTTP error status codes that the browser shows when the link is broken. These error codes have different meanings. Let's take a look at the different HTTP status codes. 200 - It means success, the link is working. 404 - It's the most common one, which means Page not found. 403 - Authorization is required to access the page.  400 - It has different meanings, bad request, bad host, timeout, etc. 500 - Internal server error. 2. Why a link broke? A link might not be working due to many reasons,

Learn Selenium Wait Commands: Implicit, Explicit and Fluent Waits

Image
1. Introduction to Selenium Wait Commands Selenium Wait Commands are an essential aspect of automated testing with Selenium WebDriver. They allow us to synchronize our test scripts with the application under test, ensuring that the desired elements are present and in the expected state before performing actions on them. Waiting for elements or conditions to be met is crucial for reliable and stable test execution. Table of Contents: Introduction to Selenium Wait Commands 1.1 Why are Wait Commands Important? 1.2 Types of Wait Commands in Selenium Implicit Wait 2.1 How Implicit Wait Works 2.2 Setting Implicit Wait in Selenium Explicit Wait 3.1 What is Explicit Wait? 3.2 Conditions for Explicit Wait 3.3 Using Expected Conditions in Explicit Wait 3.4 Examples of Explicit Wait Fluent Wait 4.1 What is Fluent Wait? 4.2 Customizing Fluent Wait Conditions 4.3 Examples of Fluent Wait Thread.sleep() vs. Selenium Wait Commands 5.1 Differences between Thread.sleep() and Selenium Wait Comma