0

I'm trying to count all words which are actually displayed in a UI. I'm aware of code / solutions on how to count text and words using id's from the HTML, but in my case I do only want to count what is really displayed on the screen.

Consider the case of a long text in a p-tag which is placed inside a container. As the container is limited in width and length and the fontsize is fix, only the beginning from the text will be visible in the interface.

Any ideas on how could I count this "visible"/ displayed text, and not all of the text included in the p tag?

I have been thinking about using the height and width of the container, together with line height and fontsize to calculate how many lines are present in the container and therefore approximate the amount of words? But, if possible I would prefer an exact option.

lydiaP
  • 123
  • 1
  • 13
  • Depends a lot, you will have to "train it" to know screen size, pixels and more to determine which sections of the text is visible. I don't mean training as MI/ML/AI – Lars Nielsen Aug 23 '18 at 13:39
  • See if this helps : https://stackoverflow.com/questions/18336956/get-visible-text-of-page-with-selenium-webdriver – Arnaud Aug 23 '18 at 13:43
  • @Arnaud, not exactly what I need, as it would be still return *all* text stored inside a specific div.. – lydiaP Aug 25 '18 at 09:12

0 Answers0