Selenium+python Automation 87-chrome Browser silent mode start (headless)

Source: Internet
Author: User

Objective

SELENIUM+PHANTOMJS can open the browser without interface, implement the silent mode to start the browser to complete the automated test, this mode is excellent, do not need to occupy the computer screen.

However, phantomjs this hole is still more, and encountered problems can not see the page, unable to troubleshoot problems.

In fact, the Chrome browser can also implement silent mode, do not display the page on the computer, can also implement automated testing.

Small Series Environment:
Python 3.6
Selenium 3.6.0
Chrome 63.0.3239.84
Chromdriver 2.33.506120

(I this configuration is pro-test feasible, the other version is too low if not estimated)

Headless

1. When you start the browser, do not want to see the browser run, then load the browser's silent mode, let it secretly run in the background.

option = Webdriver. Chromeoptions ()
Option.add_argument (' headless ')

2. By contrast, when you start silent mode, running code starts the browser faster.

Reference Code

1.chromedriver.exe need to add to the environment variable path, this is common sense is not much to say

# Coding:utf-8  from Import  = webdriver. Chromeoptions () option.add_argument ('headless')  #  silent mode # Open Chrome Browser driver = webdriver. Chrome (chrome_options=option) driver.get ("Https://www.cnblogs.com/yoyoketang " )print(driver.title)

Selenium+python Automation 87-chrome Browser silent mode startup (headless)

Related Article

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.