wkeeling / selenium-wire

Extends Selenium's Python bindings to give you the ability to inspect requests made by the browser.
MIT License
1.86k stars 240 forks source link

Remote Firefox Webdriver doesn't record requests #706

Closed alexmerm closed 10 months ago

alexmerm commented 10 months ago

Essentially the issue is when using seleniumwire version 5.1.0, and setting up the remote firefox webdriver to use selenium-wire's proxy, SW doesn't record the requests. I've tested setting the proxy to a separate mitmproxy instance, and the requests are going through the proxy, however they don't show up in seleniumwire. The requests do go through, as you can see in both the firefox GUI and through interactions with regular selenium methods.

Steps to Reproduce

  1. setup a remote Selenium instance of firefox, I used docker with the following docker-compose
    version: '3.3'
    services:
    standalone-firefox:
    ports:
      - '4444:4444'
      - '5900:5900'
      - '7900:7900'
    image: 'selenium/standalone-firefox:4.10.0'
  2. Run the following program
    from seleniumwire import webdriver
    from selenium.webdriver.common.proxy import Proxy
    firefox_options = webdriver.FirefoxOptions()
    sw_options = {
    'auto_config': False,  # Ensure this is set to False
    'addr': '0.0.0.0',  # The address the proxy will listen on
    'port': 8087,
    }
    proxy = Proxy();
    proxy.http_proxy = 'host.docker.internal:8087'
    proxy.ssl_proxy = 'host.docker.internal:8087'
    firefox_options.proxy = proxy
    driver = webdriver.Remote(command_executor="http://localhost:4444/wd/hub",options=firefox_options, seleniumwire_options=sw_options)
    driver.get("http://example.com")
    print(driver.requests)

    and observe that driver.requests is empty.

other notes

alexmerm commented 10 months ago

So it turns out that this was an issue with my computer, I tried it again after restarting and it worked fine. sorry abt that. Thank you for all the work you do on Selenium-Wire!