Challenge - 5 Problems
ChromeOptions 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 ChromeOptions configuration code?
Consider the following Java Selenium code snippet configuring ChromeOptions. What will be the value of
options.toString() after execution?Selenium Java
import org.openqa.selenium.chrome.ChromeOptions; public class Test { public static void main(String[] args) { ChromeOptions options = new ChromeOptions(); options.addArguments("--headless"); options.addArguments("--disable-gpu"); System.out.println(options.toString()); } }
Attempts:
2 left
💡 Hint
The order of addArguments calls is preserved in the args list.
✗ Incorrect
The ChromeOptions object stores arguments in the order they are added. Here, '--headless' is added first, then '--disable-gpu'. The toString method reflects this order.
❓ assertion
intermediate2:00remaining
Which assertion correctly verifies that ChromeOptions has the 'incognito' argument?
Given a ChromeOptions object
options with arguments added, which assertion correctly checks that '--incognito' is present in the arguments list?Selenium Java
import org.openqa.selenium.chrome.ChromeOptions; import static org.junit.jupiter.api.Assertions.assertTrue; ChromeOptions options = new ChromeOptions(); options.addArguments("--incognito");
Attempts:
2 left
💡 Hint
Check the type returned by getArguments() and how to verify presence of an element.
✗ Incorrect
The getArguments() method returns a List. Using contains("--incognito") correctly checks if the argument is present. Other options either compare to a string or use incorrect methods.
🔧 Debug
advanced2:00remaining
Why does this ChromeOptions code cause a runtime error?
Examine the following code snippet. Why does it throw a NullPointerException at runtime?
Selenium Java
ChromeOptions options = null;
options.addArguments("--start-maximized");Attempts:
2 left
💡 Hint
Check the initialization of the options variable before method call.
✗ Incorrect
The variable options is null, so calling any method on it causes a NullPointerException. The other options are incorrect because addArguments accepts strings, the argument is valid, and ChromeOptions does not require WebDriver to initialize.
❓ framework
advanced2:00remaining
Which ChromeOptions configuration disables extensions and runs in headless mode?
Select the correct Java Selenium ChromeOptions code snippet that disables browser extensions and runs Chrome in headless mode.
Attempts:
2 left
💡 Hint
Use the setHeadless method to enable headless mode properly.
✗ Incorrect
Option D correctly uses setHeadless(true) to enable headless mode and adds the argument to disable extensions. Option D incorrectly passes two arguments in one call (which is invalid), C misses the required '--' prefix, and D disables extensions but sets headless to false.
🧠 Conceptual
expert2:00remaining
What is the effect of adding '--remote-debugging-port=9222' in ChromeOptions?
In Selenium ChromeOptions, what does adding the argument '--remote-debugging-port=9222' do?
Attempts:
2 left
💡 Hint
Think about what remote debugging means in browser context.
✗ Incorrect
The '--remote-debugging-port=9222' argument opens a debugging port on Chrome that external tools like DevTools or other debuggers can connect to. It does not affect WebDriver commands or network restrictions.