硒处理窗口弹出

时间:2020-01-01 21:46:19

标签: python-3.x selenium selenium-webdriver

我目前正在开发一个可以登录instagram的机器人,目前我具有登录和打开通知的脚本,但是当我看到一个弹出窗口时,该代码不会单击“允许”。我被困了很长时间。预先感谢您的帮助。 Window Popup

def allow_noti():
allow_noti = WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.XPATH, 
"//button[contains(.,'Turn On')]")))
allow_noti.click()
allow_browser =  WebDriverWait(browser, 10).until(EC.element_to_be_clickable((By.XPATH, '//* 
[text()="Allow"]'))).click()
allow_browser.click()

1 个答案:

答案 0 :(得分:0)

希望这会有所帮助

public static void main(String[] args) 
{
    ChromeOptions options = new ChromeOptions();    
    options.addArguments("--disable-notifications");
    System.setProperty("webdriver.chrome.driver", "/home/users/ss/bb/chromedriver");
    WebDriver driver =new ChromeDriver(options);
    driver.get("http://google.com");
    driver.manage().window().maximize();
}
相关问题