Selenium WebDriver Browser & Driver Configuration 1 — Questions and Answers
Question 1: Which class is used to configure Chrome-specific options in Selenium WebDriver?
- ChromeOptions (Correct answer)
- ChromeConfig
- ChromePreferences
- ChromeSettings
Correct answer: ChromeOptions
ChromeOptions allows setting command-line arguments, experimental options, and capabilities for ChromeDriver.
Question 2: How do you launch Chrome in headless mode using ChromeOptions?
- options.addArguments('--headless') (Correct answer)
- options.setHeadless(true)
- options.addArguments('--no-gui')
- options.headless(true)
Correct answer: options.addArguments('--headless')
Passing '--headless' as a Chrome argument starts the browser without a visible UI.
Question 3: What is the purpose of setting 'webdriver.chrome.driver' system property?
- To specify the file path to the chromedriver executable (Correct answer)
- To set the Chrome browser version
- To point to the Chrome browser binary
- To define the default download directory
Correct answer: To specify the file path to the chromedriver executable
Selenium uses the 'webdriver.chrome.driver' system property to locate the chromedriver binary on disk.
Question 4: Which WebDriver manager library automatically downloads the correct ChromeDriver version?
- WebDriverManager (Correct answer)
- DriverFactory
- ChromeDriverSetup
- AutoDriver
Correct answer: WebDriverManager
WebDriverManager (by Boni García) detects the browser version and downloads the matching driver binary automatically.
Question 5: How do you set an implicit wait of 10 seconds in WebDriver?
- driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10)) (Correct answer)
- driver.setImplicitWait(10)
- driver.waitFor(10)
- driver.manage().setWait(10, TimeUnit.SECONDS)
Correct answer: driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10))
Implicit waits are configured through driver.manage().timeouts().implicitlyWait() with a Duration parameter.
Question 6: What does driver.manage().window().maximize() do?
- Maximizes the browser window to fill the screen (Correct answer)
- Sets window size to 1920x1080
- Switches to fullscreen mode
- Resizes to the viewport maximum
Correct answer: Maximizes the browser window to fill the screen
maximize() expands the browser window to the maximum size allowed by the operating system.
Which class is used to configure Chrome-specific options in Selenium WebDriver?