gpt4 book ai didi

python - 如何通过 Selenium 摆脱信息栏 "Chrome is being controlled by automated test software"

转载 作者:太空宇宙 更新时间:2023-11-04 04:31:15 25 4
gpt4 key购买 nike

已经搜索了一段时间并尝试了所有现有的解决方案,但似乎没有一个有效。我创建了一个“幻灯片放映”,它将首先登录,然后在选项卡之间切换。所有这些都有效,但我无法摆脱

“Chrome 正在被自动化测试软件控制”栏。有什么建议吗?

代码

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')

最佳答案

试试这个:

from selenium import webdriver

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

driver_path = '/Users/myuser/Downloads/chromedriver'
driver = webdriver.Chrome(executable_path=driver_path, chrome_options=options)
driver.get('https://google.com')

driver.close()

关于python - 如何通过 Selenium 摆脱信息栏 "Chrome is being controlled by automated test software",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52614592/

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