Where we learn technology

Advanced Selenium Webdriver Interview Questions and Answers in Java

Advanced Selenium Webdriver Interview Questions and Answers in Java

Selenium WebDriver – QA

Here is the list of Selenium Interview questions and answers.


How to read data from table? 

You can easily read the data from table using findElements method. 

Find all the table cells using TD tag and then get the text inside each cell by getText() method or innerText property in HTML DOM.


What all browsers and OS are supported by Selenium? 

Selenium supports below browsers.
  1. Internet Explorer
  2. Google Chrome
  3. Firefox
  4. Safari
  5. Opera
  6. Android browser
  7. iPhone Browser
Operating systems supported by Selenium are –
  1. All Windows OS
  2. Linux
  3. Mac (Apple OS)
  4. Android
  5. IOS
Various Synchronization methods in Selenium Webdriver – implicit wait, 
page load timeout, explicit wait?
There are 4 ways we can handle synchronization in Selenium.
  1. Implicit
  2. Explicit using wait and expected conditions
  3. Browser Navigation timeout
  4. Script time out 
How to take screenshot in Selenium? 
Selenium provides an interface called TakesScreenshot which has a method getScreenShotAs which can be used to take a screenshot of the application under test.

How to execute JavaScript in Selenium? How many arguments 
can be passed to executeScript method? 
Selenium webdriver API provides one interface called 
JavascriptExecutor with a method called executeScript. 
This method has 2 main arguments. 
First argument is the javascript code you want to execute on current page and second argument is optional but important. 
We can pass variable number of web elements as an arguments which can be manipulated in javascript code passed in the first argument.

How to handle multiple browser windows and frames?
We can easily work with multiple windows and frames by switching to them. 
We can find all open windows in selenium using getWindowhandles method. 
We can find frame in the web page using name, id or any other method like css or xpath selectors.

How to drag and drop in Selenium Webdriver? 
Selenium webdriver provides Actions class which has many methods to support complex user actions like contextClick, doubleClick, dragAndDrop. 

How to use Selenium Grid?
Selenium grid is used to execute selenium scripts on various environments (OS and browsers) simultaneously and on different machines. 
Hub acts as a central server which sends the execution requests to the other machines called as nodes. 
Hub server and node server must be up and running. 
Node machine must be registered with HUB. Depending upon the webdriver capabilities, HUB routes the request to appropriate node to execute the scripts.

Challenges, issues and limitations of Selenium tool? 

How to handle Captcha? 
We can not handle captcha in Selenium. We can not also automate 
the Adobe Flash contents on webpages. These are some of the limitations of Selenium.
Other common issues are –
  1. Certificate Errors in IE
  2. Protect mode error
  3. Browser zoom error in IE
  4. Canvas image map
  5. Unsupported command line flag – ignore certificates warning in Chrome
What is the page object model in Selenium? 
Page object model is an alternative way to handle automation project.

Write a complex xpath or css expression? Which one is better? 
xpath and css can be used to find any element on the web page.
 Most of the engineers prefer writing xpath expressions as finding r
elative elements is very easy in xpath.

How to upload files using AUTOIT Script, Robot?
We can use AUTOIT/Robot/Sikuli code to handle the window dialogs 
which are not supported by web driver.

Flash automation, silverlight Automation? 
Selenium has no support for these controls. We need to use third party tools to automate these apps.

How to format date and time in Selenium in Java? How to compare dates? 
We can format date in selenium using DateFormat object.

How to append a data to file in Selenium?
We can use File and FileWriter class to work with files in Selenium Webdriver.

Frameworks in Selenium – Data driven, Hybrid, Keyword, 

BDD – Cucumber, TestNG?
Frameworks are used to speed up the automation testing by 
developing the test data, reusable functions and reports.

Database testing in Selenium? 
We can use JDBC driver to connect to any database in Java.

How to work with Excel files in Selenium?

We can use JXL or POI library to work with excel files in Selenium.

Find total time of execution in Selenium? 
If we are using custom library, we can log the start and end time 
of the execution and then find the total execution time by 
subtracting end time from start time.

How to schedule the Test Suite Execution?
We can schedule the test suite execution using CI tools like 
hudson(Jenkins), Bamboo. Alternatively, we can use windows 
scheduler to launch the test execution.

How to send an email stating the execution status to all stakeholders in Selenium? 
We can send mail in Java using javax.mail library.

What is the difference between findElement and findElements?
findElement returns the first matching element. If element is not found, NoElementFoundException is thrown. findElements 
returns the list of matching web elements. 
If no element is found, empty list is returned. Exception is not thrown.

What is the difference between Junit and TestNG. What are the various annotations and features? 
TestNG is the new generation testing framework with lot of new 
useful features as compared to old Junit framework. 
Using TestNG, we can run the tests in parallel.

Automation of Android apps and Android Browsers using Selenium possible?

We can use  Appium and Selendroid tools to automate mobile applications.

How to handle Ajax calls in Selenium?
When working with Ajax calls, we must be very careful to handle StaleElementStateException. This exception occurs 
when we refer to the stale (Old) element on page. 
To handle this error, we need to find the element again after ajax load new elements in the page.

Difference between Selenium and QTP. Competitors to Selenium Webdriver? 
QTP is a licensed tool supporting automation of lot of applications based on .Net, Java, Web and much more. Selenium is a free tool and supports only web application automation testing.

What is desired capabilities?
Capabilities are used to set the values of the browser attributes 
before we launch any browser using selenium web driver.

Version control tools like SVN, GIT? 
We use version control tools like SVN to track the changes to 
the files in a project and work in collaboration.

Build tools – Ant, Maven? 
We use these tools to manage build activities for the Java project.

CI tools – Jenkin, Bamboo? 

These are continuous integration tools helping in quick 
deployment of applications, testing them and reporting the issues in the code before it is too late. 
It helps in getting the application into production quickly and with more quality confidence.

How to identify the frame which does not have Id as well as name? 

We can identify the frame using xpath or css selectors as well.

What is the alternative to sendkeys? 

We can use JavaScriptExecutor to work with html controls.

How to press TAB key in Selenium? 

We can press any keyboard key using Keys class.

What are the Exception that may occur in Selenium Webdriver 

Selenium may throw below exceptions.

  1. InvalidElementStateException
  2. StaleElementReferenceException
  3. ElementNotFoundException
  4. ElementNotVisibleException 

For any feedback, feel free to reach me. You can write to me at naveenanimation20@gmail.com

Subscribe to this channel, and press bell icon to get some interesting videos on Selenium and Automation:

Follow me on my Facebook Page:
Please follow and like us:

182 Comments

  1. sriram

    It's interesting that many of the bloggers to helped clarify a few things for me as well as giving.Most of ideas can be nice content.The people to give them a good shake to get your point and across the command.

    software testing course in chennai

  2. Unknown

    It is very useful information. It will help to improve my knowledge in Selenium. Thank you for sharing this awesome site.
    Selenium Training in Chennai | Selenium Training | Selenium Course in Chennai | Selenium Training Institute in Chennai

  3. Unknown

    Excellent information with unique content and it is very useful to know about the information based on blogs.
    Java training in chennai

  4. Unknown

    Yiioverflow presenting one of the best and high performance PHP framework. Fast, secure and extremely professionals are developing applications. We guide to implement mobile app development and SOA hybrid applications.Code in Nodejs, Angular,Ionic,ReactJS and Yiiframework.

  5. ajay

    Good informations It mayt be Helpfull for me thanks alot for sharing
    Learn Online DevOps Training
    Salesforce Online Training in Bangalore

  6. ajay

    Nice post keep do posting The Info was too good
    Best Amazon web Services Training Hyderabad
    Salesforce Online Training in Bangalore

  7. suvathi

    I think this is the best article today. Thanks for taking your own time to discuss this topic, I feel happy about that curiosity has increased to learn more about this topic. Keep sharing your information regularly for my future reference.
    Java Courses in chennai

  8. evergreensumi

    I wish to indicate because of you only to bail me out of this specific trouble. As a consequence of checking through the net and meeting systems that were not beneficial, I thought my life was finished.
    fire and safety engineering course in chennai

  9. Unknown

    Thanks for sharing with us, This article gives more useful information to me. Great post keep updating.
    Regards,
    Selenium Training in Chennai

  10. ANISHA

    Woww Thank you for the amazing information u have shared. that was very useful for me. do share more information.

    Click the link to know more exciting information.
    Selenium Training in chennai

  11. Unknown

    This content was very useful and informative. POst more information.
    You can also refer for more job related information

    Selenium Training and Placement

  12. Vicky Ram

    Wonderful post!!Thank you for sharing this info with us.
    Keep updating I would like to know more updates on this topic
    Very useful content, I would like to suggest this blog to my friends.

    Selenium training Chennai

    software testing selenium training

  13. Unknown

    I have read your blog completely. It is very impressive one for all the viewers. Thanks for sharing this blog.

    selenium training in chennai

  14. Unknown

    Nice post.Thank you so much for sharing.Yiioverflow is a web development company.We have well expert team in Angular JS, Ionic, Yii Framework, Node JS, Laravel, PHP, MySQL, and WordPress.If you want a developer visit.. https://yiioverflow.com/