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