【问题标题】:Selenium python navigation硒 python 导航
【发布时间】:2021-12-06 23:22:32
【问题描述】:

我想转到 Aliexpress 网站上产品类别中的下一页。但是会出现错误。如何解决?

from selenium import webdriver
from selenium.webdriver.common.by import By
import time
def main():
    driver = webdriver.Chrome()
    driver.get('https://aliexpress.ru/category/202003912/blouses-shirts.html?page=2')
    el = driver.find_element(By.CLASS_NAME, "SearchPagination_SearchPagination__particularPageInput__16999")
    el.send_keys("5")
    time.sleep(5)
    el = driver.find_element_by_xpath('//button[text()="OK"]')
    el.click()
main()

结果:

...\temp.py", line 12, in main
    el.click()
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
  (Session info: chrome=94.0.4606.81)

【问题讨论】:

    标签: python selenium pagination


    【解决方案1】:

    查看 aliexpress 页面并在页面上查找 xpath 后,似乎找到了两个不同的元素,使用完整的 xpath 或其他方法可能会起作用,但是您可以尝试使用返回的 find elements 方法一个列表然后与第二个元素交互。

    el = driver.find_elements_by_xpath('//button[text()="OK"]')[1]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-12
      • 2020-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-24
      • 1970-01-01
      相关资源
      最近更新 更多