selenum-grid 执行代码报错:Error forwarding the new session Error forwarding the request No route to host

grid搭建好了之后,node也能注册,但是一运行代码就报错
代码:

from selenium import webdriver
import seldom

if __name__ == '__main__':
    # selenium启动gird
    options = webdriver.ChromeOptions()
    # options.set_capability("browserName", "chrome")
    # options.set_capability("browserVersion", "106.0")
    driver = webdriver.Remote(command_executor="http://hubip:4444/wd/hub", options=options)
    driver.get("https://www.baidu.com")
    time.sleep(100)
    print(driver.page_source)
    driver.quit()

报错:selenium.common.exceptions.WebDriverException: Message: Error forwarding the new session Error forwarding the request No route to host

原因:因为node向hub注册时,获取的ip不准确,无法连接对应环境

解决方法:指定node的ip,java -jar selenium-server-standalone-3.141.59.jar -role node -nodeConfig ~/Documents/node2.json -host node_ip

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容