0

I want to find all elements in the table that match the following conditions:

-div text contains '2019';

-div class='excellent';

here is the HTML code excerpt:

<tr>
    <td>Name of Person1</td>
        <td>
        <div class="testDate">21/12/2019</div>
        <div class="excellent"></div>
    </td>
</tr>
<tr>
     <td>Name of Person2</td>
         <td>
         <div class="testDate">01/12/2017</div>
     </td>
</tr>

I tried this solution:

//tr/td[2][div/text()='21/12/2019'][div[@class='starred']]

but I need the year only and not entirely date.

2
  • Hi Gregory, See this xpath example for containing text, rather than equaling text. guru99.com/… Commented Apr 14, 2020 at 0:20
  • @Gregory, Please add your expected output. Commented Apr 14, 2020 at 3:10

1 Answer 1

2

Use the below xpath.

//tr/td[div[contains(.,'2019')]and div[@class='excellent']]

Screenshot:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.