#StackBounty: #python #selenium #webdriver #geckodriver #http-referer What's the difference between `driver.execute_script("…..

Bounty: 100

I think, this question concerns the internal workings of Selenium. In another post Referer missing in HTTP header of Selenium request it becomes apparent that there is a difference between running

driver.execute_script("window.location.href = '{}';".format(url))


driver.get("javascript: window.location.href = '{}'".format(url))

The latter command will send Referer header with the request, the former will not.

Doesn’t matter at this point if this is desired behavior or a bug and Referer should be sent by both commands. Also, window.location.href = ... is only an example.

Yet, obviously, there must be a difference between running JavaScript with command driver.execute_script("...") and driver.get("javascript: ..." if they don’t produce the same result. So the question is more about the fact that both commands don’t invoke the same Selenium code internally.

What is the difference between both commands?

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.