Top 20 Advanced Selenium Webdriver Coding Interview Questions of 2019

Question 1 - How to handle Alerts or Pop-Ups using Selenium Webdriver?

Answer - Alerts or javascript pop-ups can be handled by using commands of org.openqa.selenium.Alert class in Selenium Webdriver. 
Read details - Alert Handling
Answer - Multiple browser tabs can be handled using Keys enumerator and switchTo() method. 

Question 3 - How to Achieve Code Reuseablity & Maintainablility in Selenium Code?

Answer - Code re-usability can be achieved by creating page methods (action methods) and use those methods in your test method code instead of direct selenium commands.

Question 4 - How to Handle Dynamic Web Table in Selenium WebDriver?

Answer - We can handle dynamic web table by preparing dynamic xpath of table at runtime. 
Read details - Handle Dynamic Table

Question 5 - How to Extract Table Data/Read Table Data Using Selenium WebDriver?

Answer - We can extract table data by preparing dynamic xpath of table at runtime. 
Read details - Extract Table Data

Question 6 - How to Take Partial Screenshot in Selenium Webdriver?

Answer - Partial screenshot can be taken by using org.openqa.selenium.Point class of Selenium. We can get height and width of the element by using Point class. 
Read details - Take Partial Screenshot

    Question 7 - How to take screenshot in Selenium Webdriver?

    Answer - Screenshot can be taken by using org.openqa.selenium.TakesScreenshot class of Selenium.

    Question 8 - What is Actions class? What are its commands?

    Answer - Actions class is used to handle Keyboard and Mouse Events. You need to import org.openqa.selenium.interactions.Actions in order to use Actions class.

    Question 9 - How to upload a file in Selenium Webdriver?

    Answer - Selenium can't directly interact with window dialogues but we can interact with them by keyboard interactions using Selenium's Keys class or Java's Robot class.

    Question 10 - How to do Mouse hover in Selenium Webdriver?

    Question 11 - What is TestNG? How it can be integrated with Selenium?

    Question 12 - How to create setup and teardown methods in TestNG?

    Question 13 - What is the difference b/w @BeforeClass, @BeforeMethod and @AfterClass, @AfterMethod in TestNG?

    Question 14 How to set priority of test methods in TestNG?

    Question 15 - How to scroll vertically and horizontally using Selenium Webdriver?

    Answer - Scroll can be done in selenium using org.openqa.selenium.JavascriptExecutor

    Example - 

       // Create object of JavascriptExecutor
      JavascriptExecutor js = (JavascriptExecutor) driver;
      // Vertical Scroll
      // Horizontal Scroll

    Question 16 How to download file using Selenium Webdriver?

    Answer - You can download a file using Robot class.

    Example -

      /* Download file by clicking on Save button of window dialog

     // Create object of Robot class
     Robot r = new Robot();  
     // Press Alt and S key, it will shift the focus to 'Save' button of Windows dialog
     // Now, release S and Alt key
     // Press Enter Key as Focus is on Save button, so it will be 
     // Release Enter key

    Question 17 How to switch to Nth browser window in Selenium Webdriver?

    Answer - Code example -

    Case 1:

     // Create a Set and store all window handle ids in it
     Set AllWindowHandles = driver.getWindowHandles();
     String window1 = (String) AllWindowHandles.toArray()[0];
     String window2 = (String) AllWindowHandles.toArray()[1];
     // Switch to window with id 2
    Case 2 :
     /* Moving Between all Windows
     for (String handle : driver.getWindowHandles()) {

    Question  18 - How to handle ajax elements using Selenium Webdriver?

    Answer - When we do Google search and a list of options matching to our keyword displayed on it's own without refreshing the page, is an example of ajax search. We can handle ajax elements using Explicit Wait in Selenium.

    Question  19 - How to switch frames in Selenium Webdriver?

    Answer - Code example -

      // Move to frame
     driver.switchTo().frame("Target Web element")


    Question  20 - How to find broken links of a web page using Selenium Webdriver?


    1. The information which you have provided is very good. It is very useful who is looking for selenium interview questions

    2. Great blog thanks for sharing Instagram and Facebook have provided an amazing place for new brands to grow and flourish. We can find the perfect niche for your brand on the best social media marketing in chennai. Marketing through social media brings forth global audience without all these physical boundaries.

    3. Nice blog thanks for sharing Run your salon business successfully by tying up with the best beauty shop in Chennai - The Pixies Beauty Shop. With tons of prestigious brands to choose from, and amazing offers we’ll have you amazed.

    4. Excellent blog thanks for sharing Set up a aesthetic work environment that employees love to spend time in and relieve their stress. Your company needs the best corporate gardening service in Chennai and Karuna Nursery Gardens in happy to oblige you in the endeavour to make your infrastructure something worth flaunting about.


    Post a Comment

    Popular Posts

    Top 10 Demo Websites to Practice Selenium Webdriver Online

    REST API Tutorial - Manual Testing of APIs using Postman

    REST API Automation Tutorial using Postman

    Selenium WebDriver - Browser and Navigation Commands