Webdriver Automation Test Tools (3) Use of the---PHANTOMJS

Source: Internet
Author: User

PHANTOMJS is a WebKit-based JavaScript API. It uses Qtwebkit as the function of its core browser, using WebKit to compile and interpret the execution of JavaScript code. Anything you can do on a WebKit browser can do it. Not only is it an invisible browser, it provides such things as CSS selectors, web standards support, DOM manipulation, JSON, HTML5, Canvas, SVG, and so on, as well as handling file I/O, so you can read and write files to the operating system. Phantomjs is useful for a wide range of applications, such as network monitoring, Web screenshots, Web tests without browsers, and page access automation.

Its use is also quite simple:

One. Installation

Download webdriverc# class library, http://www.seleniumhq.org/download/

You will also need to download a phantomjs,:http://phantomjs.org/download.html

Here you can search in NuGet for selenium.webdriver and Selenium.PhantomJS.WebDriver to download, but domestic network problems may appear to download not come

Two. References (nuget download ignores this step)

If you are downloading through a link, you can refer to it, Phantomjs.exe put it in the root directory, and then set the property to always copy

Three. Preliminary examination

usingOpenqa.selenium;usingOpenQA.Selenium.PhantomJS;usingSystem;namespacephantomjsdemo{classProgram {Static voidMain (string[] args) {            varURL ="https://www.baidu.com"; varDriver =NewPhantomjsdriver (); Driver. Navigate ().            Gotourl (URL); Driver. Findelement (By.id ("kw")). SendKeys ("ASP"); Driver. Findelement (By.id ("su")).            Click (); Console.WriteLine (Driver.            Title);            Console.read (); Driver.        Quit (); }    }}

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

Webdriver Automation Test Tools (3) Use of the---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.