0
0
Selenium Pythontesting~20 mins

WebDriver setup (ChromeDriver, GeckoDriver) in Selenium Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
WebDriver Setup Master
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 Selenium WebDriver setup code?
Consider the following Python code snippet that sets up a Chrome WebDriver and opens a webpage. What will be printed after execution?
Selenium Python
from selenium import webdriver
from selenium.webdriver.chrome.service import Service

service = Service(executable_path='/path/to/chromedriver')
driver = webdriver.Chrome(service=service)
driver.get('https://example.com')
print(driver.title)
driver.quit()
AExample Domain
BChromeDriver
Chttps://example.com
Dselenium.common.exceptions.WebDriverException
Attempts:
2 left
💡 Hint
The driver.title returns the title of the current page loaded by the browser.
assertion
intermediate
1:30remaining
Which assertion correctly verifies the page title after WebDriver opens a page?
You want to check that the page title is exactly 'Welcome Page' after opening a URL with Selenium WebDriver in Python. Which assertion is correct?
Selenium Python
from selenium import webdriver
from selenium.webdriver.chrome.service import Service

service = Service(executable_path='/path/to/chromedriver')
driver = webdriver.Chrome(service=service)
driver.get('https://example.com/welcome')
# Which assertion below is correct?
Aassert driver.title != 'Welcome Page'
Bassert driver.title == 'Welcome Page'
Cassert 'Welcome Page' in driver.current_url
Dassert driver.page_source == 'Welcome Page'
Attempts:
2 left
💡 Hint
The page title is accessed by driver.title, not current_url or page_source.
🔧 Debug
advanced
2:30remaining
Why does this GeckoDriver setup code raise an error?
This Python code tries to start Firefox WebDriver but raises an error. Identify the cause.
Selenium Python
from selenium import webdriver
from selenium.webdriver.firefox.service import Service

service = Service('/path/to/geckodriver')
driver = webdriver.Firefox(service=service)
driver.get('https://example.com')
driver.quit()
AFirefox browser is not installed on the system
BThe Service class is not imported from selenium.webdriver.firefox.service
CThe path to geckodriver is incorrect or missing execute permission
Ddriver.get() method is deprecated and causes error
Attempts:
2 left
💡 Hint
Check if the geckodriver executable path is valid and accessible.
locator
advanced
1:30remaining
Which locator strategy is best for stable element selection in Selenium?
You want to select a button element that has a unique id 'submit-btn' on a webpage. Which locator is best practice for stability and speed?
Adriver.find_element('id', 'submit-btn')
Bdriver.find_element('xpath', '//button[@id="submit-btn"]')
Cdriver.find_element('css selector', 'button#submit-btn')
Ddriver.find_element('class name', 'submit-btn')
Attempts:
2 left
💡 Hint
Using id locator is usually fastest and most reliable if id is unique.
framework
expert
3:00remaining
What is the correct way to initialize ChromeDriver with options in Selenium Python?
You want to start ChromeDriver with headless mode enabled and disable GPU usage. Which code snippet correctly sets this up?
A
from selenium import webdriver
from selenium.webdriver.chrome.service import Service

service = Service('/path/to/chromedriver')
driver = webdriver.Chrome(service=service)
driver.add_argument('--headless')
driver.add_argument('--disable-gpu')
driver.get('https://example.com')
B
from selenium import webdriver
options = webdriver.ChromeOptions()
options.headless = True
options.disable_gpu = True
driver = webdriver.Chrome(options=options)
driver.get('https://example.com')
C
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.set_headless(True)
options.set_disable_gpu(True)
driver = webdriver.Chrome(options=options)
driver.get('https://example.com')
D
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options

options = Options()
options.add_argument('--headless')
options.add_argument('--disable-gpu')
service = Service('/path/to/chromedriver')
driver = webdriver.Chrome(service=service, options=options)
driver.get('https://example.com')
Attempts:
2 left
💡 Hint
Options must be created and passed to the driver constructor before starting the browser.