Selenium (vi) Headless CHROME/FIREFOX--PHANTOMJS stop support, use no interface mode.

Source: Internet
Author: User

Brief introduction:

Previously, PHANTOMJS was used for automated testing without interface mode, or to crawl some dynamic pages.

However, after the recent selenium update, the ‘Selenium support for PhantomJS has been deprecated, please use headless ‘ prompt does not support PHANTOMJS, please use headless mode.

Well, let's continue using Firefox Chrome's headless mode.

One: Version Confirmation

1.windows down

Selenium 3.9.0

I am using this version of selenium and have been prompted to stop support. You can find this article and prove that your version is not too low.

Firefox 58.0.2 (64-bit)

This is a long-term support version, not the latest version, some features seemingly unstable, and often updated.

Chrome version 64.0.3282.119 (official version) (64-bit)

This is easy to follow the application of the housekeeper upgrade, after all, not even on the Google upgrade server.

Python 3.6.3 AMD64

This is indeed the version.

2.linux

Not tested yet. Deploy a Linux project in a few days and share the version with you.

Two: Firefox headless mode

 fromSeleniumImportwebdriveroptions=Webdriver. Firefoxoptions () options.set_headless ( )#options.add_argument ('-headless ')Options.add_argument ('--disable-gpu') Driver=webdriver. Firefox (firefox_options=options) Driver.get ('http://httpbin.org/user-agent') Driver.get_screenshot_as_file ('Test.png') Driver.close ()

Instantiate firefoxoptions

With Set_headless

or add_headless

When instantiating a Firefox browser, add parameters firefox_options=options

That's all you can do.

The phrase '--DISABLE-GPU ' is disabling GPU acceleration.

Three: Chrome headless mode

 from  selenium import   webdriveroptions  =webdriver. Chromeoptions () options.set_headless ()  #   Options.add_argument ('--headless ')  options.add_argument ( " --disable-gpu   " ) driver  =webdriver. Chrome (Options=options) driver.get (  " Span style= "COLOR: #800000" >http://httpbin.org/user-agent   "  Driver.get_screenshot_as_file (  " test.png   " ) driver.close ()  

Same as Firefox above.

Selenium (vi) Headless CHROME/FIREFOX--PHANTOMJS stop support, use no interface mode.

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.