'Getting the size of a text with Selenium

So im stuck with something very basic. Im trying to determine the width of a text contained in a div with a image. The thing is, the width of the paragraph is the same as the one of the div element, but the text is wrapped in another width. Is there any option to get the width I want.

This is the width of the paragraph:enter image description here

But the width I want is something like this: enter image description here

The page of reference is this one: https://wikifaunia.com/aves/como-cuidar-a-un-agaporni/

Thanks in advance



Solution 1:[1]

i think you can with just math.

  • The total width of the div (text with the image) is : 787px
  • The with of the image is 300px and your have a margin left of 30px so the total is 330px.

So 787 - 330 = 457.

Your text width is 457px.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Christophe Gibelli