7x11x13 / selenium-wire-2

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

selenium.common.exceptions.WebDriverException: Message: unknown error: net::ERR_PROXY_CONNECTION_FAILED #2

Closed pidgey016 closed 1 month ago

pidgey016 commented 1 month ago

May I ask what's going on with this?

from seleniumwire2 import webdriver
from selenium.webdriver.chrome.options import Options
from seleniumwire2.options import ProxyConfig, SeleniumWireOptions

def remote_test():
    target_url = "https://www.google.com"

    chrome_options = Options()
    chrome_options.add_argument("--start-maximized")
    chrome_options.add_argument('--headless')

    driver = webdriver.Remote(
        command_executor='http://192.168.0.10:4444',
        options=chrome_options,
        )

    driver.get(target_url)

Traceback (most recent call last): File "/Users/pidgey016/VScode/minio-test/selenium_test.py", line 49, in remote_test() File "/Users/pidgey016/VScode/minio-test/selenium_test.py", line 28, in remote_test driver.get(target_url) File "/Users/pidgey016/miniconda3/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 363, in get self.execute(Command.GET, {"url": url}) File "/Users/pidgey016/miniconda3/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 354, in execute self.error_handler.check_response(response) File "/Users/pidgey016/miniconda3/lib/python3.12/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: unknown error: net::ERR_PROXY_CONNECTION_FAILED (Session info: chrome-headless-shell=124.0.6367.118) Stacktrace:

0 0x5608a0c1ecb3

1 0x5608a090d4a7

2 0x5608a09057a9

3 0x5608a08f5782

4 0x5608a08f6d71

5 0x5608a08f5aee

6 0x5608a08f5211

7 0x5608a08f5093

8 0x5608a08f301c

9 0x5608a08f353a

10 0x5608a090fe2f

11 0x5608a09997a5

12 0x5608a097a412

13 0x5608a0998be9

14 0x5608a097a1b3

15 0x5608a094b24a

16 0x5608a094bc1e

17 0x5608a0be2fdb

18 0x5608a0be6f2b

19 0x5608a0bcf0f1

20 0x5608a0be7a92

21 0x5608a0bb3faf

22 0x5608a0c0de08

23 0x5608a0c0dfe0

24 0x5608a0c1de04

25 0x7fe6d028aac3

7x11x13 commented 1 month ago

Can you try setting the host as mentioned here (under the Remote Webdriver subsection): https://github.com/7x11x13/selenium-wire-2?tab=readme-ov-file#creating-the-webdriver

pidgey016 commented 1 month ago

Thanks for replying. Is that right? He reported a new error. Where did this host come from?

options = SeleniumWireOptions(
        host="192.168.0.10",
       )

Traceback (most recent call last): File "/Users/pidgey016/miniconda3/lib/python3.12/site-packages/seleniumwire2/server.py", line 132, in address return self.master.addons.get("proxyserver").listen_addrs()[0]


IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/pidgey016/VScode/minio-test/selenium_test.py", line 56, in <module>
    remote_test()
  File "/Users/pidgey016/VScode/minio-test/selenium_test.py", line 26, in remote_test
    driver = webdriver.Remote(
             ^^^^^^^^^^^^^^^^^
  File "/Users/pidgey016/miniconda3/lib/python3.12/site-packages/seleniumwire2/webdriver.py", line 187, in __init__
    self._setup_backend(seleniumwire_options, options)
  File "/Users/pidgey016/miniconda3/lib/python3.12/site-packages/seleniumwire2/webdriver.py", line 84, in _setup_backend
    self.backend = backend.create(
                   ^^^^^^^^^^^^^^^
  File "/Users/pidgey016/miniconda3/lib/python3.12/site-packages/seleniumwire2/backend.py", line 28, in create
    addr, port, *_ = backend.address
                     ^^^^^^^^^^^^^^^
  File "/Users/pidgey016/miniconda3/lib/python3.12/site-packages/seleniumwire2/server.py", line 134, in address
    raise SeleniumWireException("Proxy is not running")
seleniumwire2.exceptions.SeleniumWireException: Proxy is not running
pidgey016 commented 1 month ago

I see what the problem is. Thank you very much, okay