【发布时间】:2022-06-22 22:35:15
【问题描述】:
我遇到了问题 - 使用implicitly_wait 时不会单击“添加到包”按钮。如果我使用 time.sleep,一切正常,但 time.sleep 是不好的方法。 那么,我需要什么?获取 URl,单击设备,单击“添加到包”按钮。 是的,我知道https://selenium-python.readthedocs.io/waits.html 和https://www.selenium.dev/documentation/webdriver/waits/,但这对我没有帮助。请帮帮我)
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.common.exceptions import TimeoutException
from selenium.common.exceptions import WebDriverException
import time
try:
browser = webdriver.Chrome()
browser.maximize_window()
browser.get("https://www.oumua.me/shop")# Get URL
browser.implicitly_wait(10)
browser.find_element(By.XPATH, '//*[@id="__next"]/div[2]/div/div[1]/div[1]').click() #Click on device button
browser.find_element(By.XPATH, '/html/body/div[1]/div[2]/div[3]/div[1]').click() #Click Add to the bag that doesn't working
【问题讨论】:
标签: python selenium selenium-webdriver