Getting current page url with selenium

0 votes

I'm using selenium to open a page. I'm trying to get the current opened page url but I can't seem to get it.

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import getpass

vid = 'https://www.edureka.co/prince2-foundation-and-practitioner-certification-training'
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('load-extension=C:/Users/'+getpass.getuser()+'/AppData/Local/Google/Chrome/User Data/Default/Extensions/leallakffbiflfgpmamdgcojddnbfdgo/1.1.8_0')
driver = webdriver.Chrome(chrome_options=chrome_options)
print('Start')
driver.get(vid)
print('Middle')
urlpage = driver.current_url
print(urlpage)
print('End')

I have a chrome extension that modifies the url of the video. I'm trying to grab that modified page url, but there is no point in adding a time delay since I can't grab the url of the video page in the first place for some reason. And driver.current_url is not working.

Aug 9, 2018 in Selenium by Martin
• 4,320 points
6,148 views

1 answer to this question.

0 votes

If you are having issues with .get(), then you must be on a bad combination of chromedriver and Chrome browser.

I would recommend updating to chromedriver 2.36 or Above

And also make sure you have updated to the current Chrome Build 65 by opening this URL:

chrome://settings/help

If you cannot update to current, please try this:

from selenium import webdriver

ChromeOptions = webdriver.ChromeOptions()
ChromeOptions.add_argument('--disable-browser-side-navigation')
driver = webdriver.Chrome('your/path/to/chromedriver.exe', chrome_options=ChromeOptions)
answered Aug 9, 2018 by Samarpit
• 5,910 points

Related Questions In Selenium

+1 vote
2 answers
0 votes
1 answer
0 votes
1 answer

How to replace remote resources with local resource in a page with Selenium?

You could change URL for that script ...READ MORE

answered Aug 8, 2018 in Selenium by Samarpit
• 5,910 points
4,707 views
0 votes
1 answer

How do I get current URL in Selenium Webdriver using Python?

Use current_url element. Example: print browser.current_url READ MORE

answered Aug 8, 2018 in Selenium by Meci Matt
• 9,460 points
26,009 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
13,687 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,150 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
7,230 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,881 views
0 votes
1 answer

Firefox browser not opening with given URL using Selenium Webdriver with Java

Download the latest selenium jar and replace ...READ MORE

answered Apr 30, 2018 in Selenium by Samarpit
• 5,910 points
7,785 views
0 votes
1 answer

Current URL of the already opened browser using selenium

Use Something like this: //get all the windows ...READ MORE

answered Jul 25, 2018 in Selenium by Samarpit
• 5,910 points
6,455 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP