3 回答

TA贡献1780条经验 获得超1个赞
您可以使用显式等待按钮来完成此操作:
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//*[@id='u_0_8']"))).click()
我希望它能帮助你!

TA贡献1840条经验 获得超5个赞
所需的元素是动态元素,因此要单击该元素,您需要引发WebDriverWait ,并且element_to_be_clickable()可以使用以下任一 定位器策略:
使用CSS_SELECTOR:
driver.get('https://help.instagram.com/contact/723586364339719/')
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button[type='submit']"))).click()
使用XPATH:
driver.get('https://help.instagram.com/contact/723586364339719/')
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//*[@value='1' and normalize-space()='Send']"))).click()
注意:您必须添加以下导入:
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
浏览器快照:

TA贡献1854条经验 获得超8个赞
而不是这个:
submit_button = driver.find_element_by_xpath('//*[@id="u_0_8"]')
submit_button.click()
尝试这个:
driver.find_element_by_id("id='u_0_8']").click()
- 3 回答
- 0 关注
- 136 浏览
添加回答
举报