0
0
Selenium Javatesting~20 mins

FirefoxOptions configuration in Selenium Java - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
FirefoxOptions 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 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());
    }
}
Atrue
Bfalse
Cnull
DCompilation error
Attempts:
2 left
💡 Hint
Check the method used to set headless mode and the method to retrieve it.
assertion
intermediate
2: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");
AassertNull(options.getProfile().getArguments());
BassertEquals(options.getProfile().getArguments(), "-private");
CassertFalse(options.getProfile().getArguments().isEmpty());
DassertTrue(options.getProfile().getArguments().contains("-private"));
Attempts:
2 left
💡 Hint
Check how to verify a list contains a specific string.
locator
advanced
2: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?
Aoptions.setBinary("/usr/bin/firefox");
Boptions.setBinary(new File("/usr/bin/firefox"));
Coptions.setBinary(new FirefoxBinary(new File("/usr/bin/firefox")));
Doptions.setBinary("firefox", "/usr/bin/firefox");
Attempts:
2 left
💡 Hint
Check the expected parameter type for setBinary method.
🔧 Debug
advanced
2: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);
AThe code is correct and compiles without error.
BMissing quotes around '-private' causes a compilation error.
CCannot assign FirefoxOptions to options variable without import.
DaddArguments method does not exist in FirefoxOptions.
Attempts:
2 left
💡 Hint
Check the argument type passed to addArguments.
framework
expert
3: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.
A
FirefoxOptions options = new FirefoxOptions();
options.setHeadless(true);
options.addArguments("--disable-gpu");
B
FirefoxOptions options = new FirefoxOptions();
options.addArguments("--headless", "--disable-gpu");
C
FirefoxOptions options = new FirefoxOptions();
options.setHeadless(false);
options.addArguments("--disable-gpu");
D
FirefoxOptions options = new FirefoxOptions();
options.setHeadless(true);
options.addArguments("-disable-gpu");
Attempts:
2 left
💡 Hint
Check the correct method to enable headless mode and the correct argument syntax for disabling GPU.