2016-05-25 46 views
0

HTML代码按钮提交在JSP:按钮无法点击或没有得到任何回应

<button type="button" class="btnInactive" name="Save" id="saveGrid" 
    onclick="saveList()"> 
<img src="<c:url value="/images/save.png" />" alt="Save" title="Save" 
    class="vMiddle padRight5"> <spring:message code="label.save"/></button> 

HTML代码鼠标悬停按钮:

<button onclick="saveList()" id="saveGrid" name="Save" class="btnInactive" 
    type="button" disabled="disabled"> 
    <img class="vMiddle padRight5" title="Save" alt="Save" 
    src="/web/images/save.png"> Save </button> 

我尝试这样做:

driver.findElement(By.xpath(".//*[@id='saveGrid']/img")).click(); 
WebDriverWait wait = new WebDriverWait(driver, 15); 
wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("button#saveGrid"))); 
driver.findElement(By.cssSelector("button#saveGrid")).click(); 
+4

您收到了什么样的错误? – Hellzzar

+0

没有错误投掷。测试套件显示为Success并且在控制台中没有错误或显示插入查询。 – kurri

+0

我不能看到一个关闭按钮标签 –

回答

0

这可能是因为可能还有一个屁股在相同的属性上,所以尝试找到唯一的元素,然后尝试。 例如:当时有两个按钮具有相同的属性,webdriver会失败,所以用户在多个元素具有相同属性的情况下尝试使用相对xpath唯一地查找元素