Sadboy
Sadboy

Reputation: 11

Python selenium find text on page

I have a problem with finding text on page. I found solution for single occurrence like:

   if  "tutu"  in driver.page_source:
   else:

But now I'm looking for some solution to find 2 same text. ("tudu" and other "tudu")

Upvotes: 0

Views: 127

Answers (1)

John Gordon
John Gordon

Reputation: 33359

Use the count() string method.

if driver.page_source.count("some text") == 2:

Incase, two or more than two is okay:

if driver.page_source.count("some text") >= 2:

Upvotes: 2

Related Questions