How can I get a intermediate URL from a redirect chain from Selenium using Python? -


i'm using selenium python api , firefox automatic stuff, , here's problem:

  1. click link on original page, let's on page a.com
  2. i'm redirected b.com/some/path?arg=value
  3. and i'm redirected again final address c.com

so there way intermediate redirect url b.com/some/path?arg=value selenium python api? tried driver.current_url when browser on b.com, seems browser still under loading , result returned if final address c.com loaded.

another question is there way add event handlers selenium url-change? phantomjs has capacity i'm not sure selenium.

you can redirects performance logs. according docs , github answer here i've done in c#, should possible port in python:

var options = new chromeoptions(); var cap = desiredcapabilities.chrome(); var perflogprefs = new chromeperformanceloggingpreferences(); perflogprefs.addtracingcategories(new string[] { "devtools.network" }); options.performanceloggingpreferences = perflogprefs; options.addadditionalcapability(capabilitytype.enableprofiling, true, true); ptions.setloggingpreference("performance", loglevel.all); var driver = new chromedriver(options); var url = "https://some-website-that-will-redirect.com/"; driver.navigate().gotourl(url); var logs = driver.manage().logs.getlog("performance"); //all logs redirects here 

looping through logs, if message.params.redirectresponse.url equal original url message.params.request.url contain redirect url


Comments

Popular posts from this blog

Sass watch command compiles .scss files before full sftp upload -

filehandler - java open files not cleaned, even when the process is killed -

gridview - Yii2 DataPorivider $totalSum for a column -