用selenium做自動測試的時候,網頁會顯示這個。
這是因為用selenium啟動谷歌瀏覽器的時候,為了保證最快的運行效率,啟動了一個最初始化的瀏覽器,沒有插件,沒有歷史記錄等。
from selenium import webdriver
# 下面兩行代碼就是設置啟動配置項,加了的話就沒有“Chrome正受到自動測試軟件的控制”這幾個字
chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option("excludeSwitches", ['enable-automation'])
path = r"E:\chromedriver\chromedriver.exe"
driver = webdriver.Chrome(executable_path=path, options=chrome_options)
driver.get("http://www.baidu.com"