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

你可能感兴趣的:(selenum-grid 执行代码报错:Error forwarding the new session Error forwarding the request No route to host)