QA Interview Hub · Knowledge base · Quizzes · Українська
All topics
Selenium + Java interview questions
40 questions on Selenium + Java, from the basics to the hard ones. Answers and explanations are in the quiz and the knowledge base.
By level: Junior QA interview questions · Middle QA interview questions · Senior QA interview questions
WebDriver: architecture and drivers
- What is Selenium WebDriver? Junior
- What role does chromedriver play when a test runs? Junior
- What is the difference between driver.close() and driver.quit()? Junior
- A test fails with SessionNotCreatedException: "This version of ChromeDriver only supports Chrome version N". The project uses a current Selenium 4, yet the code has System.setProperty("webdriver.chrome.driver", ...). What most likely needs to be done? Middle
- What is the right way to pass browser settings (headless, window size) in Selenium 4? Middle
- A CI runner without internet access fails on new ChromeDriver(). What should be done? Middle
- driver.get() hangs on a page where a third-party widget loads forever, although the needed button is already there. What fits? Middle
- Why can classic WebDriver not simply "subscribe" to browser console errors while BiDi can? Senior
Take the quiz for this chapter · Read the explanation in the knowledge base
Locators and waits
- Developers added data-testid="pay" to a button. Which locator is the most stable? Junior
- What happens if you call driver.findElements(By.id("error")) and there is no such element on the page? Junior
- When is XPath a better choice than a CSS selector? Junior
- How does an explicit wait differ from an implicit wait? Junior
- Why does the Selenium documentation advise against mixing implicit and explicit waits? Middle
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
new WebDriverWait(driver, Duration.ofSeconds(15))
.until(ExpectedConditions.visibilityOfElementLocated(By.id("result")));
- After a list refresh, a click on a previously found element throws StaleElementReferenceException. What does it mean and what to do? Middle
- What does the near relative locator mean in Selenium 4? Middle
WebElement label = driver.findElement(
RelativeLocator.with(By.tagName("span")).near(By.id("price")));
- Clicking "Pay" sometimes throws ElementClickInterceptedException: a spinner briefly appears over the button. What is the most correct fix? Middle
Take the quiz for this chapter · Read the explanation in the knowledge base
Page Object
- What is the main benefit of Page Object? Junior
- Where do Selenium recommendations place assertions? Junior
- Following the Selenium recommendations, what does a Page Object method return when another page opens after it? Middle
public ??? loginAs(String user, String pass) {
// fill the form, click submit
}
- Why do teams move away from PageFactory with @FindBy? Middle
- Why extract a site header or a table into a separate component in Page Object? Middle
- A Page Object keeps in a field a WebElement found in the constructor. What is the risk? Middle
- BasePage declares a static WebDriver driver and the tests run in parallel. What goes wrong? Senior
Take the quiz for this chapter · Read the explanation in the knowledge base
Framework and runs
- What is the JUnit 5 equivalent of the TestNG annotation @BeforeMethod? Junior
- How do you run one test with a set of inputs in JUnit 5, like @DataProvider in TestNG? Middle
- How do you enable parallel test execution in JUnit 5? Middle
- The class runs from a testng.xml with parallel="methods" thread-count="4". What is most likely to happen? Middle
public class CartTest {
private WebDriver driver;
@BeforeMethod
public void setUp() {
driver = new ChromeDriver();
}
@Test
public void addsItem() { driver.get(CART_URL); /* ... */ }
@Test
public void removesItem() { driver.get(CART_URL); /* ... */ }
@AfterMethod
public void tearDown() {
driver.quit();
}
}
- Which deployment modes does Selenium Grid 4 have? Middle
- A selenium/standalone-chrome container crashes on heavy pages. What should be checked first? Middle
docker run -d -p 4444:4444 selenium/standalone-chrome
- All Grid 4 slots are busy and new tests are left without a session. Which part of Grid holds them until a slot frees up? Senior
- The team added an automatic retry of failed tests and the suite turned green. Which approach is right? Senior
Take the quiz for this chapter · Read the explanation in the knowledge base
Stability and debugging
- What is Allure used for in a Selenium project? Middle
- Why is Thread.sleep(5000) after a click a bad waiting practice? Junior
- What is the most convenient way to save a screenshot only for failed tests in JUnit 5? Middle
- A test passes alone but fails within the full suite. What should be checked first? Middle
- How do you hover over a menu item in Selenium so a submenu opens? Middle
- How do you upload a file into a form with <input type="file">? Middle
- After a click a new tab opened, but findElement searches on the old one. What needs to be done? Middle
- The button is visible on the page, but findElement throws NoSuchElementException. It is inside an iframe. What to do? Middle
- A new project must catch console errors and network requests in Chrome and Firefox. What to choose? Senior
Take the quiz for this chapter · Read the explanation in the knowledge base