Challenge - 5 Problems
ChromeDriver Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this Selenium WebDriver setup code?
Consider the following Java code snippet for setting up ChromeDriver. What will be the result when this code runs?
Selenium Java
import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class TestSetup { public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver"); WebDriver driver = new ChromeDriver(); driver.get("https://example.com"); System.out.println(driver.getTitle()); driver.quit(); } }
Attempts:
2 left
💡 Hint
Check if the driver path is set and the driver instance is created properly.
✗ Incorrect
The code sets the system property for ChromeDriver, creates a new ChromeDriver instance, navigates to the URL, prints the page title, and then quits the browser cleanly.
❓ assertion
intermediate1:30remaining
Which assertion correctly verifies the page title after ChromeDriver navigation?
You want to check that after navigating to "https://example.com", the page title is exactly "Example Domain". Which assertion is correct in Java with JUnit?
Selenium Java
WebDriver driver = new ChromeDriver(); driver.get("https://example.com"); // Which assertion below is correct?
Attempts:
2 left
💡 Hint
Use the proper method to compare strings in Java assertions.
✗ Incorrect
assertEquals compares the expected string with the actual title correctly. Using '==' compares references and is incorrect for strings.
❓ locator
advanced1:30remaining
Which locator strategy is best for finding a button with id 'submitBtn' in Selenium?
You want to locate a button element with the id attribute 'submitBtn'. Which locator is the best practice in Selenium WebDriver Java?
Attempts:
2 left
💡 Hint
Id is unique and fastest locator.
✗ Incorrect
Using By.id is the fastest and most reliable way to locate an element by its unique id attribute.
🔧 Debug
advanced2:00remaining
Why does this ChromeDriver setup code throw an exception?
Review the code below. It throws an IllegalStateException at runtime. What is the cause?
Selenium Java
import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class Test { public static void main(String[] args) { WebDriver driver = new ChromeDriver(); driver.get("https://example.com"); driver.quit(); } }
Attempts:
2 left
💡 Hint
Check if the driver executable path is configured before creating ChromeDriver.
✗ Incorrect
Without setting the system property 'webdriver.chrome.driver' to the chromedriver executable path, ChromeDriver cannot start and throws IllegalStateException.
❓ framework
expert2:30remaining
Which setup method correctly initializes ChromeDriver for parallel test execution in JUnit 5?
You want to run Selenium tests in parallel using JUnit 5. Which setup method ensures each test gets its own ChromeDriver instance safely?
Attempts:
2 left
💡 Hint
Each test needs its own driver instance to avoid conflicts in parallel runs.
✗ Incorrect
@BeforeEach creates a new ChromeDriver instance before every test method, ensuring thread safety. @BeforeAll runs once for all tests, causing shared driver issues.