- 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 do I get current URL in Selenium Webdriver 2 Python?
We can get the current URL of a page with Selenium webdriver. The method current_url is available which obtains the present page URL and then we can print the result in the console.
Syntax
s = driver.current_url
Let us find the URL of the page presently navigated and we shall get https://www.tutorialspoint.com/index.htm as the output.
Example
from selenium import webdriver driver = webdriver.Chrome(executable_path="C:\chromedriver.exe") driver.implicitly_wait(0.5) driver.get("https://www.tutorialspoint.com/index.htm") #identify current URL with current_url l= driver.current_url print(Current URL is: " + l) driver.close()
Output
- Related Articles
- How do I set the Selenium webdriver get timeout?
- Getting the URL of the current page using Selenium WebDriver.
- How do I open Chrome in selenium WebDriver?
- How do I resolve the ElementNotInteractableException in Selenium WebDriver?
- How do I get a parent HTML Tag with Selenium WebDriver using Java?
- How can I get Webdriver Session ID in Selenium?
- How do I find an element that contains specific text in Selenium WebDriver (Python)?
- Maximize WebDriver (Selenium 2) in Python.
- How do I set browser width and height in Selenium WebDriver?
- How to check URL for 404 using Selenium WebDriver?
- How to get current URL in JavaScript?
- How to get current URL in jQuery?
- How can I get the current contents of an element in webdriver?
- How to get selected option using Selenium WebDriver with Python?
- How do I find an element that contains specific text in Selenium Webdriver?

Advertisements