问题:
在机器A搭建了selenium-grid的环境,hub以4444端口号启动,并在4444下注册了子node,端口4445,浏览器配置chrome
使用代码进行远程连接,并创建会话:
传入的server_url = http://xxxx:4445/wd/hub
driver = webdriver.remote.webdriver.WebDriver(command_executor=server_url, desired_capabilities=desired_cps_web)
执行以上代码,持续时间约10分钟,最后报错
这个问题就是因为到对应的机器上找不到4445的hub,所以报错
解决:
实际要连接的是远程机器hub的端口号4444,然后在其子node下面找到匹配的node节点,进行执行代码
看机器A下启动的hub节点,提示clients should connect to http://xxxx:4444
将server_url里面端口号更新为4444,即可连接上机器A,并创建chrome的会话,代码连接过程
[remote_connection.py:_request:388] [DEBUG]: POST http://192.168.8.212:4444/wd/hub/session {"capabilities": {"firstMatch": [{}], "alwaysMatch": {"browserName": "firefox", "acceptInsecureCerts": true}}, "desiredCapabilities": {"browserName": "firefox", "marionette": true, "acceptInsecureCerts": true}} 2023-02-09 14:24:13,742 [connectionpool.py:_new_conn:206] [DEBUG]: Starting new HTTP connection (1): 192.168.8.212 2023-02-09 14:25:06,291 [connectionpool.py:_make_request:393] [DEBUG]: http://192.168.8.212:4444 "POST /wd/hub/session HTTP/1.1" 500 12019 2023-02-09 14:25:06,293 [remote_connection.py:_request:440] [DEBUG]: Finished Request .... 执行后面的代码标签:10,remote,hub,py,连接时间,4444,DEBUG,http From: https://www.cnblogs.com/cuitang/p/17105763.html