How to get rid of the infobar quot;Chrome is being controlled by automated test softwarequot; through Selenium(如何摆脱信息栏“Chrome 正在被自动化测试软件控制通过硒)
问题描述
搜索了一段时间并尝试了所有现有的解决方案,但似乎没有一个有效.我创建了一个幻灯片放映",它将首先登录,然后在选项卡之间交替.所有这些都有效,但我无法摆脱
Been searching for a while and tried all the solutions present but none appear to be working. I created a "slide show" that will first log in, then alternate between tabs. All of that is working but i cannot get rid of the
Chrome 正在被自动化测试软件控制"栏.有什么建议吗?
"Chrome is being controlled by automated test software" bar. Any advise?
代码
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
usernameStr = 'test'
passwordStr = 'test'
browser = webdriver.Chrome()
#first tab
browser.get(('www.testwebsite.com?'))
# fill in username and hit the next button
username = browser.find_element_by_id('username')
username.send_keys(usernameStr)
password = WebDriverWait(browser, 10).until(
EC.presence_of_element_located((By.ID, 'password')))
password.send_keys(passwordStr)
nextButton = browser.find_element_by_class_name('emp-submit')
nextButton.click()
#second tab
browser.execute_script("window.open('about:blank', 'tab2');")
browser.switch_to.window("tab2")
browser.get('www.testwebsite.com')
推荐答案
当您通过 ChromeDriver 打开 Chrome 浏览器 时,此信息栏包含 通知 嵌入如下:
When you open Chrome Browser in through ChromeDriver this infobar containing the notification is embedded as follows:
Chrome is being controlled by automated test software
- 不带参数
disable-infobars
的浏览器快照: - Browser snapshot without the argument
disable-infobars
: 代码块:
Code Block:
但是,如果您通过 ChromeOptions 的实例添加参数 disable-infobars,您可以按如下方式删除此信息栏:
But if you add the argument disable-infobars through an instance of ChromeOptions you can get rid of this infobar as follows:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument('start-maximized')
options.add_argument('disable-infobars')
driver = webdriver.Chrome(chrome_options=options, executable_path=r'C:WebDriverschromedriver.exe')
driver.get('https://www.google.com/')
应用参数disable-infobars
的浏览器快照:
这篇关于如何摆脱信息栏“Chrome 正在被自动化测试软件控制"通过硒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何摆脱信息栏“Chrome 正在被自动化测试软件控制"通过硒
基础教程推荐
- 使用PyInstaller后在Windows中打开可执行文件时出错 2022-01-01
- 何时使用 os.name、sys.platform 或 platform.system? 2022-01-01
- 线程时出现 msgbox 错误,GUI 块 2022-01-01
- 在 Python 中,如果我在一个“with"中返回.块,文件还会关闭吗? 2022-01-01
- Dask.array.套用_沿_轴:由于额外的元素([1]),使用dask.array的每一行作为另一个函数的输入失败 2022-01-01
- 如何在海运重新绘制中自定义标题和y标签 2022-01-01
- 用于分类数据的跳跃记号标签 2022-01-01
- 筛选NumPy数组 2022-01-01
- 如何让 python 脚本监听来自另一个脚本的输入 2022-01-01
- Python kivy 入口点 inflateRest2 无法定位 libpng16-16.dll 2022-01-01