python安装目录下.\Lib\site-packages\selenium\webdriver\chromium\options.py
文件中的第34行
# Licensed to the Software Freedom Conservancy (SFC) under one # or more contributor license agreements. ?See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. ?The SFC licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. ?You may obtain a copy of the License at # # ? http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. ?See the License for the # specific language governing permissions and limitations # under the License.
import base64 import os from typing import List, NoReturn, Union
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities from selenium.webdriver.common.options import ArgOptions
class ChromiumOptions(ArgOptions): ? ? KEY = "goog:chromeOptions"
? ? def __init__(self): ? ? ? ? super(ChromiumOptions, self).__init__() ? ? ? ? self._binary_location = '' ? ? ? ? self._extension_files = [] ? ? ? ? self._extensions = [] ? ? ? ? self._experimental_options = {'excludeSwitches':['enable-automation']} ? ? ? ? self._debugger_address = None
将 self._experimental_options = {} 修改为self._experimental_options = {'excludeSwitches':['enable-automation']}
不修改源码的解决方法参照如下链接:chrome正受到自动测试软件的控制 浏览器版本V76以及以上disable-infobars参数失效不起作用python_wsbl52006的专栏-CSDN博客问题: python+selenium 跑UI自动化时谷歌浏览器显示“chrome正受到自动测试软件的控制”谷歌浏览器版本在V75以及以下解决办法如下:from selenium import webdriveroptons=webdriver.ChromeOptions()optons.add_argument('disable-infobars')driver=webdri...https://blog.csdn.net/wsbl52006/article/details/105459850?spm=1001.2014.3001.5501
|