Challenge - 5 Problems
FirefoxOptions 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 FirefoxOptions configuration code?
Consider the following Java Selenium code snippet configuring FirefoxOptions. What will be the value of the 'headless' option after execution?
Selenium Java
import org.openqa.selenium.firefox.FirefoxOptions; public class Test { public static void main(String[] args) { FirefoxOptions options = new FirefoxOptions(); options.setHeadless(true); options.addArguments("-private"); System.out.println(options.isHeadless()); } }
Attempts:
2 left
💡 Hint
Check the method used to set headless mode and the method to retrieve it.
✗ Incorrect
The method setHeadless(true) sets the FirefoxOptions to run in headless mode. The isHeadless() method returns true if headless mode is enabled.
❓ assertion
intermediate2:00remaining
Which assertion correctly verifies FirefoxOptions has the argument '-private'?
Given a FirefoxOptions object configured with addArguments("-private"), which assertion correctly checks this argument is present?
Selenium Java
FirefoxOptions options = new FirefoxOptions();
options.addArguments("-private");Attempts:
2 left
💡 Hint
Check how to verify a list contains a specific string.
✗ Incorrect
options.getProfile().getArguments() returns a set of strings. To check if '-private' is present, use contains() inside assertTrue.
❓ locator
advanced2:00remaining
Identify the best way to locate the Firefox binary path in FirefoxOptions
Which code snippet correctly sets the Firefox binary path to '/usr/bin/firefox' in FirefoxOptions?
Attempts:
2 left
💡 Hint
Check the expected parameter type for setBinary method.
✗ Incorrect
setBinary expects a FirefoxBinary object, which can be created with a File object pointing to the binary path.
🔧 Debug
advanced2:00remaining
Why does this FirefoxOptions code cause a compilation error?
Identify the error in the following code snippet:
Selenium Java
FirefoxOptions options = new FirefoxOptions(); options.addArguments(-private);
Attempts:
2 left
💡 Hint
Check the argument type passed to addArguments.
✗ Incorrect
The argument '-private' must be a string literal enclosed in quotes. Without quotes, it is treated as an undefined variable causing a compilation error.
❓ framework
expert3:00remaining
Which FirefoxOptions configuration will correctly enable headless mode and disable GPU acceleration for a Selenium test?
Select the code snippet that correctly configures FirefoxOptions to run headless and disable GPU acceleration.
Attempts:
2 left
💡 Hint
Check the correct method to enable headless mode and the correct argument syntax for disabling GPU.
✗ Incorrect
setHeadless(true) enables headless mode. The argument to disable GPU is '--disable-gpu' with two dashes. Option A uses both correctly.