您的位置:軟件測試 > 開源軟件測試 > 開源功能測試工具 > Selenium
Selenium webdriver的各種driver
作者:網(wǎng)絡(luò)轉(zhuǎn)載 發(fā)布時間:[ 2014/2/17 9:20:55 ] 推薦標簽:Selenium 驅(qū)動 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)
  得出的結(jié)果:

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

上一頁12下一頁
軟件測試工具 | 聯(lián)系我們 | 投訴建議 | 誠聘英才 | 申請使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd