SELENIUM2 supports no interface operation (Htmlunit and PHANTOMJS)

Source: Internet
Author: User
Tags selenium grid

SELENIUM2 supports testing through various driver (firfoxdriver,iternetexplorerdriver,operadriver,chromedriver) to drive real-world browsers.

In fact, selenium is also supported without interface browser operation. such as Htmlunit and PHANTOMJS. They are not real browsers, the runtime will not render the page display content, but support page element lookup, JS execution, etc., because no CSS and GUI rendering, the efficiency is much faster than the real browser.

1.htmlUnit is a Java-implemented class browser program that is included in the selenium server without the need for a driver to instantiate directly.

Use the following: Webdriver Driver = new htmlunitdriver ();// Webdriver Driver = new Htmlunitdriver (TRUE);//Support JS  2.PhantomJS is a server-side JavaScript API based on WebKit (WebKit is an open source browser engine, Chrome,Safari is the browser engine ), the main application scenario is: Web testing without browser, page access automation, screen capture, network monitoring Use the following:Webdriver Driver = new Phantomjsdriver (); 3. In order to see whether the above two non-interface browser is suitable for the current project group front-end automation, did some preliminary research, the results are as follows: 
Behavior description Behavior Htmlunitdriver Htmlunitdriver (True) Phantomjsdriver Firefoxdriver
text box input Enter text Yes Yes Yes Yes
Buttons button Click the button Yes Yes Yes Yes
Hyperlink A Click Yes Yes No Yes
Drop-down list select Select options Yes Yes Yes Yes
check box checkbox Click Yes Yes Yes Yes
Alert (Displays a warning box with a specified message and an OK button) Click No No No Yes
Promprt (displays a dialog box to prompt the user for input) Click No No No Yes
 The final pre-research results are not suitable for our system because there are many alert in our system4. Summarize the pros and cons of HTMLUNITDRIVER,PHANTOMJS vs Real Browser drivers


Driver type Advantages Disadvantages Application
Real Browser driver Real-world simulation of user behavior Low efficiency and stability Browser compatibility test
Htmlunit Fast speed JS Engine (RHINOJS) is not the mainstream browser support, so the JS support is not good enough 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
 

Summarize:

If you want to test the page JS is not a lot, and do not need to do a compatibility test, Htmlunitdriver is the best choice

If you need to do a compatibility test, you should still choose the real browser driver (if you want to improve the speed of automation, you can consider using Testng,selenium grid parallel test)

SELENIUM2 supports no interface operation (Htmlunit and PHANTOMJS)

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.