
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get Title and URL of 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()
Advertisements