【问题标题】:Selenium Webdriver (JAVA) - its getting impossible to click on SPAN CLASSSelenium Webdriver (JAVA) - 无法点击 SPAN CLASS
【发布时间】:2019-02-27 23:34:04
【问题描述】:

下面是我的代码:

//<span class="ui-button-text">Export</span>

我尝试使用以下代码在所有级别单击“导出”按钮,但它根本不起作用。请指教..

Driver.findElement(By.xpath("//span[@class='ui-button-text']")).click();
Driver.findElement(By.xpath("Driver.findElement(By.xpath("//span[@class='ui-button-text']\")).click();

xpath 不工作!任何其他方式表示赞赏..

【问题讨论】:

    标签: java selenium xpath css-selectors webdriver


    【解决方案1】:

    根据您共享的 HTML,单击带有 Export 文本的元素,您可以使用以下任一解决方案:

    • cssSelector:

      Driver.findElement(By.cssSelector("span.ui-button-text")).click();
      
    • xpath:

      Driver.findElement(By.xpath("//span[@class='ui-button-text' and contains(.,'Export')]")).click();
      

    【讨论】:

      猜你喜欢
      • 2016-08-26
      • 1970-01-01
      • 2015-04-25
      • 1970-01-01
      • 2016-11-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-10
      相关资源
      最近更新 更多