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://openload.co/f/KgNvMOs9fws/C__Program_Files_Python36_placeholder.mp4'
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,220 points
881 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,130 points

Related Questions In Selenium

0 votes
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,130 points
23 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,400 points
3,973 views
0 votes
1 answer

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,050 points
260 views
0 votes
1 answer
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,130 points
629 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
257 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,130 points
1,906 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,130 points
1,028 views