0
0
Selenium Pythontesting~10 mins

pytest with Selenium setup in Selenium Python - Interactive Code Practice

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

Complete the code to import the Selenium WebDriver module.

Selenium Python
from selenium import [1]
Drag options to blanks, or click blank then click option'
Awebdriver
Bwebdriver_manager
Cseleniumbase
Dseleniumhub
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect module names like 'webdriver_manager' which is a separate package.
Trying to import 'seleniumbase' or 'seleniumhub' which are not standard Selenium modules.
2fill in blank
medium

Complete the code to create a new Chrome WebDriver instance.

Selenium Python
driver = [1].Chrome()
Drag options to blanks, or click blank then click option'
Aselenium
Bwebdriver
CChromeDriver
Ddriver
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'selenium.Chrome()' which is incorrect because 'selenium' is the package, not the module.
Trying to instantiate 'ChromeDriver()' which is not the correct class name.
3fill in blank
hard

Fix the error in the pytest fixture to properly initialize and quit the WebDriver.

Selenium Python
@pytest.fixture
def driver():
    driver = webdriver.Chrome()
    yield [1]
    driver.quit()
Drag options to blanks, or click blank then click option'
Adriver
Bwebdriver
CChrome
Ddriver.quit()
Attempts:
3 left
💡 Hint
Common Mistakes
Yielding webdriver instead of the driver instance.
Yielding driver.quit() which calls quit too early.
4fill in blank
hard

Fill both blanks to write a test that opens a page and checks its title.

Selenium Python
def test_open_page(driver):
    driver.[1]('https://example.com')
    assert driver.title [2] 'Example Domain'
Drag options to blanks, or click blank then click option'
Aget
Bclick
C==
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using click instead of get to open the page.
Using != in the assertion which would fail the test.
5fill in blank
hard

Fill all three blanks to create a fixture that sets up Firefox WebDriver with options and yields it.

Selenium Python
from selenium.webdriver.firefox.options import Options

@pytest.fixture
def firefox_driver():
    options = Options()
    options.[1] = True
    driver = webdriver.Firefox(options=[2])
    yield [3]
    driver.quit()
Drag options to blanks, or click blank then click option'
Aheadless
Boptions
Cdriver
Dfirefox
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect attribute names like 'headless_mode'.
Yielding the options object instead of the driver instance.