Python Selenium Closing A Pop-up Window
I'd like to close this window opened up on Amazon web site by using Selenium with Python. I've tried find_element_by_xpath, but it doesn't work. Here's the snippet of the code; clo
Solution 1:
You don't need to use switch_to_alert()
as well as get()
to close modal window. Just try to close it with below code:
from selenium.webdriver.common.by import Byfrom selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
WebDriverWait(browser, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'button[aria-label="Close"]'))).click()
This allows you to wait for button appearance and click the button
Post a Comment for "Python Selenium Closing A Pop-up Window"