在单击插入标签内的“中止”按钮时需要帮助。尝试使用Xpath,名称和值。插入标签中没有ID

driver.findElement(By.xpath(“ html / body / div [1] / div / table / tbody / tr / td / table [5] / tbody / tr [3] / td [1] / form / table [2 ] / tbody / tr [9] / td [2] / input“)。click(); - 不工作

<body>
<noscript/>
<!--/DO NOT REMOVE/-->
<!-- End SiteCatalyst code version: H.22. -->
<!--END HTML HEADER-->
<script type="text/javascript">   $(document).ready(function () { SLM.ON.FWF.HTMLPage.initialize(); }) </script>
<div class="DIVBackGround">
<div class="DIVPrimaryArea">
<noscript> <table border="0" cellspacing="0" cellpadding="0" width="762"> <tr> <td width="324"></td> <td width="416"> <font color="red">Your browser's security settings do not allow JavaScript. You must change the settings to support JavaScript in order to use this application.</font> </td> </tr> </table> </noscript>
<!-- PARENT CONTAINER TO MANAGE WIDTH OF SECTIONS-->
<table cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td>
<!--BEGIN HEADER-->
<table class="TableHeader" cellspacing="0" cellpadding="0" border="0" width="1012">
<table cellspacing="0" cellpadding="0" border="0" width="1012">
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<table cellspacing="0" cellpadding="0" border="0" width="1012">
<!--END HEADER-->
<!--BEGIN WORKSPACE -->
<table class="TableBody" cellspacing="0" cellpadding="0" border="0" width="1012">
<tbody>
<tr>
<tr>
<tr>
<td>
<form name="mainform" method="POST" action="/QUERY/?CharSet=ENGLISH&AppMode=SLM&TS=5%2f30%2f2017+10%3a53%3a26+AM" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<input name="SessionID" value="511036a7eec646b79ef2fe388928dd39" type="hidden"/>
<input name="StateID" value="431DCC44-5ED0-46EF-A42A-CB3FDE441083:3cbf085a-eb1a-4360-a35d-0c110a9593a0" type="hidden"/>
<input name="EntryPointName" value="" type="hidden"/>
<input name="Selection" value="SearchAgain" type="hidden"/>
<input name="Key" value="" type="hidden"/>
<input name="Name" value="" type="hidden"/>
<input name="PrevPage" value="ServicingLoanSummary" type="hidden"/>
<input name="PageStack" value="" type="hidden"/>
<table cellspacing="0" cellpadding="0" border="0" width="762">
<table cellspacing="0" cellpadding="0" border="0" width="762">
<tbody>
<tr>
<tr>
<tr>
<tr>
<tr>
<tr>
<tr>
<tr>
<tr>
<td/>
<td class="NavigationButtons" colspan="3">
<input class="ButtonLabel" name="btnDiscontinue" value="Discontinue" onclick="SLM.ON.QUERY.SubmitPage('Discontinue')" type="button"/>
</td>
</tr>
</tbody>
</table>

最佳答案

你可以试试看吗? driver.findElement(By.xpath("//input[contains(@value, 'Discontinue')]")).click();

08-18 21:10