[英]How to handle alert using Selenium python&
對我來說, Brower Notification
似乎不是警報。 嘗試使用 chrome 選項禁用Brower Notification
這里有兩種disabled
browser notifications
的方法。
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
chrome_options = webdriver.ChromeOptions()
prefs = {"profile.default_content_setting_values.notifications" : 2}
chrome_options.add_experimental_option("prefs",prefs)
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()),options=chrome_options)
driver.get("specific url")
或者
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--disable-notifications")
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()),options=chrome_options)
driver.get("specific url")
此 window 具有的 IDK。 但最簡單的解決方案是向瀏覽器發送“輸入”,然后 window 將被關閉。
import org.openqa.selenium.Keys
WebElement.sendKeys(Keys.RETURN);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.