I am very new to Selenium and I am asking your kind advice.
I have the following html:
<div class="order">
<a style="float: left;" href="#137674" class="voidCmn ui-button ui-corner-all ui-widget" role="button">Void</a>
<a style="float: left;" href="printcmn.php?Id=137674" target="_blank" class="ui-button ui-corner-all ui-widget" role="button"> Print </a>
<a style="float: left;" href="section_a.php?cmnId=137674&origin=viewreferral.php" class="ui-button ui-corner-all ui-widget" role="button"> Edit </a>
</div>
In that scenario I would like to use cssSelector and not an xpath.
My code to find web element button Edit (see above):
Driver.findElement(By.cssSelector("a.ui-button.ui-corner-all.ui-widget[role='button'][href^='viewreferral.php']"));
However, I am getting an error:
no such element: Unable to locate element: {"method":"css selector","selector":"a.ui-button.ui-corner-all.ui-widget[role='button'][href^='viewreferral.php']"}
Could you kindly review and tell me what is wrong.
CodePudding user response:
Please use below given css Selector, It should work :
a.ui-button.ui-corner-all.ui-widget[role='button'][href*='viewreferral.php']
You have used wrong operator to check contains. You used : ^
But it should be *