Selenium Middle interview questions and answers
75 questions for a Selenium (Middle) interview - with correct answers, explanations and links to the docs.
- 1.What does
FluentWaitadd over a basicWebDriverWait? - 2.How do you wait for a custom condition, e.g. a counter showing 5?
- 3.Why can
@FindByfields withPageFactorycause stale element errors? - 4.What is a page component (or fragment) object?
- 5.What does a fluent page object method return after navigation?
- 6.Where should the constructor of a page object check that it's on the right page?
- 7.What is the purpose of a driver factory?
- 8.How do you run Selenium tests in parallel with TestNG?
- 9.What are the main parts of Selenium Grid 4?
- 10.Why are official Selenium Docker images popular for Grid?
- 11.What are capabilities in WebDriver?
- 12.What does WebDriver BiDi enable that classic WebDriver couldn't?
- 13.How can a Selenium 4 test fail when the page logs a JavaScript error?
- 14.How do you test a file download in Chrome with Selenium?
- 15.What does the page load strategy
eagerchange? - 16.What does
ElementNotInteractableExceptionusually mean? - 17.A sticky header covers the button the test clicks. What helps?
- 18.How do you find a table cell next to a row label with XPath?
- 19.Which XPath handles a button whose id changes, like
save-8842? - 20.Why does HTML5 drag and drop often fail with
Actions.dragAndDrop? - 21.How do you take a screenshot of just one element?
- 22.What are soft assertions good for in UI tests?
- 23.Why log in through the API and inject cookies instead of using the login form in every test?
- 24.How do you set a value in localStorage from a test?
- 25.What should happen between tests that reuse the same browser?
- 26.How do you test an infinite-scroll list?
- 27.How should a test handle a custom date picker?
- 28.What does
Select.isMultiple()tell you? - 29.How do you send Ctrl+A to an input?
- 30.Why add Allure steps and attachments to Selenium tests?
- 31.What is a risk of a TestNG retry analyzer for UI tests?
- 32.Why prefer explicit waits for a specific state over waiting for 'page load'?
- 33.How do you wait until a loading spinner disappears?
- 34.What is the main benefit of running Grid nodes in containers?
- 35.What does
driver.manage().timeouts().scriptTimeout(...)control? - 36.How can Selenium 4 emulate a user's location?
- 37.What changed for capabilities when moving from Selenium 3 to 4?
- 38.What does Selenide's
shouldHave(text("Saved"))do? - 39.How do you read all rows of an HTML table into a list?
- 40.Why do tests sometimes pass locally but fail in headless CI?
- 41.What's a safe way to deal with a cookie-consent banner in tests?
- 42.How do you get the text of an input the user typed into?
- 43.What's the risk of very long implicit waits in a suite?
- 44.How do you test a site in a specific language with Chrome?
- 45.Why should page methods not return raw
WebElements to tests? - 46.What is a good use of the
@BeforeMethodhook in TestNG UI tests? - 47.Why does
alwaysRun = truematter on TestNG teardown methods? - 48.How do you verify a link opens in a new tab without following it?
- 49.What's a reasonable approach to visual checks in Selenium suites?
- 50.How do you handle an HTML modal dialog (not a JS alert)?
- 51.Why should locators avoid CSS classes generated by build tools like
css-1x9k2? - 52.What does running tests on several browsers in Grid at once require?
- 53.How do you test that a button becomes enabled after filling a form?
- 54.What does
driver.switchTo().newWindow(WindowType.TAB)do? - 55.Why may tests in Firefox behave differently from Chrome for the same locator?
- 56.What is a good way to make a flaky UI test deterministic?
- 57.How do you open a page with HTTP basic auth in Selenium 4 Chromium?
- 58.Why is reading the table text with one
getText()and splitting it fragile? - 59.What's the role of a base page class in a framework?
- 60.Why save page source and screenshots on every failure?
- 61.How do you check that a downloaded PDF has the right name?
- 62.What does
ExpectedConditions.frameToBeAvailableAndSwitchToItdo? - 63.How do you handle nested iframes?
- 64.Why prefer API calls for test data setup over UI steps?
- 65.What is the trade-off of using Cucumber on top of Selenium?
- 66.How do you test a tooltip that appears on hover?
- 67.What should happen to the driver when a test is interrupted by a timeout?
- 68.Why may
click()on a link in a hidden menu fail on mobile widths? - 69.What's a good naming practice for UI test methods?
- 70.What does
ExpectedConditions.refreshed(...)help with? - 71.Why keep the WebDriver version and the browser version in sync?
- 72.What is a good way to check text that loads with a delay?
- 73.How do you scroll to an element with the Selenium 4 Actions API?
- 74.Why should a UI test framework capture the browser and driver versions in reports?
- 75.What does
getDomProperty("checked")return for a checkbox?