XPATH

Requirement-
In the below html code, I have to write the xpath for selecting the span (with data value as 6,7,8,9,10,18,19,20,21,22 ) tags present inside td tags where td class=”closeTrigger” and tr class is not “week-selected”.

HTML code-
<tr>
<td class=”weekend closeTrigger”>
<span>5</span></td>
<td class=”closeTrigger”>
<span>6</span></td>
<td class=”closeTrigger”>
<span>7</span></td>
<td class=”closeTrigger”>
<span>8</span></td>
<td class=”closeTrigger”>
<span>9</span></td>
<td class=”closeTrigger”>
<span>10</span></td>
<td class=”weekend closeTrigger”>
</tr>
<tr class=”week-selected”>
<td class=”weekend closeTrigger date-selected”>
<span>11</span></td>
<td class=”closeTrigger”>
<span>12</span></td>
<td class=”closeTrigger”>
<span>13</span></td>
<td class=”closeTrigger todays-date”>
<span>14</span></td>
<td class=”closeTrigger”>
<span>15</span></td>
<td class=”closeTrigger”>
<span>16</span></td>
<td class=”weekend closeTrigger”>
</tr>
<tr>
<td class=”weekend closeTrigger”>
<span>17</span></td>
<td class=”closeTrigger”>
<span>18</span></td>
<td class=”closeTrigger”>
<span>19</span></td>
<td class=”closeTrigger”>
<span>20</span></td>
<td class=”closeTrigger”>
<span>21</span></td>
<td class=”closeTrigger”>
<span>22</span></td>
<td class=”weekend closeTrigger”>
</tr>

amitjain Supporter Asked on March 11, 2015 in Selenium WebDriver.
Add Comment
2 Answer(s)

You may be looking at identifying element based on the position like this

driver.findElementByXPath(“//*[@class=’closeTrigger’][position()=1]”);

Virender

Virender Singh Professor Answered on March 11, 2015.

No Sir, I am not looking for specific position xpath

I want xpath for selecting the span with data value as 6,7,8,9,10,18,19,20,21,22 , only 1 xpath

on March 12, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.