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:

Automating Google Search with Selenium WebDriver: Handling AJAX Calls

Image
Google Search represents one of the most  complex yet essential  web elements to automate because: It uses  AJAX (Asynchronous JavaScript and XML)  for real-time suggestions The UI frequently changes, requiring  robust locator strategies It's the perfect case study for  mastering dynamic element handling Key Learning Objectives ✔ Understand how AJAX powers Google's instant search suggestions ✔ Implement  Explicit Waits  to handle dynamic content ✔ Automate the complete search suggestion workflow ✔ Build  failure-resistant  test scripts "Google's search automation is the ultimate test of your Selenium skills - it combines dynamic waits, precise element location, and real-world AJAX handling." - Sarah Johnson, Lead QA Automation Engineer   Table of Index What is AJAX Search? Why Use Explicit Wait for AJAX? Step-by-Step Automation Guide Complete Java Code Solution Common Errors & Fixes Best Practices FAQs What is AJAX Search? AJAX...

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...