看起来SeleniumGrid2无法同时启动浏览器实例。所以下面的python脚本:
import time
from threading import Thread
from datetime import datetime
from selenium import webdriver
def start_firefox_remote():
print datetime.now(), 'start firefox remote creation'
capabilities = webdriver.DesiredCapabilities.FIREFOX
capabilities['firefox_binary'] = '/usr/bin/firefox'
browser = webdriver.Remote('http://10.0.2.149:4444/wd/hub',
desired_capabilities=capabilities)
print datetime.now(), 'end firefox remote creation'
for i in xrange(5):
time.sleep(.1)
Thread(target=start_firefox_remote).start()
输出以下内容:
2014-03-25 03:12:29.294335 start firefox remote creation
2014-03-25 03:12:29.395388 start firefox remote creation
2014-03-25 03:12:29.499435 start firefox remote creation
2014-03-25 03:12:29.600302 start firefox remote creation
2014-03-25 03:12:29.700916 start firefox remote creation
2014-03-25 03:12:31.806996 end firefox remote creation
2014-03-25 03:12:34.775233 end firefox remote creation
2014-03-25 03:12:37.948995 end firefox remote creation
2014-03-25 03:12:40.612055 end firefox remote creation
2014-03-25 03:12:44.301012 end firefox remote creation
[Finished in 15.2s]
如您所见,浏览器实例创建过程同时开始,但随后它们按非并发模式顺序创建。我使用的是selenium-server-standalone 2.39.0。有趣的是,添加额外的硒节点也无济于事。
如何在真正的并发支持下运行SeleniumGrid? 非常感谢。