Selenium WebDriver Professional Standards & Competencies 3 β Questions and Answers
Question 1: A Selenium professional wants to ensure locators remain stable as the application evolves. Which attribute should be preferred when available?
- CSS class name shared across many elements
- Auto-generated numeric ID from the framework
- A dedicated `data-testid` attribute added by the development team (Correct answer)
- The element's visible text content
Correct answer: A dedicated `data-testid` attribute added by the development team
A `data-testid` attribute is added explicitly for testing purposes and is unlikely to change due to styling or structural refactors.
Question 2: What is the professional rationale for storing test configuration (URLs, credentials, timeouts) in environment variables rather than in test code?
- Environment variables execute faster than constants in code
- It separates configuration from code, enables environment-specific runs, and avoids committing secrets (Correct answer)
- Environment variables are required by Selenium Grid
- It allows skipping the build step when config changes
Correct answer: It separates configuration from code, enables environment-specific runs, and avoids committing secrets
Externalizing config supports running the same test suite against dev, staging, and production without code changes and keeps credentials out of version control.
Question 3: Which Selenium WebDriver approach best demonstrates professional handling of asynchronous page content?
- Using Thread.sleep(5000) as a universal wait
- Applying explicit WebDriverWait with an ExpectedCondition for the specific element state needed (Correct answer)
- Polling document.readyState in a loop
- Disabling JavaScript in the browser profile
Correct answer: Applying explicit WebDriverWait with an ExpectedCondition for the specific element state needed
Explicit waits target exactly the condition required and adapt to actual page behavior, minimizing both false failures and wasted wait time.
Question 4: A team is onboarding junior engineers to the Selenium suite. Which practice best supports knowledge transfer and maintainability?
- Write complex one-liners to minimize file count
- Use consistent naming conventions, Page Objects, and README documentation for setup (Correct answer)
- Grant only senior engineers write access to the test repo
- Store all helper logic in a single 3,000-line utility class
Correct answer: Use consistent naming conventions, Page Objects, and README documentation for setup
Naming conventions, POM structure, and documentation lower the barrier for new contributors and reduce onboarding time.
Question 5: What is the professional purpose of running Selenium tests against multiple browsers (cross-browser testing)?
- To satisfy a checklist requirement with no practical value
- To verify that application behavior is consistent across environments users actually operate in (Correct answer)
- To increase total test count for reporting purposes
- To test Selenium's internal browser drivers
Correct answer: To verify that application behavior is consistent across environments users actually operate in
Real users work on different browsers, and cross-browser testing catches rendering or JavaScript differences that could degrade their experience.
Question 6: A Selenium engineer is reviewing a colleague's pull request that introduces 200 new tests with no assertions, only navigation steps. What should be flagged?
- The tests will run too slowly
- Without assertions, the tests verify nothing and provide false confidence (Correct answer)
- Navigation steps are not valid Selenium operations
- The tests should use CSS selectors, not XPath
Correct answer: Without assertions, the tests verify nothing and provide false confidence
Tests without assertions cannot detect failures; they will always pass even when the application is broken, providing a false sense of coverage.
Question 7: Which version control practice is considered professional when maintaining a Selenium test repository?
- Committing directly to main after every test run
- Using feature branches, peer-reviewed pull requests, and meaningful commit messages (Correct answer)
- Keeping all tests in a single file to minimize repository complexity
- Deleting old test files to reduce repository size
Correct answer: Using feature branches, peer-reviewed pull requests, and meaningful commit messages
Feature branches and peer-reviewed PRs ensure quality control, catch issues early, and provide a clear history of changes to the test suite.
A Selenium professional wants to ensure locators remain stable as the application evolves.
Which attribute should be preferred when available?