我的 /etc/rc.local 文件中有以下配置
Xvfb :99 -screen 0 1024x768x24 -ac 2>&1 >/dev/null &
export DISPLAY=:99
java -jar /home/ubuntu/selenium-server-standalone-2.29.0.jar -role hub -maxSession 50 -Dwebdriver.chrome.driver=/usr/local/bin/chromedriver > /home/ubuntu/selenium.log&
Xvfb :98 -screen 0 1024x768x24 -ac 2>&1 >/dev/null &
export DISPLAY=:98
java -jar /home/ubuntu/selenium-server-standalone-2.29.0.jar -role node -hub http://IP:4444/grid/register url http://IP:4444/grid/register -remoteHost http://IP:4444/grid/register -host http://IP -Dwebdriver.chrome.driver=/usr/local/bin/chromedriver > /home/ubuntu/selenium-node.log&
要在同一台机器上运行集线器和节点,当我连接到 5555 端口(作为节点)时,我可以成功运行它,但是当询问集线器(端口 4444)时,我得到
Session [None] not available and is not among the last 1000 terminated sessions.\nActive sessions are[]'
我的代码如下:
driver = webdriver.Remote("http://IP:4444/wd/hub", webdriver.DesiredCapabilities.CHROME)
driver.get("http://www.google.com")
print "Page Title: " + driver.title
driver.close()