Various driver of selenium webdriver

Source: Internet
Author: User
Tags selenium grid

Selenium official plus a third-party announced support for a variety of drivers, in addition to the PC-side browser, but also support the iphone, Android driver, about the selenium supported by the various driver purposes and instructions.

Selenium supported PC browser drivers include:

Safari driver "included in Selenium server"

IE driver

Chrome driver "third party"


Selenium supported pseudo-browser drivers:

Phantomjs Driver the "third party"----material, but it didn't actually work.

Htmlunit Driver "included in Selenium server"----material, but it's not actually working.


Selenium supported mobile-side drivers:

Windows Phone Driver "third party"

Selendroid -selenium for Android "third party"

Ios-driver "Third party"

Appium supports iphone, ipad, Android,Firefoxos"third party"

All of the above drivers can be called directly from the respective language client or registered to a selenium grid for distributed remote calls.


Because the mobile side of the driver have not tried, so do not explain. PC-side driver are browser-based and are divided into 2 main types:

One is the real browser driver

For example: Safari, FF Drive the browser itself in the form of plug-ins, ie, chrome is the binary files to drive the browser itself;

These driver are launched directly and driven by invoking the browser's underlying interface to drive the browser, thus having the most realistic user scenario simulations, primarily for web compatibility testing use.


One is pseudo browser driver (not working in the browser, only relevant information is provided here)

Selenium supported pseudo-browsers include Htmlunit, PHANTOMJS; they are not really in the browser, there is no GUI, but with the support of HTML, JS and other parsing capabilities of the class browser program, these programs do not render the display of the page, but support page element lookup , JS implementation, and so on, because no CSS and GUI rendering, so the efficiency of the operation than the real browser is much faster, mainly used in functional testing above.

Htmlunit is a Java-implemented class browser program, included in the selenium server, without the need for driver, direct instantiation can be, its JS parsing engine is Rhino

Phantomjs is a third party's independent class browser application, can support HTML, JS, CSS and other execution; its driver is ghost driver after 1.9.3 has been packaged into the main program, so just download a main program, its JS parsing engine is chrome The V8.



Driver type Advantages Disadvantages Application
Real Browser driver Real-world simulation of user behavior Low efficiency and stability Compatibility test
Htmlunit Fast speed JS engine is not supported by the mainstream browser Page test with a small number of JS
Phantomjs Medium speed, simulated behavior close to reality Cannot simulate behavior of different/specific browsers Functional testing of non-GUI


PS: In addition to the above several real browser driver, but also by different means to cancel the browser's CSS parsing, interface rendering, etc., so as to ensure the true compatibility of the browser, but also improve the efficiency of the implementation of the problem, the use of means: AutoIt, Pyvirtualdisplay, browser settings, and more.


comparison of the efficiency of several PC end driver :


[python] view plaincopy650) this.width=650; "src=" Https://code.csdn.net/assets/CODE_ico.png "alt=" Check the code for "width=" height= "/>650" this.width=650; src= "Https://code.csdn.net/assets/ico_fork.svg" alt= " Derive to my code slice "width=" "height=" "/>"

  1. 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 ():   &NBsp;   common_step (Webdriver. Phantomjs (executable_path=r ' C:\Python27\Scripts\phantomjs.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&Nbsp;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)        &nBsp; for k,v in dervers_time.items ():      print  ' avg  elapse for %s in %s times:%s '  %  (k, times, v/times)

Results obtained:


650) this.width=650; "Src=" http://img.blog.csdn.net/20140211184951812?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqvzml2ztm=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Southeast "/>


The quickest is htmlunit, PHANTOMJS, Chrome, ie, FF


But excluding pseudo-browsers, chrome in real-world browsers feels like the fastest,

This article is from the "ganshizhe.bokee.com" blog, make sure to keep this source http://328538.blog.51cto.com/318538/1660366

Various driver of selenium webdriver

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.