【问题标题】:How to click on span class using VBA Selenium如何使用 VBA Selenium 单击跨度类
【发布时间】:2021-05-03 11:42:45
【问题描述】:

我需要点击“exportar”按钮。我该怎么做?

<div class="ui-dialog-buttonset"><button type="button" title="" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only button-default" role="button" aria-disabled="false"><span class="ui-button-text">Exportar</span></button><button type="button" title="" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only button-cancel" role="button" aria-disabled="false"><span class="ui-button-text">CANCELAR</span></button></div>

我一直在尝试,但到目前为止一无所获。喜欢

bot.FindElementByXPath("//div[@class='ui-dialog-buttonset']/following-sibling::button/span").Click

bot.find_element_by_xpath ("//span[text()='Exportar']")

【问题讨论】:

  • 试试这个 bot.find_element_by_css_selector('span.ui-button-text')

标签: vba selenium selenium-webdriver xpath css-selectors


【解决方案1】:

到元素上的click(),文本为Exportar,您可以使用以下任一Locator Strategies

  • 使用FindElementByCss

    bot.FindElementByCss("div.ui-dialog-buttonset > button.ui-button.ui-widget.ui-state-default.ui-corner-all.ui-button-text-only.button-default > span.ui-button-text").click
    
  • 使用FindElementByXPath

    bot.FindElementByXPath("//button[@class='ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only button-default']/span[@class='ui-button-text' and text()='Exportar']").click
    

【讨论】:

猜你喜欢
  • 2021-08-10
  • 2020-02-13
  • 2018-12-15
  • 2021-11-09
  • 2015-01-16
  • 1970-01-01
  • 2019-12-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多