硒无法成功单击按钮

时间:2020-10-26 13:52:09

标签: java selenium click

我试图单击带有硒和Java的按钮,但找不到元素
我试图找到按钮by id ("YES")by xpath ("//*[@id=\"YES\"]"),但硒找不到它。
我还验证了该按钮不在iFrame中。

这是我的代码:

@FindBy(xpath="//*[@id=\"YES\"]")
public static WebElement btnConfirmExistingRequest;

btnConfirmExistingRequest.click()

这是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>

0 个答案:

没有答案