問題描述
搜索了一段時間并嘗試了所有現(xiàn)有的解決方案,但似乎沒有一個有效.我創(chuàng)建了一個幻燈片放映",它將首先登錄,然后在選項卡之間交替.所有這些都有效,但我無法擺脫
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
- 不帶參數(shù)
disable-infobars
的瀏覽器快照: - Browser snapshot without the argument
disable-infobars
: 代碼塊:
Code Block:
但是,如果您通過 ChromeOptions 的實例添加參數(shù) 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/')
應(yīng)用參數(shù)disable-infobars
的瀏覽器快照:
這篇關(guān)于如何擺脫信息欄“Chrome 正在被自動化測試軟件控制"通過硒的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!