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不準確夏伊,無法連接對應環(huán)境
解決方法:指定node的ip吻氧,java -jar selenium-server-standalone-3.141.59.jar -role node -nodeConfig ~/Documents/node2.json -host node_ip