0

As explained in the title I am looking for a tag with a specific character string on this site:

My goal is to access a specific result of the search results, which is "PSG" But it does not work and I access the next result.

My goal is to access a specific result from the search results, which is "PSG". But it doesn't work and I get the next result, which is "PSG -19". Here is a screenshot to better understand what I mean: search results for the word "PSG" And here is my current code: player_or_team = WebDriverWait(driver, timeout=15).until(EC.element_to_be_clickable( (By.XPATH,"//div[contains(@class,'searchResults')]/div[contains(@class,'searchResults__section')]/a[contains(@class,'searchResult')]/div[contains(text(), '" + Team + "')]"))) driver.execute_script("arguments[0].click();", player_or_team)

I know that the contains function searches for a sub string and so all search results meet the condition but my goal is to find a tag that has a text equal to a specific string and so to do that I found several methods like: [text()="string"], [.="string"] or [normalized-space()="string] But none of this exception which returns a TimeoutException.

Here are some relevant links that have a similar topic but I don't know why the answer doesn't work for me : topic 1, topic 2 and topic 3

the star
  • 259
  • 1
  • 2
  • 10

1 Answers1

0

contains() only works on strings

before:

//div[contains(@class,'searchResults')]

after:

//div[@class,'searchResults']

vizznet
  • 43
  • 5