Selenium Junior interview questions and answers

75 questions for a Selenium (Junior) interview - with correct answers, explanations and links to the docs.

  1. 1.What is Selenium WebDriver?
  2. 2.What does a browser driver like chromedriver do?
  3. 3.What does Selenium Manager (Selenium 4.6+) solve?
  4. 4.How do you open a page in Selenium Java?
  5. 5.What does driver.quit() do compared to driver.close()?
  6. 6.Which locator is usually the most stable choice?
  7. 7.What does By.cssSelector("button.primary") find?
  8. 8.What can XPath do that CSS selectors can't?
  9. 9.What's wrong with this XPath?
  10. 10.What's the difference between findElement and findElements?
  11. 11.What does element.sendKeys("text") do?
  12. 12.What does element.getText() return?
  13. 13.What is an implicit wait?
  14. 14.What is an explicit wait?
  15. 15.Why is Thread.sleep(3000) a bad wait in Selenium tests?
  16. 16.What does NoSuchElementException mean?
  17. 17.What does StaleElementReferenceException mean?
  18. 18.What does ElementClickInterceptedException usually mean?
  19. 19.How do you work with an element inside an iframe?
  20. 20.How do you switch to a new tab that the app opened?
  21. 21.How do you accept a JavaScript alert?
  22. 22.How do you pick an option in a <select> element?
  23. 23.What is the Actions API used for?
  24. 24.What is the Page Object pattern?
  25. 25.Should page objects contain assertions?
  26. 26.How do you run Chrome without a visible window?
  27. 27.What does driver.manage().window().setSize(...) help test?
  28. 28.How do you take a screenshot in Selenium Java?
  29. 29.What is Selenium Grid?
  30. 30.What is RemoteWebDriver used for?
  31. 31.What does JavascriptExecutor.executeScript let you do?
  32. 32.Why is clicking with JavaScript instead of click() risky in tests?
  33. 33.What does isDisplayed() check?
  34. 34.What is a relative locator in Selenium 4?
  35. 35.How do you read a cookie in Selenium?
  36. 36.Why can adding a session cookie speed up UI tests?
  37. 37.What is a flaky test?
  38. 38.Where should test data like users come from in UI tests?
  39. 39.What do TestNG and JUnit add to a Selenium project?
  40. 40.What is the right place to start and stop the browser in tests?
  41. 41.What does driver.getTitle() return?
  42. 42.How do you go back in browser history?
  43. 43.Why do tests fail when an element is inside a shadow DOM?
  44. 44.What does ExpectedConditions.visibilityOfElementLocated wait for?
  45. 45.Why should locators not depend on visible text in multi-language apps?
  46. 46.What does Selenide add on top of Selenium?
  47. 47.What is Allure used for in Selenium projects?
  48. 48.What does Cucumber with Gherkin give a Selenium project?
  49. 49.What should a test do after a failing assertion in teardown?
  50. 50.How do you check that an element is NOT on the page without waiting a long time?
  51. 51.What does clear() do on an input field?
  52. 52.Why do tests need a fixed window size in CI?
  53. 53.What does submit() do on a form element?
  54. 54.What does the W3C WebDriver standard mean for Selenium?
  55. 55.How do you upload a file through an <input type="file">?
  56. 56.Why should tests avoid driver.manage().timeouts().implicitlyWait with a long value and explicit waits together?
  57. 57.What does getAttribute("href") return on a link?
  58. 58.What is a good assertion after clicking 'Save'?
  59. 59.What does driver.switchTo().defaultContent() do?
  60. 60.Why keep locators in page objects and not in test methods?
  61. 61.What is the Screenplay pattern?
  62. 62.What happens if two tests share one browser session in parallel?
  63. 63.How can tests check a page in Firefox as well as Chrome?
  64. 64.What does Keys.ENTER in sendKeys(Keys.ENTER) do?
  65. 65.What is a good reason to keep UI tests few and focused?
  66. 66.What does getCssValue("color") return?
  67. 67.How do you hover over a menu to open it?
  68. 68.Why log the browser console in UI test failures?
  69. 69.What is the benefit of data-testid-style attributes?
  70. 70.What does driver.getPageSource() return?
  71. 71.What is a common cause of TimeoutException in explicit waits?
  72. 72.What is the main purpose of the By class?
  73. 73.What does driver.navigate().refresh() do?
  74. 74.What does By.linkText("Sign in") find?
  75. 75.Why should each UI test be independent of the others?