Get second event from FullCalendar by xpath

孤街浪徒 提交于 2019-12-11 16:07:48

问题


I have FullCalendar in my project: https://www.primefaces.org/primereact/#/fullcalendar

I have 2 events at one day, I found first event by this code:

//tbody//td[count(//thead//td[@data-date='2019-08-06']/preceding-sibling::*)+1] 

And I need to find second or more events.

<table>
 <thead>
  <tr>
   <td data-date="2019-08-05"></td>
   <td data-date="2019-08-06"></td> 
   <td data-date="2019-08-07"></td> 
   <td data-date="2019-08-08"></td> //find index of this element
   <td data-date="2019-08-09"></td>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td rowspan="2"></td>
   <td rowspan="2" class="rrrr">event1 2019-08-06</td>
   <td class="rrrr">event1 2019-08-07</td>
   <td class="rrrr">event1 2019-08-08</td> //find this element by found index
   <td rowspan="2"></td>
  </tr>
  <tr>
    <td class="rrrr">event2 2019-08-07</td>
    <td class="rrrr">event2 2019-08-08</td> //find this element by found index
  </tr>
 </tbody>

UPD How work //div[@class='fc-content-skeleton'][.//td[@data-date='2019-09-03']]//tbody/tr/td[count(//thead//td[@data-date='2019-09-03']/preceding-sibling::*)+1] at second day


回答1:


I would use the below xpath to get all the events and then iterate them. So, you don't have to worry even if the events' count change between the dates.

//div[@class='fc-content-skeleton'][.//td[@data-date='2017-02-12']]//tbody/tr/td[count(//thead//td[@data-date='2017-02-12']/preceding-sibling::*)+1]

Screenshot:

If you want to access any specific event then you can do it using the index as shown below. (wrapped entire xpath in () and then provide the index in []).

(//div[@class='fc-content-skeleton'][.//td[@data-date='2017-02-12']]//tbody/tr/td[count(//thead//td[@data-date='2017-02-12']/preceding-sibling::*)+1])[2]



来源:https://stackoverflow.com/questions/57757779/get-second-event-from-fullcalendar-by-xpath

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!