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)