【问题标题】:Need to find a way to click on the message button using selenium with python需要找到一种使用selenium和python点击消息按钮的方法
【发布时间】:2017-06-19 17:43:20
【问题描述】:
<button aria-label="Send message to Francesca Felder" class="message-anywhere-button mn-person-card__person-btn-ext button-secondary-medium link-without-visited-state" data-ember-action="" data-ember-action-1634="1634">
<span aria-hidden="true">Message</span>
<span class="visually-hidden">
    Send a message to Francesca Felder
</span>

上面是我尝试使用 Selenium Webdriver 点击的按钮类。

我试过这样做:

clickit = wait(browser, 10).until(EC.element_to_be_clickable((By.XPATH, "//button[span='Send a message to']")))
clickit.click()

它根本不起作用。

【问题讨论】:

  • 尝试点击css选择器 - by.css("message-anywhere-button mn-person-card__person-btn-ext button-secondary-medium.link-without-visited-state")

标签: python selenium xpath selenium-webdriver automation


【解决方案1】:

试试这个:

//button[span="Message"] 感谢安德森

//button//span[contains(text(), 'Send a message to')]

【讨论】:

  • 感谢您的回复,但我收到此异常:raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message:
  • 试试这个//span[contains(text(), 'Send a message to')],或者你能不能把整页的源码贴出来,会有很大帮助的
  • 仍然不起作用,并且确定这是消息按钮类的来源,它也在问题中,但它是:
  • 粘贴整个网页源码,当前选择器可能选择了多个元素,所以完整源码
  • 请试试这个看看,//button[contains(@aria-label, 'Send message to')]
猜你喜欢
  • 2018-10-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-07-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-08-14
相关资源
最近更新 更多