0
0
Selenium Pythontesting~10 mins

First Selenium script 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 open a Chrome browser using Selenium.

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 capitalize the browser name.
2fill in blank
medium

Complete the code to find an element by its ID.

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

driver = webdriver.Chrome()
driver.get('https://example.com')
element = driver.find_element(By.[1], 'submit-button')
driver.quit()
Drag options to blanks, or click blank then click option'
AID
BTAG_NAME
CCLASS_NAME
DNAME
Attempts:
3 left
💡 Hint
Common Mistakes
Using By.NAME when the element has an ID.
Using lowercase instead of uppercase for By.ID.
3fill in blank
hard

Fix the error in the code to click a button after finding it.

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

driver = webdriver.Chrome()
driver.get('https://example.com')
button = driver.find_element(By.ID, 'submit')
button.[1]()
driver.quit()
Drag options to blanks, or click blank then click option'
Asubmit
Bclick
Csend_keys
Dget
Attempts:
3 left
💡 Hint
Common Mistakes
Using submit() on a button element that is not a form.
Using send_keys() which is for typing text.
4fill in blank
hard

Fill both blanks to wait until an element is visible before clicking it.

Selenium Python
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Chrome()
driver.get('https://example.com')
wait = WebDriverWait(driver, [1])
element = wait.until(EC.[2]((By.ID, 'submit')))
element.click()
driver.quit()
Drag options to blanks, or click blank then click option'
A10
B5
Cvisibility_of_element_located
Delement_to_be_clickable
Attempts:
3 left
💡 Hint
Common Mistakes
Using too long or zero wait time.
Using visibility_of_element_located when the element is not clickable yet.
5fill in blank
hard

Fill all three blanks to create a dictionary of element texts for all buttons with class 'btn'.

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

driver = webdriver.Chrome()
driver.get('https://example.com')
buttons = driver.find_elements(By.[1], 'btn')
texts = [2]: button.[3] for button in buttons
print(texts)
driver.quit()
Drag options to blanks, or click blank then click option'
ACLASS_NAME
Bbutton.text
Ctext
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Using find_element instead of find_elements.
Calling text() as a method instead of property.