Introduction to Selenium testing

Selenium is a set of different software tools each with a different approach to supporting test automation. Most Selenium QA Engineers focus on the one or two tools that most meet the needs of their project, however learning all the tools will give you many different options for approaching different test automation problems. The entire suite of tools results in a rich set of testing functions specifically geared to the needs of testing of web applications of all types. These operations are highly flexible, allowing many options for locating UI elements and comparing expected test results against actual application behavior. One of Selenium’s key features is the support for executing one’s tests on multiple browser platforms.
Selenium is a portable software-testing framework for web applications. Selenium provides a playback (formerly also recording) tool for authoring tests without the need to learn a test scripting language (Selenium IDE). It also provides a test domain-specific language (Selenese) to write tests in a number of popular programming languages, including C#, Groovy, Java, Perl, PHP, Python, Ruby and Scala. The tests can then run against most modern web browsers. Selenium deploys on Windows, Linux, and macOS platforms. It is open-source software, released under the Apache 2.0 license: web developers can download and use it without charge.

What is automation testing?
Automated testing or test automation is a method in software testing that makes use of special software tools to control the execution of tests and then compares actual test results with predicted or expected results. All of this is done automatically with little or no intervention from the test engineer. Automation is used to to add additional testing that may be too difficult to perform manually.
Automation testing is a technique uses an application to implement entire life cycle of the software in less time and provides efficiency and effectiveness to the testing software. Automation testing is an Automatic technique where the tester writes scripts by own and uses suitable software to test the software. It is basically an automation process of a manual process. Like regression testing, Automation testing also used to test the application from load, performance and stress point of view.

What's the Difference Between Automated Testing and Manual Testing?
Software testing is a huge domain, but it can be broadly categorized into two areas: manual testing and automated testing. In manual testing (as the name suggests), test cases are executed manually (by a human, that is) without any support from tools or scripts. But with automated testing, test cases are executed with the assistance of tools, scripts, and software.
Manual Testing
Manual Testing is a process which is done manually.
All the famous phases of STLC like test planning, test deployment, result analysis, test execution, bug tracking and reporting tools are obviously comes under the category of Manual Testing and done successfully by human efforts.
Manual Testing is a start of Testing, without this testing we can’t start Automation Testing
In Manual Testing we find more bugs than automation by Error Guessing.
It takes lot of time.
Manual Testing would be run sequentially.
Regression testing process is tough in Manual Testing
It is not expensive.
It gives low accuracy result.
No need of programming in Manual Testing.
Automation Testing
Automation Testing is a process which is done by the help of automated tools.
In Automation testing all the popular phases of STLC are done by various open sources and purchased tools like Selenium, J meter, QTP, Load Runner, Win Runner and so on.
Automation Testing is a continuous part of Manual Testing.
In Automation Testing we test the repetitive functionalities of the application
 It takes less time.
Automation Testing is done on different machines at same time
Regression testing process is easy in Automation Testing by Tools.
It is expensive.
It gives high accuracy result.
Need of programming is must in Automation Testing.

Benefits of Automation testing?
  • Supports execution of repeated test cases
  • Aids in testing a large test matrix
  • Enables parallel execution
  • Encourages unattended execution
  • Improves accuracy thereby reducing human-generated errors
  • Saves time and money
What is selenium testing?
Selenium is an automation testing tool used to test web-based applications. Selenium is not a single tool but a suite of tools. There are four components of Selenium – Selenium IDE, RC, WebDriver, and Grid. Last two being the most famous one.  Different components of Selenium provides different features – multiple browsers support, parallel test capabilities, execution on multiple machines and much more.

Why Selenium?
Because it has following features –
It enables parallel execution of tests.
The outcomes are highly accurate and lesser number of errors occur.
Time and money saving tool.
Allows executing repeated test cases
Selenium offer automation testing

What are the main components of Selenium testing tools?
  • Selenium IDE (Integrated Development Environment).
  • Selenium RC (Remote Control)
  • Selenium WebDriver
  • Selenium Grid
Explain Selenium IDE and selenium RC, and selenium web driver and selenium grid?
Selenium IDE:
Selenium IDE is a simple record and playback kind of tool which comes as an add-on for Mozilla Firefox only. It is used for prototype testing. Test cases written in IDE can be exported in many programming languages like Ruby, Java, C#, etc. Edit and Debug options along with record are also available. It is an excellent tool for beginners to understand the syntax of Selenium WebDriver.
Selenium RC:
Selenium RC (Remote Control) was the first tool of Selenium Suite. Earlier it was known as JavaScript Executor. RC was the tool which made Selenium famous in the market.It was the first tool which provided the support for multiple programming languages (JAVA, Ruby, Perl, and PHP, Python, and C #).
Selenium web driver:
Selenium WebDriver is the successor to Selenium RC. Selenium WebDriver accepts commands (sent in Selenese, or via a Client API) and sends them to a browser. This is implemented through a browser-specific browser driver, which sends commands to a browser, and retrieves results. Most browser drivers actually launch and access a browser application (such as FirefoxChromeInternet Explorer, or Microsoft Edge); there is also an HtmlUnit browser driver, which simulates a browser using HtmlUnit.
Selenium grid:
Selenium Grid is a server that allows tests to use web browser instances running on remote machines. With Selenium Grid, one server acts as the hub. Tests contact the hub to obtain access to browser instances. The hub has a list of servers that provide access to browser instances (WebDriver nodes), and lets tests use these instances. Selenium Grid allows running tests in parallel on multiple machines, and to manage different browser versions and browser configurations centrally (instead of in each individual test).

What are the testing types that can be supported by Selenium?
Selenium supports functional Testing and regression Testing.

What is explicit wait in Selenium WebDriver?
Using explicit wait code In selenium web driver, You can define to wait for a certain condition to occur before proceeding further test code execution.

What are the different types of locators in Selenium?
The locator can be termed as an address that identifies a web element uniquely within the webpage. Thus, to identify web elements accurately and precisely we have different types of locators in Selenium:
  • ID
  • ClassName
  • Name
  • Tag Name
  • Link Text
  • PartialLinkText
  • Xpath
  • CSS Selector
  • DOM
What is same origin policy and how it can be handled?
The problem of same origin policy disallows to access the DOM of a document from an origin that is different from the origin we are trying to access the document.
Origin is a sequential combination of scheme, host and port of the URL. For example, for a URL, the origin is a combination of http,, 80 correspondingly.
Thus the Selenium Core (JavaScript Program) cannot access the elements from an origin that is different from where it was launched. For Example, if I have launched the JavaScript Program from “”, then I would be able to access the pages within the same domain such as ““or“”. The other domains like, would no more be accessible.

What is the difference between “/” and “//” in Xpath?
Single Slash “/” –Single slash is used to create Xpath with absolute path i.e. the xpath would be created to start selection from the document node/start node.
Double Slash “//” –Double slash is used to create Xpath with relative path i.e. the xpath would be created to start selection from anywhere within the document.

What Is XPath and what Is use of It in WebDriver?
 In Selenium WebDriver, XPath is used to locate the elements. Using XPath, We can navigate through elements and attributes In an XML document to locate webpage elements like buttons, text box, links, Images etc..

How to type in a textbox using Selenium?
User can use send Keys (“String to be entered”) to enter the string in the textbox.
Web Element username = drv.findElement ( (“Email”));
// entering username
username.sendKeys (“sth”);

What is the difference between absolute XPath and relative XPath?
Absolute XPath: Absolute XPath is the full path starting from root node and ends with desired descendant element's node. It will start using single forward slash (/) as bellow. Example of Absolute XPath:
/html/body/div[3]/div[2]/div[2]/div[2]/div[2]/div[2]/div[2]/div/div[4]/div[1]/div/div/div/div[1]/div/div/div/div[1]/div[2]/form/table/tbody/tr[1]/td/input Above XPath Is absolute XPath of calc result box given on THIS PAGE. It starts top node html and ends with input node.
Relative XPath: Instead of starting from root node, Relative XPath starts from any In between node or current element's node (last node of element). It will start using double forward slash (//) as bellow.
Example of Relative XPath:
//input [@id='Resultbox']
Above XPath Is relative XPath of same calc result box given on THIS PAGE.

In which format does source view shows your script in Selenium IDE?
In Selenium IDE source view shows your script in XML format

Explain how you can insert a start point in Selenium IDE?
In two ways selenium IDE can be set Press “S” key on the keyboard and select the command in Selenium IDE.  In Selenium IDE right click on the command and the select “Set / Clear Start Point”

How to execute only the failed test case in selenium?
When you execute any test using testng.xml in the output folder there will be one file called as testng-failed.xml file will be created. Modify your script and run the testng-failed.xml it will be executed.

Explain how you can capture server side log Selenium Server?
To capture server side log in Selenium Server, you can use command
java –jar .jar –log selenium.log

How to run the test on multiple browsers.
Use parameters annotation in testNG.xml and import that parameters to the program and run the testNG.xml file it will execute on the specified browser.

How to create a Screenshot of failed Test case?
There are two methods to create a screenshot when the testcase is failed.
  • TestNG Listeners.
  • Reusable method.
How to configure Selenium Grid.
Generally selenium grid consists of configuration hub and nodes. Following are the steps required to configure selenium grid.
In the hub system make sure all the libraries, eclipse is being installed and working perfectly.
In the hub system type the following command.
Java –jar selenium.jar role –hub
In the node system open the command prompt with selenium rc directory
And type the following command java –jar selenium-server-standalone -2.44.0 -role web driver -hub\ chromedriver_win32\chromedriver.exe –browser browser Name=chrome -port 1234
Write the script in the hub system and run in eclipse automatically the script will be executed in the node system as well.

What is Robot class?
Robot class in provided by java.awt package which is used to perform keyboard and mouse related operations.

What is Selenese?   
Selenese is the language which is used to write test scripts in Selenium IDE.

How can you find if an element in displayed on the screen?
WebDriver facilitates the user with the following methods to check the visibility of the web elements. These web elements can be buttons, drop boxes, checkboxes, radio buttons, labels etc.
  • isDisplayed()
  • isSelected()
  • isEnabled()
IsDisplayed ():
boolean buttonPresence = driver.findElement(“gbqfba”)).isDisplayed();
boolean buttonSelected = driver.findElement(“gbqfba”)).isDisplayed();
boolean searchIconEnabled = driver.findElement(“gbqfb”)).isEnabled();

What is exception test in Selenium?        
An exception test is an exception that you expect will be thrown inside a test class. If you have written a test case in such way that it should throw an exception, then you can use the @Test annotation and specify which exception you will be expecting by mentioning it in the parameters. Take a look at the example below: @Test (expectedException = NoSuchElementException.class)
Do note the syntax, where the exception is suffixed with .class

Why and how will you use an Excel Sheet in your project?
The reason we use Excel sheets is because it can be used as data source for tests. An excel sheet can also be used to store the data set while performing DataDriven Testing. These are the two main reasons for using Excel sheets.
When you use the excel sheet as data source, you can store the following:
    Application URL for all environments: You can specify the URL of the environment in which you want to do the testing like: development environment or testing environment or QA environment or staging environment or production/ pre-production environment.
    User name and password credentials of different environments: You can store the access credentials of the different applications/ environments in the excel sheet. You can store them in encoded format and whenever you want to use them, you can decode them instead of leaving it plain and unprotected.
    Test cases to be executed: You can list down the entire set of test cases in a column and in the next column, you can specify either Yes or No which indicates if you want that particular test case to be executed or ignored.
When you use the excel sheet for Data Driven Test, you can store the data for different iterations to be performed in the tests. For example while testing a web page, the different sets of input data that needs to be passed to the test box can be stored in the excel sheet.

What are the different types of waits available in WebDriver?
There are two types of waits available in WebDriver:
Implicit Wait
Explicit Wait
Implicit Wait: Implicit waits are used to provide a default waiting time (say 30 seconds) between each consecutive test step/command across the entire test script. Thus, subsequent test step would only execute when the 30 seconds have elapsed after executing the previous test step/command.
Explicit Wait: Explicit waits are used to halt the execution till the time a particular condition is met or the maximum time has elapsed. Unlike Implicit waits, explicit waits are applied for a particular instance only.

What are the Breakpoints and Start points in selenium?
Breakpoints: When you implement a breakpoint in your code, the execution will stop right there. This helps you to verify that your code is working as expected.
Start points: Start point indicates the point from where the execution should begin. Start point can be used when you want to run the test script from the middle of the code or a breakpoint.

Mention why to choose Python over Java in Selenium?
Python over Java to use with Selenium is,
  • Java employs static typing, while Python is dynamically typed.
  • Java programs tend to run slower compared to Python programs.
  • Java uses traditional braces to start and ends blocks, while Python uses indentation.
  • Python is simpler and more compact compared to Java.
What is the difference between Assert and Verify?
Assert- it is used to verify the result. If the test case fail then it will stop the execution of the test case there itself and move the control to other test case.
Verify- it is also used to verify the result. If the test case fail then it will not stop the execution of that test case.

What if you have written your own element locator and how would you test it?
To test the locator one can use “Find Button” of Selenium IDE, as you click on it, you would see on screen an element being highlighted provided your element locator is right or or else an error message will be displayed.

What are core extension?
If you want to “extend” the default functionality provided by Selenium Function Library, you can create a Core Extension. They are also called “User Extension”. You can even download ready-made Core Extension created by other Selenium enthusiast.

What are the two modes of views in Selenium IDE?
Either Selenium IDE can be opened as a pop up window or in side bar.

What are the different types of navigation commands?
Following are the navigation commands:
navigate().back() – The above command requires no parameters and takes back the user to the previous webpage in the web browser’s history.
Sample code:
Navigate ().forward () – This command lets the user to navigate to the next web page with reference to the browser’s history.
Sample code:
navigate().refresh() – This command lets the user to refresh the current web page there by reloading all the web elements.
Sample code:
navigate().to() – This command lets the user to launch a new web browser window and navigate to the specified URL.
Sample code:

How do you verify if the checkbox/radio is checked or not?
We can use isSelected() method. Syntax –
driver.findElement(By.xpath("xpath of the checkbox/radio button")).isSelected();
If the return value of this method is true then it is checked else it is not.

How do you handle alert pop-up?
To handle alert pop-ups, we need to 1st switch control to alert pop-ups then click on ok or cancle then move control back to main page.
String mainPage = driver.getWindowHandle();

Alert alt = driver.switchTo().alert(); // to move control to alert popup

alt.accept(); // to click on ok.

alt.dismiss(); // to click on cancel.

//Then move the control back to main web page-

driver.switchTo().window(mainPage); to switch back to main page.

To enter values onto text boxes what is the command that can be used?
To enter values onto text boxes we can use command sendkeys().

Explain how you can capture server side log Selenium Server?
To capture server side log in Selenium Server, you can use command
    java –jar .jar –log selenium.log

Other than the default port 4444 how you can run Selenium Server?
You can run Selenium server on java-jar selenium-server.jar-port other than its default port

Using Selenium how can you handle network latency?
To handle network latency you can use driver.manage.pageloadingtime for network latency.

How do you achieve synchronization in WebDriver?
We can use implicit wait.
Syntax- driver.manage ().timeouts ().implicitlyWait (10, TimeUnit.SECONDS);
Here it will wait for 10sec if while execution driver did not find the element in the page immediately. This code will attach with each and every line of the script automatically. It is not required to write every time. Just write it once after opening the browser.

What is a Framework?
A framework is set of automation guidelines which help in Maintaining consistency of Testing, Improves test structuring, Minimum usage of code, Less Maintenance of code, Improve re-usability, Non-Technical testers can be involved in code, Training period of using the tool can be reduced, Involves Data wherever appropriate.
There are five types of framework used in software automation testing:
  • .Data Driven Automation Framework
  • Method Driven Automation Framework
  • Modular Automation Framework
  • Keyword Driven Automation Framework
  • Hybrid Automation Framework, it’s basically combination of different frameworks. (a+b+c).
What are the prerequisites to run selenium web driver?
JDK, Eclipse, WebDriver (selenium standalone jar file), browser, application to be tested.

What is the use of getOptions () method?
getOptions () is used to get the selected option from the dropdown list.

What is the use of deSelectAll() method ?
t is used to deselect all the options which have been selected from the dropdown list.

Is WebElement an interface or a class?
 WebDriver is an Interface.

FirefoxDriver is class or an interface and from where is it inherited?
FirefoxDriver is a class. It implements all the methods of WebDriver interface.

Which is the super interface of webdriver?

What is the difference b/w close () and quit ()?
close() – it will close the browser where the control is.
quit() – it will close all the browsers opened by WebDriver.

What is testing strategy?
A Test Strategy document is a high level document and normally developed by project manager. This document defines “Software Testing Approach” to achieve testing objectives. The Test Strategy is normally derived from the Business Requirement Specification document.

What is actions class in WebDriver?
Actions class is used to control the actions of mouse.

What are different components of your framework?
Library- Assertion, ConfigLibrary, GenericLibrary, ProjectSpecificLibrary, Modules.
Drivers folder, Jars folder, excel file.

What is the difference b/w getWindowHandles () and getWindowHandle ()?
GetWindowHandles ()- is used to get the address of all the open browser and its return type is Iterator<String>.
GetWindowHandle ()- is used to get the address of the current browser where the conrol is and return type is String.

How can you redirect browsing from a browser through some proxy?
Selenium provides a PROXY class to redirect browsing from a proxy. Look at the example below:
String PROXY = “”;
org.openqa.selenium.Proxy proxy =;
Desired Capabilities cap = new DesiredCapabilities();
cap.setCapability(CapabilityType.PROXY, proxy);
WebDriver driver = new FirefoxDriver(cap);

Can WebDriver test Mobile applications?
WebDriver cannot test Mobile applications. WebDriver is a web based testing tool, therefore applications on the mobile browsers can be tested.

Can captcha be automated?
No, captcha and bar code reader cannot be automated.

 What is Object Repository? How can we create Object Repository in Selenium?
Object Repository is a term used to refer to the collection of web elements belonging to Application under Test (AUT) along with their locator values. Thus, whenever the element is required within the script, the locator value can be populated from the Object Repository. Object Repository is used to store locators in a centralized location instead of hard coding them within the scripts.

What is POM (Page Object Model)?
Page Object Model is a design pattern for creating an Object Repository for web UI elements. Each web page in the application is required to have its own corresponding page class. The page class is thus responsible for finding the WebElements in that page and then perform operations on those WebElements.

What is Page Factory?
Page Factory gives an optimized way to implement Page Object Model. When we say it is optimized, it refers to the fact that the memory utilization is very good and also the implementation is done in an object oriented manner. Page Factory is used to initialize the elements of the Page Object or instantiate the Page Objects itself. Annotations for elements can also be created (and recommended) as the describing properties may not always be descriptive enough to differentiate one object from the other.

My XPath finds elements in one browser, but not in others. Why is this?
The short answer is that each supported browser handles XPath slightly differently, and you’re probably running into one of these differences. The long answer is on the XpathInWebDriver page..

Cross browser testing in selenium?
Ability to test on multiple browsers is called cross browser testing. It can be done by parameters annotation in testNG.

Where do we use hashmaps in selenium?
Whenever we want to store collection of elements then we use hashmaps.

What is webdriver listener and TestNG Listener?
Webdriver listener is provided in webdriver which is used to track the events in the scripts.
TestNG Listener is provided by testNG which automatically gets triggered once the operation is completed.

What is dependency test In TestNG?
Dependency Is very good feature of testing using which we can set test method as dependent test method of any other single or multiple or group of test methods. That means depends-on method will be executed first and then dependent test method will be executed. If depends-on test method will fail then execution of dependent test method will be skipped automatically. TestNG dependency feature will works only If depends-on test method Is part of same class or part of Inherited base class.

What is the syntax to set test method disabled?
We can use attribute enabled = false with @Test annotation to set test method disabled. Syntax Is as bellow.
@Test (enabled = false)
    Public void LogOut() {
  System.out.println("LogOut Test code.");

How to pass parameter with testng.xml file to use It In test case?
We can define parameter In testng.xml file using syntax like bellow.
<parameter name="browser" value="FFX" />
Here, name attribute defines parameter name and value defines value of that parameter. Then we can use that parameter In selenium webdriver test case using bellow given syntax.
@Parameters ({"browser"})

What is Ajax?
Asynchronous JavaScript and XML Is full form of AJAX which is used for creating dynamic web pages very fast. Using Ajax, We can update page behind the scene by exchanging small amounts of data with server asynchronously. That means, using Ajax we can update page data without reloading page.

How to handle Ajax In selenium WebDriver?
 Generally we are using implicit wait in selenium WebDriver to wait for some element to be present on page. But Ajax call cannot be handled using only Implicit wait In your test because page not get reloaded when ajax call sent and received from server and we cannot assume how much time It will take to receive ajax call from server.

To handle Ajax call In selenium WebDriver, We needs to use webdriver’ s Fluent Wait method or Explicit Waits which can wait for specific amount of time with specific condition.

Can you tell me the alternative driver.get() method to open URL In browser?
We can use anyone from bellow given two methods to open URL In web browser in selenium webdriver.
  • driver.get()
  • driver.navigate().to()
What is Object Repository?
An object repository is an essential entity in any UI automations which allows a tester to store all object that will be used in the scripts in one or more centralized locations rather than scattered all over the test scripts.

Explain what are the JUnits annotation linked with Selenium?
The JUnits annotation linked with Selenium are
@Before public void method() –
It will perform the method () before each test, this method can prepare the test
@Test public void method() –
Annotations @Test identifies that this method is a test method environment
@After public void method()-
To execute a method before this annotation is used, test method must start with test@Before.

Explain what is Data driven framework and Keyword driven?
Data driven framework: In this framework, the test data is separated and kept outside the Test Scripts, while test case logic resides in Test Scripts. Test data is read from the external files (Excel Files) and are loaded into the variables inside the Test Script. Variables are used for both for input values and for verification values.
Keyword driven framework: The keyword driven frameworks requires the development of data tables and keywords, independent of the test automation. In a keyword driven test, the functionality of the application under test is documented in a table as well as step by step instructions for each test.

How you can use “submit” a form using Selenium?
You can use “submit” method on element to submit form-
element.submit ();
Alternatively you can use click method on the element which does form submission

What is heightened privileges browsers?
The purpose of heightened privileges is similar to Proxy Injection, allows websites to do something that are not commonly permitted. The key difference is that the browsers are launced in a special mode called heightened privileges. By using these browser mode, Selenium core can open the AUT directly and also read/write its content without passing the whole AUT through the Selenium RC server.

Can we automate desktop application's testing using selenium WebDriver?
No. This Is the biggest disadvantage of selenium WebDriver API. We can automate only web and mobile application's testing using selenium WebDriver.

Can you tell me the alternative driver.get() method to open URL In browser?
We can use anyone from bellow given two methods to open URL In web browser In selenium webdriver.

Can you tell me a difference between driver.get() and driver.navigate() methods?
Main and mostly used functions of both methods are as bellow.
driver.get() method Is generally used for Open URL.
It will wait till the whole page gets loaded.
driver.navigate() method Is generally used for navigate to URL, navigate back, navigate forward, refresh the page.
It will just navigate to the page but wait not wait till the whole page gets loaded.

Is it possible to execute javascript directly during test execution? If yes then tell me how to generate alert by executing javascript in webdriver script?
Yes, we can execute javascript during webdriver test execution. To generate alert, you can write bellow given code In your script.
JavascriptExecutor javascript = (JavascriptExecutor) driver;
javascript.executeScript("alert('Javascript Executed.');");

What is sikuli and AutoIt and difference between them?
Sikuli and AUTOIT both are used to perform desktop related operations which a selenium web driver cannot do directly.
Sikuli interacts with the desktop application based on the images it recognizes the path of the image.
AutoIT interacts based on the properties of window. It provides full-fledged documentation in the form of a help file.

What is browsermobproxy?
Browsermobproxy is used to get the response time whenever a request is send to the server. It is a part of selenium open source project.

How to work with webtables in selenium?
First we have to find out the table locator technique.
This table consist of some tags <table> tag- This is the most outer tag which contain overall data <tr> tag - This represent table row if we have 4< tr> tag it mean we have 4 rows <td>tag- This represent table data if<tr> have 3 <td> it means that rows has 3 columns

What are Cookies how to create a cookie?
A cookie, also known as an HTTP cookie, web cookie, Internet cookie, or browser cookie, is a small piece of data sent from a website and stored in a user's web browser while the user is browsing that website. Every time the user loads the website, the browser sends the cookie back to the server to notify the website of the user's previous activity.
addCookie (Cookie cookie)
deleteCookie (Cookie cookie)
deleteCookieNamed (java.lang.String name)
deleteAllCookies ()
getCookies ()
getCookieNamed (java.lang.String name)
Request to Download PDF

Post A Comment: