Selenium does not recognize pop up as existing

Issue

Original code credit: Omer Sakarya and Ken Jee.

try:
    WebDriverWait(driver, 30).until(EC.alert_is_present())
    obj = driver.switch_to.alert
    obj.dismiss()
except NoSuchElementException:
    pass

Unfortunately, the pop-up stays on the screen and 30 seconds passes resulting in a time-out. Any advice would be appreciated!

   url='https://www.glassdoor.com/Job/' + keyword + '-jobs- 
   SRCH_KO0,14.htm'
   driver.get(url)
   jobs = []


    try:
        driver.find_element(By.CSS_SELECTOR,  '[data- 
    selected="true"]').click()
    except ElementClickInterceptedException:
        pass


    try:
        WebDriverWait(driver, 30).until(EC.alert_is_present())
        obj=driver.switch_to.alert
        obj.dismiss()
    except NoSuchElementException:
        print('x out failed')
        pass

Solution

try:
    driver.find_element(By.XPATH,('.//div[@id="JAModal"]//span[@alt="Close"]')).click()
except NoSuchElementException:
    pass

I was able to solve this one through a lot of trial and error, thank you to everyone that helped!

Answered By – BuffaloJ

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published