【问题标题】:Cannot find next button on the page在页面上找不到下一步按钮
【发布时间】:2019-07-06 18:38:13
【问题描述】:

我正在尝试使用 Python 和 Selenium 从 LinkedIn 抓取数据。

在页面上获取名称后,我想找到“下一步”按钮并单击它。

“下一步”按钮位于下面突出显示的文本中(顺便说一下,这是来自 Firefox 页面):

所以我这样做:

next_button_find=browser.find_element_by_class_name('next')
next_button_find.click()

但在执行时会出现此错误:

我也尝试过基于这个post:

next_button_find=browser.find_elements_by_class_name('next')
next_button_find.click()

AttributeError: 'list' 对象没有属性 'click'

提前谢谢!

【问题讨论】:

  • 这个元素的类是artdeco-button__text,而不是next。它有文本Next,但它不是类名。
  • 文本Next 在标签<span> 中,在标签<button> 中,您应该搜索<button>,因为按钮是可点击的。 <span> 不可点击。
  • 因为这个<button> 有id=ember320 那么你应该使用browser.find_element_by_id('ember320').click()

标签: python selenium class


【解决方案1】:

试试下面的代码:

next_button_find = browser.find_element_by_css_selector(".artdeco-pagination__button--next")
next_button_find.click()

PS:id (ember320) 看起来像是动态的。

希望对你有帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-06-25
    • 1970-01-01
    • 2022-08-18
    • 2021-02-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多