Top 40 Selenium WebDriver Interview Questions & Answers

1. What is Selenium WebDriver?

  • Selenium Webdriver is an open-source test tool
  • Supports cross-browser testing
  • Supports scripting in multiple programming languages
  • Supports platform compatibility
  • Interacts directly with the web browser
  • Supports headless browser testing

Top 40 Selenium WebDriver Interview Questions & Answers2. What are the platforms supported by Selenium Webdriver?

  • Windows
  • Mac OS
  • Linux

3. What are the different browsers supported by Selenium Webdriver

  • Chrome
  • Internet Explorer
  • Safari
  • Firefox
  • Opera
  • HtmlUnit (Headless)
  • PhantomJS (Headless)

Note: Headless browser is a web browser without Graphical User Interface, so one cannot see the test execution on screen. 

4. What are the different programming languages supported by Selenium Webdriver?

  • JAVA
  • C#
  • Ruby
  • Python
  • PHP
  • JavaScript
  • Perl

5. Name any 3 limitations of Selenium WebDriver.

  • Supports only web-based application testing
  • Record and playback option is not available
  • Captcha and barcode readers cannot be tested

6. What are the different types of locators in Selenium?

Locators are used to identify web elements within the webpage. There are 8 different types of locators in Selenium.

  • ID
  • Name
  • ClassName
  • TagName
  • LinkText
  • PartialLinkText
  • CSS Selector
  • XPath

7. What is the command used to launch a browser?

WebDriver driver = new ChromeDriver(); // launch Chrome browser

WebDriver driver = new SafariDriver(); // launch Safari browser

WebDriver driver = new InternetExplorerDriver(); // launch IE browser

WebDriver driver = new FirefoxDriver(); // launch Firefox browser

WebDriver driver = new OperaDriver(); // launch Opera browser

WebDriver driver = new HtmlUnitDriver(); // launch headless browser

8. What is the command to launch an URL?


9. What is the command used to get the current page URL?


10. What is the command to get the webpage title?


11. What is the command to type values in a textbox?


12. What is the command to get the text values ?


13. What is the command to clear values in a textbox?


14. What is the command to click a control?


15. What is the command to maximize a browser window?


Note: Selenium does not have any built-in function for minimizing the browser window! 

16. What is the command to click on a hyperlink?

driver.findElement(By.linkText("Defect tool")).click();

driver.findElement(By.partialLinkText("Defect to")).click();

17. What is the command to find if an element is displayed on a screen?


18. What is the command to verify if a checkbox/radio is selected?


19. What is the command to verify if a button is enabled?


20. What is the command to verify if a particular text is present on the webpage?


21. What are the different commands used for a dropdown list?


Select value = new Select(driver.findElement("marital_status")));



Select index = new Select(driver.findElement("marital_status")));



Select text = new Select(driver.findElement("marital_status")));



Select value = new Select(driver.findElement("marital_status")));



Select index = new Select(driver.findElement("marital_status")));



Select text = new Select(driver.findElement("marital_status")));



Select text = new Select(driver.findElement("marital_status")));


22. Name any 4 commonly used Assertions in Selenium?

  • Assert.assertEquals
  • Assert.assertNotEquals
  • Assert.assertTrue
  • Assert.assertFalse

23. What are the different navigation commands?

driver.navigate().back(); // Takes you one page backward based on browser's history

driver.navigate().forward(); // Takes you one page forward based on browser's history

driver.navigate().refresh(); // Refresh your current page

driver.navigate().to(""); // Takes you to new webpage

Note: driver.navigate().to(“”) and driver.get(“”) does the same thing! Both are same!!

24. What is the command to right click?

WebElement loginBtn = driver.findElement("loginBtn"));

Actions rightClick = new Actions(driver); // Actions Class is used

rightClick.contextClick(loginBtn); // contextClick is the method

25. What is the command to mouse hover?

WebElement loginBtn = driver.findElement("loginBtn"));

Actions move = new Actions(driver); // Actions Class is used

move.moveToElement(loginBtn); // moveToElement is the method

26. What is the command to double-click?

WebElement loginBtn = driver.findElement("loginBtn"));

Actions doubleClk = new Actions(driver); // Actions Class is used

doubleClk.doubleClick(loginBtn); // doubleClick is the method

27. What is the command used to scroll down to a web element?

WebElement loginBtn = driver.findElement("loginBtn"));

JavascriptExecutor js = (JavascriptExecutor) driver;

js.executeScript("arguments[0].scrollIntoView();", loginBtn);

28. What is the command to drag and drop?

WebElement sourceTarget = driver.findElement("loginBtn"));

WebElement destinationTarget = driver.findElement("submitbtn"));

Actions drgDrp = new Actions(driver); // Actions Class is used

drgDrp.dragAndDrop(sourceTarget, destinationTarget); // dragAndDrop is the method

29. What is the command used to get the attribute values of an element?


30. What is the command used to get the CSS properties of a web element?







31. How to handle alert pop-ups?Alert

driver.switchTo().alert().accept(); // To click OK option or to accept the alert pop-up

driver.switchTo().alert().dismiss(); // To click Cancel option or to dismiss the alert pop-up

driver.switchTo().alert().getText(); // To get the alert pop-up text message

driver.switchTo().alert().sendKeys("Hello"); // To type values in the alert textbox

32. What is the difference between findElement() and findElements()?

  • findElement() – Finds the first matching element in the DOM & returns a single element.
  • findElements() – Finds all the matching elements in the DOM & returns a list of elements.

Note: findElements() will not throw an exception if an element is not found. It just returns the list size as zero, whereas findElement() will throw element not found exception. 

33. What is the difference between driver.close() and driver.quit()?

  • driver.close() – Used to close current active browser window
  • driver.quit() – Used to close all browser windows

34. What are the two types of waits available in Selenium Webdriver?

  • Implicit Wait – Used to provide default wait between every consecutive test steps. It’s applicable for the entire driver instance. Example below,
WebDriver driver = new FirefoxDriver();

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); // waits for 10 seconds irrespectively before actions


WebElement search = driver.findElement("searchTextbox"));
  • Explicit Wait – Used to halt the execution for a certain amount of time until certain conditions are met. It’s applicable for a particular instance only. Example below,
WebDriverWait wait = new WebDriverWait(driver, 20); // wait for 20 seconds until the element becomes clickable

WebElement element = wait.until(ExpectedConditions.elementToBeClickable("loginBtn")));

35. How to handle iFrames?

driver.switchTo().frame(3); // Based on index

driver.switchTo().frame("myframe"); // Based on name or ID

driver.switchTo().frame(WebElement); // Based on WebElement

driver.switchTo().parentFrame(); // Switching to parent frame

driver.switchTo().defaultContent(); // switching to the main frame

36. Name any two testing frameworks that can be integrated with Selenium Webdriver?

  • JUnit
  • TestNG

37. Name any two build management tools that can be integrated with Selenium Webdriver?

  • Gradle
  • Maven

38. What software do you need to run Selenium Webdriver in JAVA?

  • Eclipse or IntelliJ IDE
  • Gradle or Maven build tool
  • Junit or TestNG testing framework
  • Selenium WebDriver library
  • Browser Drivers (Chrome, IE, Safari, Firefox etc.,)

39. Name any advanced framework design that can be used with Selenium Webdriver?

  • Cucumber (BDD)
  • Page Object Model
  • Log4j
  • Data-driven testing
  • Dependency Injection (Example: Pico Container, Google Guice)
  • Object Repository

40. Name any 5 Exceptions that you got while working with Selenium Webdriver.

  • ElementNotVisibleException
    • Throws when an element is present on DOM page, but not visible to interact
  • StaleElementReferenceException
    • Throws when an element is not present on DOM page
  • NoAlertPresentException
    • Throws when an alert is not presented on the screen
  • NoSuchAttributeException
    • Throws when an attribute of an element is missing
  • NoSuchElementException
    •  Throws when an element is not found

Thanks for reading 🙂 All the Best!

Suggested Readings : Top 30 Cucumber Interview Questions & Answers

Know anyone who is preparing for Selenium Interview?  Help your friends by sharing this article on Facebook, Twitter, or Google Plus.

2 thoughts on “Top 40 Selenium WebDriver Interview Questions & Answers”
  1. Thank you so much mam and I can not even make you understand that how much helpful these are for me. I have never found such organize and easy to understand interview questions 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

Discover more from Letzdotesting

Subscribe now to keep reading and get access to the full archive.

Continue reading