- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get the title and URL of the page in Selenium with python?
We can get the title and URL of the page in Selenium.
For getting the title of the browser, the title method is to be used.
For getting the URL of the page, the current_url method is to be used.
Both these methods can be used for testing if we are navigated to the correct page and page title.
Example
Code Implementation
from selenium import webdriver #browser exposes an executable file #Through Selenium test we will invoke the executable file which will then #invoke actual browser driver = webdriver.Chrome(executable_path="C:\chromedriver.exe") # to maximize the browser window driver.maximize_window() #get method to launch the URL driver.get("https://www.tutorialspoint.com/index.htm") # to print the page title in console print(driver.title) # to print the current URL in console print(driver.current_url) #to refresh the browser driver.refresh() #to close the browser driver.close()
- Related Articles
- How to get the title and URL of a webpage with Javascript executor in Selenium with python?
- Get page title with Selenium WebDriver using Java.
- How to get the complete screenshot of a page in Selenium with python?
- How to obtain the page title using Selenium webdriver?
- How to get the title and full URL of a document in JavaScript?
- How to get the screenshot of a particular element in the page in Selenium with python?
- Getting the URL of the current page using Selenium WebDriver.
- How to get details of a webpage like url, title name, domain name etc using Javascript Executor in Selenium?
- How to get all the values including the headers inside a table in a page in Selenium with python?
- How to count the number of checkboxes in a page in Selenium with python?
- How do I get current URL in Selenium Webdriver 2 Python?
- How to find the status of an element in a page in Selenium with python?
- How to count the total number of tables in a page in Selenium with python?
- How to get innerHTML of whole page in selenium driver?
- How to get the total number of checkboxes in a page using Selenium?

Advertisements