Challenge - 5 Problems
Navigation Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output after navigating back in Selenium?
Consider the following Selenium Python code snippet. What will be the current URL printed after executing
driver.back()?Selenium Python
from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.common.by import By import time service = Service() driver = webdriver.Chrome(service=service) driver.get('https://example.com/page1') driver.get('https://example.com/page2') driver.back() print(driver.current_url) driver.quit()
Attempts:
2 left
💡 Hint
The back() method navigates to the previous page in the browser history.
✗ Incorrect
After navigating to page1 and then page2, calling driver.back() returns the browser to page1, so current_url is https://example.com/page1.
❓ assertion
intermediate2:00remaining
Which assertion correctly verifies page refresh in Selenium?
You want to verify that refreshing the page reloads the same URL. Which assertion correctly checks this after calling
driver.refresh()?Selenium Python
from selenium import webdriver from selenium.webdriver.chrome.service import Service service = Service() driver = webdriver.Chrome(service=service) driver.get('https://example.com') url_before = driver.current_url driver.refresh() url_after = driver.current_url # Which assertion below is correct?
Attempts:
2 left
💡 Hint
Refreshing reloads the same page, so URL should not change.
✗ Incorrect
After refresh, the URL remains the same, so url_before and url_after should be equal.
🔧 Debug
advanced2:00remaining
Why does this Selenium code not navigate when calling driver.forward()?
Examine the code below. Why does calling
driver.forward() not navigate forward?Selenium Python
from selenium import webdriver from selenium.webdriver.chrome.service import Service service = Service() driver = webdriver.Chrome(service=service) driver.get('https://example.com/page1') driver.forward()
Attempts:
2 left
💡 Hint
Think about browser history and when forward navigation is possible.
✗ Incorrect
driver.forward() moves forward in browser history. Since no forward page exists after first navigation, calling it does nothing.
🧠 Conceptual
advanced2:00remaining
What is the effect of calling driver.back() twice in Selenium?
If you navigate through three pages in order: page1, page2, page3, then call
driver.back() twice, which page will be displayed?Attempts:
2 left
💡 Hint
Each back() moves one step back in browser history.
✗ Incorrect
Starting at page3, first back() goes to page2, second back() goes to page1.
❓ framework
expert3:00remaining
Which Selenium Python code snippet correctly waits for page refresh to complete before asserting URL?
You want to refresh the page and then assert the URL is unchanged. Which code snippet correctly waits for the page to reload before asserting?
Attempts:
2 left
💡 Hint
Use explicit waits to ensure page reload completes before assertions.
✗ Incorrect
Option A uses WebDriverWait with expected condition url_to_be to wait until the URL matches the expected one after refresh, ensuring the page reload is complete before asserting.