Selenium + Python test environment to build extended-htmlunit use

Source: Internet
Author: User

When trying to write a daily routine check script to the company's website, you don't need to open the browser, which is the use of Htmlunit

Htmlunit is based on the selenium server, so it needs Selenium-server-standalone-xxx.jar

1. Download and install Java in order to run the jar package

2, download Selenium-server-standalone-xxx.jar, here to pay special attention to the version, to match their own selenium version

To view the methods of the packages that you have installed, cmd commands go to scripts in the directory where Python is installed

Enter the PIP list to see the version number of all installed packages

3, after the completion of the two steps, cmd into the Selenium-server-standalone-xxx.jar installation directory,

cmd command input Java-jar Selenium-server-standalone-xxx.jar, the proxy server is running.

PS: If it fails to start, it may be that the port is occupied, can download TCPView view all ports

4, the last step is to test the htmlunit can be used normally

 from Import desiredcapabilities  from Import  = Webdriver. Remote (desired_capabilities=desiredcapabilities.htmlunit) htmlunit.get ("http/ www.baidu.com")
Print Htmlunit.title

Output Result:
C:\Python27\python.exe f:/soft_test/python/code/htmlunit_test.py Baidu A bit, you know process finished with exit code 0

  

Selenium + Python test environment to build extended-htmlunit use

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.