Ariel Kovler
Ariel Kovler

Reputation: 13

How can i search with xpath selector both by text and by class

I am trying to reach an element with xpath by matching the element class and the content.

let's say that this is the query for the class //span[contains(@class, "text")].

and this is the query for the content //span[text()[contains(., "Page")]].

but is there anyway i can make one query with both queries?

Upvotes: 0

Views: 692

Answers (1)

Andersson
Andersson

Reputation: 52665

You can use and to combine both predicates as below:

//span[contains(@class, "text") and text()[contains(., "Page")]]

Upvotes: 1

Related Questions