Firefox bypasses Selenium Wire for localhost addresses
See original GitHub issueclient:
from selenium.webdriver import FirefoxProfile
from seleniumwire import webdriver
GECKO_PATH = './drivers/geckodriver'
def interceptor(request):
del request.headers['User-Agent']
request.headers['User-Agent'] = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.101 Safari/537.36"
def init_driver():
options = dict()
profile = FirefoxProfile()
driver = webdriver.Firefox(
executable_path=GECKO_PATH,
seleniumwire_options=options,
firefox_profile=profile
)
return driver
def main():
driver = init_driver()
driver.request_interceptor = interceptor
driver.get('http://127.0.0.1:8000/')
driver.quit()
if __name__ == '__main__':
main()
service to print headers:
from sanic import Sanic
from sanic.response import json
app = Sanic("My Hello, world app")
@app.route('/')
async def test(request):
print('-'*30)
for k, v in dict(request.headers).items():
print(f'"{k}": "{v}"')
print('-'*30)
return json({'hello': 'world'})
if __name__ == '__main__':
app.run()
printed headers here:
------------------------------
"host": "127.0.0.1:8000"
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:88.0) Gecko/20100101 Firefox/88.0"
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
"accept-language": "en-US,en;q=0.5"
"accept-encoding": "gzip, deflate"
"connection": "keep-alive"
"upgrade-insecure-requests": "1"
------------------------------
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
selenium-wire - PyPI
Selenium Wire extends Selenium's Python bindings to give you access to the ... Prevent Firefox from bypassing Selenium Wire for localhost addresses.
Read more >How to run Firefox headless in seleniumwire? - Stack Overflow
I had to check into the seleniumwire files, this combination worked for me from selenium.webdriver import FirefoxOptions from seleniumwire import webdriver ...
Read more >How to Handle SSL Certificate in Selenium WebDriver with ...
Have you ever wondered why this happens? The answer is simple, on manually opening a URL, the browser automatically imports the required ...
Read more >selenium-wire Changelog - pyup.io
Prevent Firefox from bypassing Selenium Wire for localhost addresses. * Fix bug where DNS wasn't being resolved through the proxy for socks5h.
Read more >WebDriverManager - Boni García
Selenium WebDriver is a library that allows controlling web browsers programmatically. It provides a cross-browser API that can be used to ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@wkeeling Thanks, I understand now. Using http://httpbin.org/headers indeed display it as you mentioned.
Hi @wkeeling I’m trying to intercept localhost request for a local file form a Chrome/Chromium browser but selenium-wire ignores localhost requests. Can you explain a bit more please? This is what I’m trying:
The requests made are something like this
htttp://localhost:3000/media/filename.mp4
Here is a thread in stackoverflow I’ve createdThanks in advance.