selenium与python如何单击弹出按钮
我已经尝试了很多可能的情况,但我无法访问它,请帮助我解决这个问题,我如何可以点击常见的主页res布局-home1加载隐藏滚动模式打开这里我想点击(添加到购物车)和(愿望列表)我的代码如下selenium与python如何单击弹出按钮,python,selenium,automation,screen-scraping,Python,Selenium,Automation,Screen Scraping,我已经尝试了很多可能的情况,但我无法访问它,请帮助我解决这个问题,我如何可以点击常见的主页res布局-home1加载隐藏滚动模式打开这里我想点击(添加到购物车)和(愿望列表)我的代码如下 from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import Select from selenium.webdriver
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)")
等待窗口出现,然后使用显式等待单击它
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")))