I'm trying to run seleniumwire driver in the remote mode. The issue is that I don't quite understand some instructions from the official docs: https://pypi.org/project/selenium-wire/#all-options
options = {
'addr': 'hostname_or_ip' # Address of the machine running Selenium Wire. Explicitly use 127.0.0.1 rather than localhost if remote session is running locally.
}
driver = webdriver.Remote(
command_executor='http://www.example.com',
seleniumwire_options=options
)
Where do I find the hostname of IP? At first I thought it might be the address I use for connecting to the selenium grid, something like this 'http://hub.selenium-grid:4444/wd/hub'. But it raised an error:
E seleniumwire.thirdparty.mitmproxy.exceptions.ServerException: Error starting proxy server: gaierror(-2, 'Name or service not known')
So, if it's not the correct 'addr', what should I use instead?
I found a solution: https://github.com/wkeeling/selenium-wire/issues/327 it works for me when i use real ip, not 127.0.0.1 i hope it will be useful to you
my code(the port 9922 is arbitrary,as long as the port is not in use):
options.add_argument('--proxy-server=192.168.64.131:9922')
seleniumwire_options = {
'suppress_connection_errors': False,
'auto_config': True,
'addr': '192.168.64.131',
'port': 9922
}
driver = webdriver.Remote(
command_executor="http://192.168.64.131:4444/wd/hub",
desired_capabilities=options.to_capabilities(),
seleniumwire_options=seleniumwire_options
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.