I'm trying to click on a button with selenium and java but it doesn't find the element
I tried to locate to the button by id ("YES")
and by xpath ("//*[@id=\"YES\"]")
but selenium doesn't find it.
I also verified that the button isn't inside iFrame.
This is my code:
@FindBy(xpath="//*[@id=\"YES\"]")
public static WebElement btnConfirmExistingRequest;
btnConfirmExistingRequest.click()
This is the HTML:
<div class="messagebox-buttons">
<a **id="YES"** acsfuncid="" acsright="NONE" isbutton="Y" default="Y" onclick="if (isClassSet(this,
'disabled')) return false;nop()" classorig="a_buttonmessage" onmouseover="return new
Button(this).onMouseOver();" onmouseout="return new Button(this).onMouseOut();"
onmousedown="return new Button(this).onMouseDown();" class="a_buttonmessage default" title=""
style="cursor: default;"><span class="spanlabel_buttonmessage" id="spanlabel_YES"><img
src="/acmweb/ajax/images/button_empty.gif" class="img_buttonmessage nomargin"
id="img_YES">כן</span></a><a id="NO" acsfuncid="" acsright="NONE" isbutton="Y" onclick="if
(isClassSet(this, 'disabled')) return false;nop()" classorig="a_buttonmessage"
onmouseover="return new Button(this).onMouseOver();" onmouseout="return new
Button(this).onMouseOut();" onmousedown="return new Button(this).onMouseDown();"
class="a_buttonmessage" title=""><span class="spanlabel_buttonmessage" id="spanlabel_NO"><img
src="/acmweb/ajax/images/button_empty.gif" class="img_buttonmessage nomargin"
id="img_NO">לא</span></a>
</div>