Home > Back-end >  See if a popup appears with Python Selenium
See if a popup appears with Python Selenium

Time:10-23

I'm using selenium and I'd like to know if there is a way to detect if a popup appears while a page is loading (newsletter or cookies especially).

Does someone have an idea ? Thank you in advance !

CodePudding user response:

It really depends on the kind of popup you are trying to detect:

  1. For native JavaScript popups WebDriver provides an enter image description here

    You should actually be able to close this "popup" by selecting the button element and trigger a click event.

    buttonElement = driver.find_element_by_xpath("//a[@title='Accepter']")
    buttonElement.click()
    
    
  • Related