带有 python 的 selenium 如何单击弹出按钮

selenium with python how to to click on a popup button

我已经尝试了很多可能的情况,但我无法访问它,请帮助我解决这个问题,我如何点击 common-home res layout-home1 loaded hidden-scroll modal-open here I want to click on (添加到购物车)和(愿望清单)我的代码在下面

    from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.webdriver import ActionChains
from time import sleep
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import ElementNotVisibleException


driver = webdriver.Chrome(executable_path='C:\Program Files\JetBrains\PyCharm 2021.1.1/chromedriver.exe')


driver.maximize_window()
driver.get("http://esindbaad.com/")
#mouse hour to catagories
beauty = driver.find_element_by_xpath("//*[@id='head-wrapper']/div/div/div/div/ul/li[3]/a")
body = driver.find_element_by_xpath("//*[@id='head-wrapper']/div/div/div/div/ul/li[3]/div/div/div/div/div/div[1]/div[3]/div/ul/li[6]/a")
actions = ActionChains(driver)
actions.move_to_element(beauty).move_to_element(body).click().perform()
#add to wishlist

wish = driver.find_element_by_xpath("//*[@id='content']/div/div[1]/div[1]/div/div[1]/div/button[1]/i")
actions = ActionChains(driver)
actions.move_to_element(wish).click().perform()
#click and view product
product = driver.find_element_by_xpath("//*[@id='content']/div/div[1]/div[1]/div/div[1]/div/a")
actions = ActionChains(driver)
actions.move_to_element(product).click().perform()
# product added to cart button click
driver.switch_to.frame(iframe)
addcart = driver.find_element_by_id("button-cart")
actions = ActionChains(driver)
actions.move_to_element(addcart).click().perform()

wishlist = driver.find_element_by_xpath("//*[@id='product']/div[2]/div[3]/ul/li/a")
actions = ActionChains(driver)
actions.move_to_element(wishlist).click().perform()




driver.execute_script("window.scrollBy(0,document.body.scrollHeight)")

等待 window 出现,然后使用显式等待

单击它
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By

addcart = WebDriverWait(driver, 10).until(
    EC.presence_of_element_located((By.ID, "button-cart")))