selenium-wire使用远程selenium的时候,driver.requests始终为空

selenium-wire使用远程selenium的时候,driver.requests始终为空
    seleniumwire_options = {
        'suppress_connection_errors': False,
        'auto_config': False,
    }
    driver = webdriver.Remote(
        command_executor="http://192.168.64.131:4444/wd/hub",
        desired_capabilities=options.to_capabilities(),
        seleniumwire_options=seleniumwire_options
    )

这是我连接远程selenium的代码,然后执行driver.get()后,打印driver.requests,一直为空列表。
但是我将连接方式更换为下面这种方式,又能正常拿到driver.requests:

    executable_path = r'chromedriver.exe'
    service = Service(executable_path=executable_path)
    driver = webdriver.Chrome(service=service, options=options)

在使用远程Selenium时,默认情况下,SeleniumWire是不会捕获HTTP请求和响应的。这是因为,当你连接到远程Selenium服务器时,SeleniumWire并不知道你要测试的网站是什么,因此无法自动配置拦截这些网站的HTTP请求。


但是,可以通过指定auto_config和suppress_connection_errors选项来覆盖默认行为。这些选项可以通过seleniumwire_options参数传递给SeleniumWebDriver实例。


例如,可以将auto_config设置为True,以便自动拦截网站的HTTP请求:

seleniumwire_options = {
    'suppress_connection_errors': False,
    'auto_config': True,
}
driver = webdriver.Remote(
    command_executor="http://192.168.64.131:4444/wd/hub",
    desired_capabilities=options.to_capabilities(),
    seleniumwire_options=seleniumwire_options
)

还可以将suppress_connection_errors设置为True,以抑制网络连接错误,这样即使SeleniumWire无法拦截HTTP请求,也不会抛出异常:

seleniumwire_options = {
    'suppress_connection_errors': True,
    'auto_config': False,
}
driver = webdriver.Remote(
    command_executor="http://192.168.64.131:4444/wd/hub",
    desired_capabilities=options.to_capabilities(),
    seleniumwire_options=seleniumwire_options
)