C # Use Selenium + PhantomJS in the project to simulate logon to the blog Park,

Source: Internet
Author: User

C # Use Selenium + PhantomJS in the project to simulate logon to the blog Park,

Selenium

Selenium is a web automated testing tool. Many students who learn automation have begun to prefer selenium.

 

PhantomJS

PhantomJS is a webkit-based javascript API. It uses QtWebKit as its core browser function and uses webkit to compile and interpret and execute JavaScript code. Anything you can do in a webkit-based browser. It is not only an invisible browser, but also provides CSS selectors, supports Web standards, DOM operations, JSON, html5, Canvas, SVG, etc, it also provides operations for processing file I/O, so that you can read and write files to the operating system. PhantomJS is widely used, such as network monitoring, Web screenshots, Web testing without a browser, and page access automation.

Official example of PhantomJS: http://phantomjs.org/examples/

 

C # How to use it in the project:

First install the component under Nuget

Selenium. PhantomJS. WebDriver

Selenium. WebDriver

Var url = "https://passport.cnblogs.com/user/signin"; var driver1 = new PhantomJSDriver (GetPhantomJSDriverService (); driver1.Navigate (). goToUrl (url); if (driver1.Title = "User Logon-blog Garden") {driver1.FindElement (. id ("input1 ")). sendKeys ("xielongbao"); driver1.FindElement (. id ("input2 ")). sendKeys ("1234"); driver1.FindElement (. id ("signin ")). click ();} Console. writeLine (driver1.PageSource );

 

 

 

Sample login code

A good package

 

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.