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:
- click link on original page, let's on page a.com
- i'm redirected b.com/some/path?arg=value
- 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
Post a Comment