简体   繁体   中英

Selenium Webdriver (JAVA) - its getting impossible to click on SPAN CLASS

Below is my code:

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

I tried all levels to click EXPORT button using below code and it won't work at all. Please advise..

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 is not working! any other ways are appreciated..

As per the HTML you have shared to click on the element with text as Export you can use either of the following solutions:

  • cssSelector :

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM