简体   繁体   中英

Why is my XPath using following-sibling not working?

I need to select the next input field and the A field, following the active page (class="active_page") on the two sample HTML code below, but the following two XPath are not working.

How would I accomplish the following-sibling and what is the easiest way of doing this?

//*[@id="pagination"]/ul/li[2]/a/following-sibling::A[1]

<div id="pagination">
   <ul class="zPagination">
      <li><a href="https://www.test.com/page&pagination=10">«</a></li>
      <li><a class="active_page" href="https://www.test.com/page&pagination=10">1</a></li>
      <li><a href="https://www.test.com/page&pagination=10">2</a></li>
      <li><a href="https://www.test.com/page&pagination=10">3</a></li>
      <li><a href="https://www.test.com/page&pagination=10">»</a></li>
   </ul>
</div>

//TABLE[@class='table-striped']/TBODY[1]/TR[1]/TD[1]/INPUT[1]/following-sibling::INPUT[1]

<table class="table-striped">
   <tbody>
      <tr>
         <td><input id="selection" style="width: 20px;" name="test" class="zeroborder" value="001" type="radio"> </td>
         <td>S</td>
      </tr>
      <tr>
         <td><input id="selection" style="width: 20px;" name="test" class="zeroborder" value="002" type="radio"> </td>
         <td>S</td>
      </tr>
      <tr>
         <td><input id="selection" style="width: 20px;" name="test" class="zeroborder" value="003" type="radio"> </td>
         <td>S</td>
      </tr>
   </tbody>
</table>

There are (at least) two errors with your XPaths:

  1. XPath and XML are case sensitive.
  2. There are no following-siblings a or input elements. Perhaps you meant just following .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM