Im using Selenium Builder to make a Selenium Test. I want to check if there's some duplicated content on the site. It can be text "This is an example" or div ids "#id_to_catch". How can I do this?
Asked
Active
Viewed 68 times
1 Answers
0
By using the findElements function:
Boolean dups = (driver.findElements(By.xpath("//*[contains(.,'This is an example')]")).size()>1);
![](../../users/profiles/5749062.webp)
Bill Hileman
- 2,630
- 2
- 12
- 21
-
And how this is applied to SeleniumBuilder? – David TG May 10 '17 at 14:41
-
It most likely isn't. My bad, sorry. – Bill Hileman May 10 '17 at 14:44
-
Selenium Builder exports on a JSON format. Can I add that to that format? If yes, I saved the value from and xpath to a variable EXAMPLE1. Can I replace 'This is an Example' to EXAMPLE1 and that's it? – David TG May 11 '17 at 14:21
-
I'm not familiar with Selenium Builder at all, and I also assumed you were using Java with just Selenium. I don't know how your SB works at all. If you can make/pass xpaths then the xpath I provided will return the element or elements that match. It would be up to your SB, I suppose, to determine if the returned value is zero, one, or more elements. My example is how I would accomplish what you are attempting to do just using Java and Selenium WebDriver. – Bill Hileman May 11 '17 at 14:33
-
I can export it to PHP - WebDriver – David TG May 11 '17 at 14:43