0
0
Selenium Pythontesting~5 mins

Page title and URL retrieval in Selenium Python - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What Selenium WebDriver method is used to get the current page title?
The driver.title property returns the current page title as a string.
Click to reveal answer
beginner
How do you retrieve the current URL of the page in Selenium WebDriver using Python?
Use the driver.current_url property to get the URL of the current page as a string.
Click to reveal answer
beginner
Why is it useful to check the page title and URL during automated testing?
Checking the page title and URL helps verify that the browser has navigated to the correct page, ensuring the test is on the right track.
Click to reveal answer
beginner
Write a simple Python Selenium code snippet to print the page title and URL.
from selenium import webdriver

driver = webdriver.Chrome()
driver.get('https://example.com')
print(f"Title: {driver.title}")
print(f"URL: {driver.current_url}")
driver.quit()
Click to reveal answer
intermediate
What will driver.title return if the page has no title tag?
It will return an empty string '' if the page does not have a title tag.
Click to reveal answer
Which Selenium WebDriver property gives you the current page URL?
Adriver.url
Bdriver.page_url
Cdriver.current_url
Ddriver.get_url()
What does driver.title return?
AThe page title as a string
BThe page URL
CThe page source HTML
DThe browser name
Why might you check the page title in a test?
ATo confirm the browser is on the expected page
BTo check the page load speed
CTo verify the page's background color
DTo get the browser version
Which of these is the correct way to get the page title in Selenium Python?
Adriver.get_title()
Bdriver.title
Cdriver.pageTitle
Ddriver.getPageTitle()
What will driver.current_url return after navigating to 'https://example.com'?
AAn empty string
BThe page title
CThe browser name
D'https://example.com'
Explain how to retrieve and verify the page title and URL using Selenium WebDriver in Python.
Think about properties of the driver object that hold page info.
You got /4 concepts.
    Describe why checking the page title and URL is important in automated web testing.
    Consider what could go wrong if you don't check these.
    You got /4 concepts.