简体   繁体   中英

How can I locate the Cancel button with below mentioned properties through Selenium WebDriver and Java

The button HTML is:

<button class="ui-button ui-corner-all ui-widget" type="button">Cancel</button>

I tried with Class name locator and link text as well, please help.

You can locate the button with either of the following solutions:

  • cssSelector :

     driver.findElement(By.cssSelector("button.ui-button.ui-corner-all.ui-widget[type='button']"));
  • xpath :

     driver.findElement(By.xpath("//button[@class='ui-button ui-corner-all ui-widget'][contains(text(),'Cancel')]"));

您可以尝试使用以下 xpath 定位元素:

driver.findElement(By.xpath("//button[contains(@class,'ui-button ui-corner-all')]"));

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