0
0
Selenium Javatesting~10 mins

Headless execution in Selenium Java - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to enable headless mode in ChromeDriver.

Selenium Java
ChromeOptions options = new ChromeOptions();
options.[1];
WebDriver driver = new ChromeDriver(options);
Drag options to blanks, or click blank then click option'
AaddArguments("--headless")
BsetHeadless
CenableHeadless
DheadlessMode
Attempts:
3 left
💡 Hint
Common Mistakes
Using a method name that does not exist like setHeadless or enableHeadless.
Trying to set a boolean property instead of adding an argument.
2fill in blank
medium

Complete the code to create a FirefoxDriver with headless mode enabled.

Selenium Java
FirefoxOptions options = new FirefoxOptions();
options.[1]("--headless");
WebDriver driver = new FirefoxDriver(options);
Drag options to blanks, or click blank then click option'
AaddArguments
BsetHeadless
CaddPreference
DsetCapability
Attempts:
3 left
💡 Hint
Common Mistakes
Using setHeadless which is not a method in FirefoxOptions.
Using setCapability incorrectly for headless mode.
3fill in blank
hard

Fix the error in the code to run ChromeDriver headless.

Selenium Java
ChromeOptions options = new ChromeOptions();
options.addArguments([1]);
WebDriver driver = new ChromeDriver(options);
Drag options to blanks, or click blank then click option'
A"headless=true"
B"-headless"
C"headless-mode"
D"--headless"
Attempts:
3 left
💡 Hint
Common Mistakes
Using "headless" without dashes causes Chrome to ignore the argument.
Using single dash or other variations are incorrect.
4fill in blank
hard

Fill both blanks to set headless mode and disable GPU in ChromeOptions.

Selenium Java
ChromeOptions options = new ChromeOptions();
options.[1];
options.[2]("--disable-gpu");
Drag options to blanks, or click blank then click option'
AaddArguments("--headless")
BsetHeadless(true)
CaddArguments
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to call setHeadless which is not a method in ChromeOptions.
Passing arguments without quotes or parentheses.
5fill in blank
hard

Fill all three blanks to create a FirefoxDriver with headless mode and set window size.

Selenium Java
FirefoxOptions options = new FirefoxOptions();
options.[1]("--headless");
WebDriver driver = new FirefoxDriver(options);
driver.[2](new Dimension([3], 1080));
Drag options to blanks, or click blank then click option'
AaddArguments
BsetHeadless
C1920
Dmanage().window().setSize
Attempts:
3 left
💡 Hint
Common Mistakes
Using setHeadless which is not a method in FirefoxOptions.
Confusing the order of method calls.
Using incorrect values for window size.