Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to open the URL 'https://example.com' using Selenium WebDriver.
Selenium Python
from selenium import webdriver driver = webdriver.Chrome() driver.[1]('https://example.com')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'open' instead of 'get' causes an AttributeError.
Using 'navigate' or 'visit' are not valid WebDriver methods.
✗ Incorrect
The correct method to open a URL in Selenium WebDriver is 'get'.
2fill in blank
mediumComplete the code to open the URL stored in the variable 'url' using Selenium WebDriver.
Selenium Python
from selenium import webdriver url = 'https://openai.com' driver = webdriver.Firefox() driver.[1](url)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'navigate_to' or 'open_url' which are not Selenium methods.
Using 'load' which is not a valid WebDriver method.
✗ Incorrect
The 'get' method accepts a URL string or variable and opens it in the browser.
3fill in blank
hardFix the error in the code to correctly open 'https://test.com' using Selenium WebDriver.
Selenium Python
from selenium import webdriver driver = webdriver.Edge() driver.[1]('https://test.com')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'open' causes AttributeError: 'WebDriver' object has no attribute 'open'.
Using 'go_to' or 'visit' are invalid method names.
✗ Incorrect
The correct method to open a URL is 'get'. Using 'open' or others causes errors.
4fill in blank
hardFill both blanks to open 'https://mysite.com' and then close the browser.
Selenium Python
from selenium import webdriver driver = webdriver.Chrome() driver.[1]('https://mysite.com') driver.[2]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'start' instead of 'get' to open URL.
Using 'close' instead of 'quit' which only closes one window.
✗ Incorrect
Use 'get' to open the URL and 'quit' to close the browser and end the session.
5fill in blank
hardFill all three blanks to open 'https://learn.com', wait 5 seconds, and then close the browser.
Selenium Python
from selenium import webdriver import time driver = webdriver.Firefox() driver.[1]('https://learn.com') time.[2](5) driver.[3]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'wait' instead of 'sleep' which causes AttributeError.
Using 'close' instead of 'quit' which only closes one window.
✗ Incorrect
Use 'get' to open URL, 'sleep' to pause, and 'quit' to close browser.