0

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>
Lior p
  • 45
  • 6
  • Did you add the asterisks around the id your self or is that hin the html? – DMart Oct 26 '20 at 16:33
  • Try to edit xpath to //*[@id='YES'] or use WebDriverWait – Yun Oct 27 '20 at 03:17
  • Refer to: https://stackoverflow.com/questions/11736027/webdriver-wait-for-element-using-java – Yun Oct 27 '20 at 03:18
  • 1. I added the asterisks ,i tried that it will be in bold 2. I tried //*[@id='YES'] , selenium still doesn't recognize the button 3. I have implicitlyWait of 10 seconds – Lior p Oct 27 '20 at 09:16

0 Answers0