What's the difference between `driver.execute_script("...")` and `driver.get("javascript: ..."` with geckodriver/Firefox?
The answer to your question depends on the browser your driver is running. Selenium itself does not implement these functionalities - it merely invokes the underlying driver's API.
Take a look at the source of WebDriver.execute_script
and WebDriver.get
- they both just call self.execute
, which performs a request to the webdriver.
Chrome, for example, does not support 'javascript:' urls with WebDriver.get
since 2013, as can bee seen in chromium's webdriver implementation.
The actual difference between directly running a JS script and navigating to a 'javascript URL' is embedded deep in each browser's implementation, and might be not very straightforward. A possible reason for the difference you mentioned could be an implementation detail - maybe the browser (that was used when the results you mentioned were produced) only sends a Referer
header when it is in the context of a high level navigation command (driver.get
), and therefore did not include one on a plain javascript-triggered navigation.