您的位置:软件测试 > 开源软件测试 > 开源功能测试工具 > Selenium
Selenium webdriver的各种driver
作者:网络转载 发布时间:[ 2014/2/17 9:20:55 ] 推荐标签:Selenium 驱动 driver

  几种PC端driver的效率比较:
from selenium import webdriver
import time
drivers = ['HtmlUnit', 'PhantomJS', 'Chrome', 'FF', 'IE']
dervers_time = {
'HtmlUnit' : 0,
'PhantomJS' : 0,
'Chrome' : 0,
'FF' : 0,
'IE' : 0,
}
times = 50
def run_with_Chrome():
common_step(webdriver.Chrome())
def run_with_FF():
common_step(webdriver.Firefox())
def run_with_IE():
common_step(webdriver.Ie())
def run_with_PhantomJS():
common_step(webdriver.PhantomJS(executable_path=r'C:Python27Scriptsphantomjs.exe'))
def run_with_HtmlUnit():
driver = webdriver.Remote("http://localhost:4444/wd/hub",
desired_capabilities=webdriver.DesiredCapabilities.HTMLUNIT)
common_step(driver)
def common_step(driver):
driver.get('http://www.baidu.com')
ele = driver.find_element_by_id('su')
print ele.get_attribute('value')
driver.quit()
for i in range(times):
print '=============Times %s============' % i
for driver in drivers:
start = time.time()
print start
eval('run_with_%s()'%driver)
end = time.time()
print end
elapse_time = end-start
dervers_time[driver] += elapse_time
print 'elapse for %s:%s' % (driver, elapse_time)
for k,v in dervers_time.items():
print 'avg elapse for %s in %s times:%s' % (k, times, v/times)
  得出的结果:

  快的依次是htmlunit、PhantomJS、chrome、ie、ff

上一页12下一页
软件测试工具 | 联系我们 | 投诉建议 | 诚聘英才 | 申请使用列表 | 网站地图
沪ICP备07036474 2003-2017 版权所有 上海泽众软件科技有限公司 Shanghai ZeZhong Software Co.,Ltd