gpt4 book ai didi

python Selenium "Chrome is being controlled by automated test software"

转载 作者:行者123 更新时间:2023-11-28 19:03:59 26 4
gpt4 key购买 nike

我有一个小型 Python 应用程序,它使用 Selenium 和 FFmpeg 简单地录制网页/网络动画。直到昨天,我的工作都很顺利。

Google 似乎删除了“--disable-infobars”功能。这可以从另一个标志或函数中禁用吗?

或者我是否被迫在顶部添加填充并从填充开始记录?

这是一个示例代码

#!/usr/bin/env python3
from pyvirtualdisplay import Display
import os

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options

url = "http://foo.bar"

os.environ['DISPLAY'] = ':99'
display = Display(visible=0, size=(1920, 1080))
display.start()
display_port = os.environ['DISPLAY']

chrome_driver_path = "/usr/local/bin/chromedriver"
options = webdriver.ChromeOptions()
options.add_argument('--disable-gpu')
options.add_argument('--kiosk')
options.add_argument('--window-position=0,0')
options.add_argument('--disable-infobars');
options.add_argument('--window-size=1920,1080')

browser = webdriver.Chrome(executable_path=chrome_driver_path, chrome_options=options)
browser.get(url)

command = "/home/fidox/bin/ffmpeg -r 60 -t {} -video_size {}x{} -framerate 60 -f x11grab -i foo.mp4 f-an {}".format(10,1920,1080,display_port)
os.system(command)

self.browser.quit()
display.stop()

最佳答案

对于 Python3。

chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option("useAutomationExtension", False)
chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"])
driver = webdriver.Chrome(options=chrome_options)

关于 python Selenium "Chrome is being controlled by automated test software",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49177222/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com