While printing the WebElement texts, why does adding toString() to getText() of a WebElement give a different output when not adding it?

Viewed 25

I wrote a code to print all the texts(country list) present with the WebElement (div) list, using getText() without adding toString() to it prints some of the initial countries in the list not all, but if toString() is added to getText() then all the countries are printed, why is there a difference in the output, without using toString() prints some initial countries but why not all?

for(WebElement w : fromCountriesList)
 System.out.println(w.getText().toString());

The source code snippet can be seen hereenter image description here

0 Answers
Related