Selenium New Version i.e. 2.42.0

Selenium new version is available i.e 2.42.0 , please download it from below link and update your libraries so that you will not face any compilation or any other version related issue:

To stay update, just like my Facebook page

What is the difference between Xpath and DOM (Document Object Model)?

This is the question asked in most of the interviews of Selenium:


The Document Object Model (DOM) is a cross-platform and language-independent convention for representing and interacting with objects in HTML, XHTML and XML documents. Objects in the DOM tree may be addressed and manipulated by using methods on the objects.

Ex: var element=document.getElementById("intro");


XPath, the XML Path Language, is a query language for selecting nodes from an XML document. In addition, XPath may be used to compute values (e.g., strings, numbers, or Boolean values) from the content of an XML document.

Ex: //input[@id=”xxx”]

Difference Between Implicit Wait and Explicit Wait

Implicit Wait – 

An implicit wait is to tell WebDriver to stop the DOM for a certain amount of time. The default setting is 0. 

Syntax – driver.manage().timeouts().Implicitly Wait(10, TimeUnit.SECONDS); 

Explicit Wait - 

What is the difference between absolute and relative Xpath?

Absolute Xpath : 

1) start selection from the document node
2) Starts with //
3) e.g. “/html/body/p” matches all the paragraph elements

Google Search Box : /html/body/div[1]/div[2]/div[1]/div[1]/div[3]/div/div/div/form/fieldset[2]/div/div/div

Relative Xpath  : 

1) start selection matching anywhere in the document
2) Starts with /
3) e.g. “//p” matches all the paragraph elements starts with p

Google Search Box : //*[@id='gbqfqwb']

TestNG Error Codes

We write automation framework using TestNG and when we run it we get errors sometimes. So, it becomes important for us to know about error messages. 

I have put some of the error messages that we get when we go wrong and execute TestNG XML file:

1.If two tests are having the same name then we see below error

at org.testng.TestNG.checkTestNames(
at org.testng.TestNG.sanityCheck(

2.If the testname doesnot enclosed in double quotes("") then we get below error

Launched a tutorial on JMeter

This is just an introduction to JMeter. Below are some points covered in this video:

- How to install and configure JMeter?
- Why JMeter and Features of JMeter
- History of JMeter
- Parameters of JMeter
- Introduction to Sampler, Threads, Listeners, Controllers, Timer, Pre-Processor, Post-Processor, Test Plan, Work Bench etc

How to Zoom In and Zoom Out in Website

In case, you want to zoom in and out in any website using Selenium. You can follow below commands:

To Zoom In:

WebElement Sel= driver.findElement(By.tagName("html"));
sel.sendKeys(Keys.chord(Keys.CONTROL, Keys.ADD));

To Zoom Out to normal page, use below command:

html.sel(Keys.chord(Keys.CONTROL, "0"));

This can be useful when you need to pin point something while showing your automation framework to any user. 

How to get data from an Excel sheet?

If you're looking how to pick username and passwords or any data from an excel sheet then below steps will help you out:

1) Download J-Excel jar (What is J-Excel), you can get the path to download J-Excel jar by clicking here
2) Now, add this jar to your build path. You can look for the steps here.
3) Create a new class and add below code:

public class Excel {
static Sheet s ;
 public static void main(String[] args) throws BiffException, IOException {
FileInputStream fis = new FileInputStream("C:\\Users\\DELL\\Desktop\\r.xls");
Workbook w = Workbook.getWorkbook(fis);
s = w.getSheet(0);

Generate Random Data

In your scripts, you always want to generate random data to automate SignUp forms, below is code to generate random password. If you need script to generate data to complete forms like available here, do write an email to me:


public static void main(String[] args) {

//can put any array below depending on requirement
String array = "abcde1234567890~!@#$%^&*()_+";

//calculates its length
int i = array.length();

 //password with length 10
for (int j =0; j<=10; j++)

//randomly picking up 10 characters
 int k = (int)(Math.random()*i);
char pass = array.charAt(k);

Interview Questions and Answers on Automation Testing

Click on the questions below to get the answers

1) What is Automation ?

Answer: In general, it is the process of implementing particular work automatically by using a machine, to reduce the need of human work in the production of goods and services.
2) What is meant by Automation in software testing ?

Answer: It is a process of testing an application(executing the tests, comparing expected and actual results under some controlled conditions and generating the reports) automatically by using a 'Tool' to reduce the need of human effort. This tool may be Selenium / QTP / RFT / SilkTest etc.
3) Why do we need automation in software testing ?

Answer: Humans can do mistakes. If a work is repetitive then we may skip some work intentionally or unintentionally due to time pressure, boring task, etc. In order to overcome these problems 'automation testing' has been introduced to reduce manual task, to save cost and time, to improve accuracy, to perform repetitive execution of tests, to customize defect reporting etc. and hence automation is needed, as it replaces human with great features.
4) Which type of testing can be Automated ?

Answer: We can automate Regression testing, Functional testing, Stress testing, Performance testing, Load testing, Smoke testing, Compatibility testing, Data-Driven testing etc.
5) When to do automation testing ?

Answer: It is not always advantageous to automate test cases. We can do automation:
- When the application is stable.
- For long term projects.
- When you have lot of regression work.
- When the scenario is easily debuggable.
6) What are the advantages and disadvantages of Automation Testing ?

Advantages :
- Reduces human resources.
- Using an automation tool, test scripts can be executed faster when compared to manual execution and hence saves time.
- Repeatable execution of tests may lead to make mistakes when it is done manually but when we automate the same task, accuracy will be improved.
- Test cases can be reused in various versions of software which saves time and cost.

- Unemployment rate increases as machine replaces human.
- It is not so easy to write automation test scripts, it requires skilled and experienced resources.
- We cannot automate everything as it is advantageous only for repeatable and reusable test cases.
- Initial cost for automation is very high unless it is open source.
- Debugging skills should be high otherwise its effect will be dangerous (mainly it kills time, so, we cannot reach dead-line).

7) Name some test automation tools?

- Selenium (Open Source)
- HP QuickTest Professional (Commercial)
- IBM Rational Functional Tester (Commercial)
- HP WinRunner (Commercial)
- SilkTest (Commercial)
- HTTP Test Tool (Open Source)
- WATIR (Open Source)
- Maveryx (Open Source)
- eggPlant (Commercial)

8) What kind of tests should NOT be automated?

- Automating tests that only need to be executed once doesn't make sense.
- Tests without predictable results – test automation should give us confidence in the results of the tests. If there are intermittent failures then the tests cannot be reliable.
- Tests that need to be verified visually
- Tests that need to be executed quickly. At first, writing an automated test takes longer. If we want a quick check, we should test it manually however, if that test is a good one which should be run regularly, then it should be automated in time
- Usability Testing – at times it becomes impossible to perform testing by automation as the computer cannot efficiently judge if the system is of any use to its users.

Difference between Jexcel and Apache POI


Apache POI

  • It doesn’t support Excel 2007 and Xlsx format. It supports only Excel 2003 and .Xls format

  • It supports both

  • JXL doesn’t support Conditional formatting

  • It supports

  • JXL API was last updated in 2009

  • Apache POI is actively maintained

  • It doesn't support rich text formatting

  • Apache POI supports it

  • It has very less documents and examples as compare to Apache POI

  • It has extensive set of documents and examples

You can download Apache POI jar by clicking here
You can download JExcel jars by clicking here

Example of JExcel Click Here