Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

1 like 0 dislike
158 views
by Contributing Tester (22 points)
How useful is collections in selenium while executing test cases?

1 Answer

0 like 0 dislike
by Master (1.2k points)
We have widely used List & Map so from my experience I can say that collection comes very handy and makes life easier while using selenium.

Before collection, we used to have arrays to store objects. But, we always had to deal with the size of an array and adding and removing an object.

With collections, it is easy to add/remove the object.

E.g. I can just say driver.findElements(By.id("some ID")); and it will return me List<WebElement>. To get the first element I can say list.get(0); to remove it, I can simply use list.remove() function.

In the same way, Hashmap can help me retrieve data in a key > value pair format. It comes very handily when you are using TestNG dataProvider.


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

...