We’ll walk you through a hands-on example that demonstrates how to programmatically select and unselect checkboxes using GenAI or ChatGPT, a task that forms the backbone of many web testing and automation projects. Our comprehensive guide covers everything from setting up your Selenium environment to crafting and dissecting the automation code. So, let’s dive in: ChatGPT or GenAI Prompt for […]
JavaScript Button Click Event Tutorial(addEventListener) Want to make your web pages more interactive? This beginner-friendly tutorial will use JavaScript to add click events to buttons. Whether you’re new to web development or looking to expand your JS skills, you’ll learn: Follow along with the provided code examples as we walk through each step. We’ll demonstrate the results live for you […]
The Java LocalDate class can represent dates, with methods to get today’s date, add/subtract days/weeks/years to calculate future or past dates, and print the results. Manipulating dates is straightforward with LocalDate’s intuitive API. Here is a 4 line summary of how to print future and past dates using LocalDate in Java: Java Program
If you’re preparing for upcoming interviews or simply looking to boost your ArrayList mastery, join us as we demystify this key skill for Java developers or Automation engineers. Whether you’re new to Java or an experienced developer, this tutorial takes a practical approach so you can truly master the process of analyzing ArrayLists for distinct and recurring values. Add this […]
One of the frequently asked Java interview questions is how to reverse the words in a sentence. In this tutorial, we will explore how to reverse the words in a sentence using Java. Reversing the words in a sentence means changing the order of the words so that the last word becomes the first, the second last word becomes the […]
In this tutorial, we will discuss How to Shuffle Arrays Using Java Collections. This Java Interview question is asked to check your knowledge of collections and array concepts. To shuffle an array in Java using collections, you can follow these steps: Java program output:
In this tutorial, we’ll explore a Java program for counting digits, letters, whitespace, and special characters in a string. This common interview question tests your Java expertise, particularly in string manipulation. Let’s dive in to strengthen your skills. This guide aims to provide practical insights into tackling such challenges, reinforcing essential Java concepts. Whether preparing for interviews or enhancing Java […]
Hello and welcome to Test Automation Central! This tutorial is entirely focused on SQL Interview Questions and Answers, with a specific emphasis on the employee’s table. Instead of conventional slides or presentations, we’ll take a hands-on approach and provide live demos of various SQL queries. Whether you’re a backend developer, full-stack engineer, or automation specialist, SQL knowledge is vital in […]
In this tutorials, we will discuss on the Java Program to Print Star Pattern (Right Triangle) which is one of the most commonly asked interview question. Whether you are freshers or an experience, this Java programs is asked quit often to test you basic understanding of loops concepts i.e. for loop and interviewer can check how good you are in […]
In this tutorial, we will discuss the Java program to swap elements based on their positions or indices. Whether you’re a coding newbie or a pro, you’ll dig the simple step-by-step guide. This question will be asked in the Java Interview and we got you covered as below tutorials: Steps: Java Program: Output:
In this tutorial, we will learn how to find the index of a specific element in an array using Java. These questions will be asked in the Java Interview and here we have provided detailed tutorials on how to find the Array index of a specific element. Steps: Java Program to Find the Index of a Specific Element in an […]
Java Program to Remove All Vowels from a String is one of the commonly asked interview questions related to Java Programming. steps: Java Program to Remove All Vowels from a String package TestAutomationCentral; public class RemoveVowels { public static void main(String[] args) { String str = “Test Automation Central”; String vowels = “aeiouAEIOU”; String output = “”; for(char c :str.toCharArray()){ […]
Suppose you are in the Java Interview and were asked to write a Java program determining the number of Uppercase letters or characters in a String. How could you answer this question or what could be your approach to solving this Java program? Well, one of the approaches we will discuss in this tutorial. Steps Java Program To Find the […]
In the Java interview, one of the most commonly asked interview questions is to write a Java program to count the number of occurrences of a specific character in a String. If you prepare well in advance, you can quickly and confidently answer or write this Java program to qualify for the upcoming interviews. Steps: Java Program: Output:
One of the commonly asked Java Interview Questions is how to remove all duplicates from an ArrayList. We will use Set to remove the duplicate values and then pass that HashSet to the ArrayList without duplicate values. Step 1: Initialized the ArrayList with duplicate values Step 2: Initialized the Set and passed duplicate values in the HashSet constructor Step 3: […]
The most commonly asked interview questions and answers for SQL Interviews. In this article, we will discuss and focus mainly on the SQL Queries Interview. SQL Query To Print Details Of The Employees Who Have Born In Specified Year select * from employeeswhere year(birth_date) = 1965 SQL Query To Print Details Of The Employees Whose FIRST_NAME Ends With ‘t’. select […]
Java Programs on String are commonly asked interview questions. In this article, we will discuss – how to reverse a String in Java without using an in-built function. Step 1: First, we will convert the String to a char[] array using String function – toCharArray() and store it in variable arr Step 2: Initialized an empty string i.e. null Step […]
In Java Exception Handling, finally block will always be executed irrespective of any exception in the try-and catch block. However, there are two scenarios in which the finally block may not be executed. #1 – System.exit(0) When System.exit(0) is used, the JVM will exit and the finally block will not be executed public static void systemExitFinally() { System.out.println(“#1 – System.exit(0)”); […]
If you have recently upgraded to the latest ChromeDriver and are encountering the “java.io.IOException: Invalid Status code=403 text=Forbidden” error, while trying to initialize ChromeDriver, then there are a couple of ways to resolve it. Firstly, you can add dependencies and set properties to overcome this error. Add the following dependency to your project: <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-http-jdk-client</artifactId> <version>4.8.1</version> </dependency> Then, set […]
How to Handle Multiple Windows/Tabs in Selenium? Firstly, We will open three different tabs with different URLs and store unique identifier strings returned by the getWindowHandle() method in tab1, tab2, and tab3 string variables. Next, we will switch to Tab 2 using the driver.switchTo().window() method. We will then use the getWindowHandles() method to get the window handles and store them […]
Steps to find the Duplicate Element in an Array: Example: package TestAutomationCentral;public class FindDuplicateElement { public static void main(String[] args) { //TestAutomationCentral.com int[] arr = {1,2,3,4,5,1,2}; for(int i=0;i<arr.length-1;i++){ for(int j=i+1;j<arr.length;j++){ if(arr[i] == arr[j]){ System.out.println(“Duplicate Element: ” + arr[i]); } } } }}
This tutorial will briefly discuss the difference between getWindowHandle() and getWindowHandles() with a sample project. getWindowHandle() returns the window handle of the current or active window. getWindowHandles() returns a set of window handles for all the windows opened by the WebDriver instance. Example: package TestAutomationCentral; import org.openqa.selenium.WebDriver;import org.openqa.selenium.WindowType;import org.openqa.selenium.chrome.ChromeDriver; import java.util.Set; public class SeleniumWindowHandles { public static void main(String[] args) […]
Can WebDriver be declared as static? Yes, the declaration of a static WebDriver is valid. Why is it not recommended to declare WebDriver as static? When WebDriver is declared as static, its instance will be shared. This can result in unexpected errors when the tests are executed in parallel, as the WebDriver instance is intended for use in a single […]
Learn the difference between findElement() and findElements() in Selenium WebDriver using Java. These methods are commonly asked in Selenium interviews. Example: package TestAutomationCentral;import org.openqa.selenium.By;import org.openqa.selenium.WebDriver;import org.openqa.selenium.WebElement;import org.openqa.selenium.chrome.ChromeDriver;import java.time.Duration;import java.util.List;public class WebElementDemo { public static void main(String[] args) { //TestAutomationCentral.com System.setProperty(“webdriver.chrome.driver”, “C:\\temp\\drivers\\chromedriver.exe”); WebDriver driver = new ChromeDriver(); driver.manage().timeouts() .implicitlyWait(Duration.ofSeconds(10)); driver.get(“https://www.google.com/”); WebElement element = driver.findElement(By.name(“q”)); element.sendKeys(“TestAutomationCentral.com”); element.submit(); List<WebElement> elements = driver.findElements(By.partialLinkText(“Test Automation […]
In this tutorial, we will discuss a detailed step-by-step guide for swapping two numbers without using a third variable in Java. This is a commonly asked question in Java interviews and Automation Testing. Through this Java program, interviewers aim to evaluate your logical skills and knowledge of Java programming. Example: package TestAutomationCentral; public class SwapNumber { public static void main(String[] […]
In this tutorial, we will discuss on Difference between the close() and quit() methods in Selenium WebDriver ‘close()’ method closes the currently active/focus window or tab of the current browser instance. ‘quit()’ method closes all open windows or tabs of the current browser instance. Example: package TestAutomationCentral;import org.openqa.selenium.WebDriver;import org.openqa.selenium.WindowType;import org.openqa.selenium.chrome.ChromeDriver;import org.openqa.selenium.chrome.ChromeOptions;public class CloseAndQuitDemo { public static void main(String[] args) throws […]
Testing in Chrome’s Incognito mode in Selenium WebDriver. Below is the detailed tutorial and step-by-step guide to run the test execution in Chrome’s Incognito mode using Selenium with Java. Incognito mode allows users to browse the web without saving any browsing history and cookies In Incognito/Private mode, the browser creates a separate session that is isolated from the main browser […]
In this tutorial, we will discuss Running Selenium Tests in Headless Mode. Selenium WebDriver supports headless mode with different browsers like Chrome, Firefox, and Edge. Safari WebDriver does not support headless mode. What is the Headless mode in Selenium WebDriver? In headless mode, we can run Tests Without a GUI Why Headless mode and what are its advantages? Headless mode […]
This tutorial will guide you through the process of handling SSL Certificates in Selenium WebDriver for different browsers like Chrome, Firefox, Edge, and Safari in a step-by-step manner. List of SSL Certificates which we need to handle: Steps: Example package TestAutomationCentral;import org.openqa.selenium.WebDriver;import org.openqa.selenium.chrome.ChromeDriver;import org.openqa.selenium.chrome.ChromeOptions;public class SSLCertificate { public static void main(String[] args) { //TestAutomationCentral.com System.setProperty(“webdriver.chrome.driver”, “C:\\temp\\drivers\\chromedriver.exe”); ChromeOptions options = new […]
STEP 1: Initial min and max values and set them to 0int min = 0, max = 0; STEP 2: Use for loop to iterate each element in the array for (int i = 0; i < arr.length; i++) STEP 3: Within the loop, write if and else if conditions to compare the current element values and set min/max with […]
Selenium does not provide the built-in methods to highlight WebElements on the web page. However, we can overcome and highlight any WebElement using JavascriptExecutor. Code Snippet to highlight element with border: We can set any color to highlight the element with border sizes like 2px, and 5px and pass the values in JavascriptExecutor parameters. js.executeScript(“arguments[0].style.border=’2px solid black'”, element); js.executeScript(“arguments[0].style.border=’4px solid […]
Selenium WebDriver provides built-in functionality for managing the size of browser windows through its Window interface. The current browser window can be expanded to its maximum size using the maximise() function and it can be shrunk to its lowest size using the minimise() method. Maximize and Minimize methods The Selenium WebDriver library provides an interface called Window that provides the […]
What are Locators? Selenium uses locators to interact with the elements on the webpage. Different Types of Locators XPath and CSS selectors are the most often used locators in automated testing. When the DOM structure does not change regularly, the terms Name, ID, and ClassName are utilized. XPath and CssSelectors provide the advantage of being able to locate the HTML […]