popup open but not closed, please help me to close the popup. only issue is coming here popup not closed.
color=”accent” class=”mat-focus-indicator mat-button mat-button-base mat-accent”>… is not clickable at point (684, 847). Other element would receive the click:
(Session info: chrome=124.0.6367.61) explain the error
# Import necessary modules
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from webdriver_manager.chrome import ChromeDriverManager
import csv
import time
# Set up Chrome service
service = webdriver.chrome.service.Service(ChromeDriverManager().install())
# Initialize Chrome WebDriver with the service
driver = webdriver.Chrome(service=service)
# Navigate to the webpage
driver.get("https://mmiconnect.in/app/exhibition/catalogue/ep2023")
# Close the initial popup if present
try:
# Find and click the close button if it's clickable
close_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CLASS_NAME, "close-button")))
close_button.click()
except:
# If close button not found, pass
pass
# List to store the scraped data
siteData = []
# Iterate over pages
for nav in range(1, 33):
for i in range(1, 750):
try:
# Find and click on the buttons
listing = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, 'center')))
lists = listing.find_elements(By.XPATH, "//div[@class='courses']//button[contains(@class, 'mat-focus-indicator')]")
# Iterate over the buttons
for listss in lists:
try:
# Click on the button
listss.click()
# Wait for the popup to appear
time.sleep(2)
# Check if the popup is still open
if EC.visibility_of_element_located((By.ID, "mat-dialog-3"))(driver):
# Wait for the popup to appear
popup_element = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "mat-dialog-3")))
# Scrape data from the popup
table = popup_element.find_element(By.ID, "customers")
rows = table.find_elements(By.TAG_NAME, "tr")
table_data = []
for row in rows:
cells = row.find_elements(By.TAG_NAME, "td")
row_data = [cell.text for cell in cells]
table_data.append(row_data)
# Write table data to CSV
with open("mmei.csv", mode='a', newline='') as file:
writer = csv.writer(file)
writer.writerows(table_data)
# Execute JavaScript to click the "Close" button within the popup
close_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//button[contains(@aria-label, 'Close dialog')]")))
driver.execute_script("arguments[0].click();", close_button)
except Exception as e:
# Print error if any
print("Error processing popup:", e)
pass
except Exception as e:
# Print error if any
print("Error iterating over pages:", e)
continue
# Quit the driver
driver.quit()