Lolpez
Lolpez

Reputation: 879

How to get an element using CSS or Xpath by removing a specific text?

I need to get an element using CSS or XPath by searching by its text inside a list, each element contains the Project Name, the Status and the Country separated with the character "|".

The problem is that I have to get an element by only using the Project Name and the Country as parameters and there is no way to edit the HTML.

<li>Project 1 | approved | USA</li>
<li>Project 2 | approved | China</li>
<li>Project 3 | disapproved | Russia</li>

What I need is to remove the approved/disapproved text from the query, something like

//li[contains(text(),'Project 1 USA')]

Is there a way to achieve this using CSS or Xpath?

Upvotes: 1

Views: 141

Answers (1)

marswoody
marswoody

Reputation: 103

How about:

//li[contains(text(),'Project 1') and contains(text(),'USA')]

...if you are able to separate the project name and location?

Upvotes: 2

Related Questions