0
0
Selenium Pythontesting~10 mins

Why cross-browser ensures compatibility in Selenium Python - Test Your Understanding

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

Complete the code to open a browser using Selenium WebDriver.

Selenium Python
from selenium import webdriver

driver = webdriver.[1]()
driver.get('https://example.com')
driver.quit()
Drag options to blanks, or click blank then click option'
AChrome
BFirefox
CSafari
DEdge
Attempts:
3 left
💡 Hint
Common Mistakes
Using a browser name that is not installed or supported.
Forgetting to import webdriver.
2fill in blank
medium

Complete the code to check the page title after loading a URL.

Selenium Python
from selenium import webdriver

driver = webdriver.Firefox()
driver.get('https://example.com')
assert driver.title [1] 'Example Domain'
driver.quit()
Drag options to blanks, or click blank then click option'
A<
B>
C==
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using assignment operator = instead of comparison.
Using wrong comparison operators like !=.
3fill in blank
hard

Fix the error in the code to find an element by its ID.

Selenium Python
from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Edge()
element = driver.find_element(By.[1], 'submit-button')
element.click()
driver.quit()
Drag options to blanks, or click blank then click option'
ACLASS_NAME
BID
CNAME
DTAG_NAME
Attempts:
3 left
💡 Hint
Common Mistakes
Using By.NAME or By.CLASS_NAME when the element has an ID.
Forgetting to import By.
4fill in blank
hard

Fill both blanks to create a test that opens Firefox and checks the page title.

Selenium Python
from selenium import webdriver

driver = webdriver.[1]()
driver.get('https://example.com')
assert driver.title [2] 'Example Domain'
driver.quit()
Drag options to blanks, or click blank then click option'
AFirefox
B!=
C==
DChrome
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong browser name or wrong comparison operator.
Mixing up != and ==.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps browser names to their WebDriver instances if the browser name length is greater than 5.

Selenium Python
from selenium import webdriver

browsers = ['Chrome', 'Firefox', 'Edge', 'Safari']
drivers = { [1]: webdriver.[2]() for [1] in browsers if len([1]) [3] 5 }
Drag options to blanks, or click blank then click option'
Abrowser
BChrome
C>
DFirefox
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same blank token for different variables incorrectly.
Using wrong comparison operator or wrong browser name.