Monthly Archives: April 2019

TestNG annotations

Below is the list of annotations in TestNG. @BeforeTest @AfterTest @BeforeMethod @AfterMethod @BeforeSuite @AfterSuite @BeforeGroups @AfterGroups @BeforeClass @AfterClass @Test @BeforeTest: Executes before any method in a class which is having @Test annotation. @AfterTest: Executes after any method in a class which is having @Test annotation. @BeforeMethod: Executes every time before any test method in a… Read More »

Implicit and Explicit wait in Selenium

During automation script development, its common that at least once in their test execution, their scripts have failed due to WebDriver couldn’t able to find element in the web page. This issue can be resolved by using selenium wait conditions appropriately. Page load speed depends on the how fast the response is coming from web… Read More »

How to handle mouse hover events using Selenium WebDriver

In this article, we will learn about how to handle the mouse hover events using selenium webdriver. Firstly, we have to hover mouse over the menu item. This displays the dropdown list/sub menu items. Next, we have to select the sub elements from the list and have to click on one of the sub element.… Read More »

encapsulation in java

Encapsulation in java: Encapsulation = Data Hiding + Abstraction. It means if any component is following Abstraction as well as data hiding then it is also following Encapsulation. Encapsulation: It is actually the process of binding data members and methods together in a unit. Each class in java itself is an example of encapsulation. It… Read More »

general selenium questions

1. Find element using xpath and cssSelector. Html code: <a class=”shopicon relative”>Shopping</a> Solution:  //a[@class=’shopicon relative’]   –> using xpath in firefox .shopicon.relative   –> using cssSelector in chrome //a[text()=’Shopping’] –> text() method 2. In the “” website, ways to find NEWS link are: Using cssSelector: .navbar>:nth-child(1)>:nth-child(2) .navbarul>:nth-child(2) Using xpath: //a[text()=’NEWS’]   Related articles: Waits in Selenium WebDriver


TestNG is a test automation framework emerged to overcome the limitations of both JUnit and NUnit. It has many new features which are more powerful and easy to use. Annotations. Multithread safe tests. Data driven testing. Parameterization support. TestNG supports a different variety of tests like unit, integration, system, functional and end to end. Setup… Read More »

Selenium Tutorials

Selenium Tutorials Introduction: Selenium is a free and open source test automation tool for testing web applications. Selenium can be installed on most of the operating systems like Windows  Linux  Apple iOS   etc. Cross browser testing is possible using selenium i.e., we can run the test scripts in different browsers like Firefox  IE  Chrome  Opera … Read More »

Most Commonly Asked Top Selenium Interview Questions

Most Commonly Asked Top Selenium Interview Questions: ADP Written test questions: 1. How to find inner text using CSS attribute. Options: css=tag:attribute (“inner text”); etc. 2. How to find words starting with ADP using CSS. Below are the few options. tag:attribute(“starts-with@id, “ADP”); tag:attribute(“@id, “ADP”); etc. 3. A question about Actions element. 4. Context click is… Read More »

How to handle alerts in Selenium WebDriver

How to handle alerts in Selenium WebDriver: Selenium WebDriver is able to handle alerts in addition to the windows and frames. This tutorial explains how to handle alerts in selenium. Alerts in selenium: What is an alert? Alert is a popup or message box which displays on the screen. Alerts can appear on the screen… Read More »

do while loop in java

Difference between while and do while loop in java: while loop do while loop Checks the condition before executing the statement. It first executes the statement and then checks the condition. Entry controlled loop. Exit controlled loop. Condition comes before the body. Condition comes after the body. Statement(s) are executed at least once. Example: int… Read More »

How to convert string to int in java

In this article you are going to learn, how to convert string to int in Java. parseInt valueOf NumberFormatException 1. Integer.parseInt(): String str = “50”; int num= Integer.parseInt(str); System.out.println(num); Output: 50 Info: It parses the string argument as a decimal integer. All characters in the string must be integers. Otherwise it will throw NumberFormatException. 2.… Read More »

common exceptions in selenium webdriver

Common exceptions in Selenium: 1 ElementNotSelectableException: Occurs when an element is not selectable. 2 ElementNotVisibleException: Element is present in the DOM but it is not visible. So WebDriver is unable to interact with the element. 3 NoAlertPresentException: This exception occurs when there is no Alert is present in the DOM. So WebDriver couldn’t be switched to the Alert. 4. NoSuchElementException: Occurs… Read More »

profiling in selenium webdriver

Firefox options and profiling in Selenium WebDriver: //How to remove log statements in console: System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE,”null”); //Set binary path of a browser FirefoxOptions fo = new FirefoxOptions(); fo.setBinary(“path to exe”); //page load strategy fo.setPageLoadStrategy(PageLoadStrategy.NONE); //or fo.setPageLoadStrategy(PageLoadStrategy.EAGER); //or //Tell selenium to launch specific firefox profile //First, Exit the firefox (Don’t click on cross button to close the… Read More »

auto suggest dropdown in selenium webdriver – Practice question 1

Auto suggest dropdown in Selenium: Topic: How to select an option from auto suggest dropdown in selenium. Example of auto suggest dropdown:               Below code is the solution for the 1st question present in the page. package com; import static; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.Keys;… Read More »


Selenium Interview Questions: 1. Question on xpath. Parent child traversing. Lets consider we have 1 parent element and 3 child elements. Write a xpath to identify the 2nd child element using 1st child element? Selenium Testing Selenium WebDriver Selenium Automation Solution: //*[@id=’id1′]/following-sibling::li[1] Explanation: If you give the xpath ‘//*[@id=’id1′]‘ in firepath or chropath, 1st child… Read More »