0
0
Selenium Javatesting~20 mins

ChromeOptions configuration in Selenium Java - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
ChromeOptions Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2: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());
    }
}
AChromeOptions: {args=[]}
BChromeOptions: {args=[--headless, --disable-gpu]}
CChromeOptions: {args=[--disable-gpu, --headless]}
DChromeOptions: {args=[--headless]}
Attempts:
2 left
💡 Hint
The order of addArguments calls is preserved in the args list.
assertion
intermediate
2: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");
AassertTrue(options.getArguments().contains("--incognito"));
BassertTrue(options.toString().equals("--incognito"));
CassertTrue(options.getArguments().equals("--incognito"));
DassertTrue(options.getArguments().indexOf("incognito") > 0);
Attempts:
2 left
💡 Hint
Check the type returned by getArguments() and how to verify presence of an element.
🔧 Debug
advanced
2: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");
ABecause options is null and calling addArguments on null causes NullPointerException.
BBecause addArguments does not accept string arguments.
CBecause --start-maximized is not a valid Chrome argument.
DBecause ChromeOptions must be initialized with a WebDriver instance.
Attempts:
2 left
💡 Hint
Check the initialization of the options variable before method call.
framework
advanced
2: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.
A
ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-extensions");
options.setHeadless(false);
B
ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-extensions", "--headless");
C
ChromeOptions options = new ChromeOptions();
options.addArguments("headless", "disable-extensions");
D
ChromeOptions options = new ChromeOptions();
options.setHeadless(true);
options.addArguments("--disable-extensions");
Attempts:
2 left
💡 Hint
Use the setHeadless method to enable headless mode properly.
🧠 Conceptual
expert
2: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?
AIt sets the ChromeDriver to listen on port 9222 for WebDriver commands.
BIt disables all network connections except on port 9222.
CIt enables remote debugging on port 9222, allowing external tools to connect to Chrome for debugging.
DIt forces Chrome to use port 9222 for all HTTP requests.
Attempts:
2 left
💡 Hint
Think about what remote debugging means in browser context.