How to count starts inside a pseudo element

Hi,

I am trying to locate this element but this is a pseudo element, the stars in rating

I want to count starts in rating field, is there any way I can do it

I am using Robot framework that have selenium library inside
image

Thank you

Can you share the underlying html? You might be able to find an element that contains the value or another method would be to find a JavaScript function which can retrieve the data or interact with the rating widget to obtain its rating.

1 Like

Advanced Topics?


That is a little odd in that I don’t see any data there. The ::after is generally used for add-on characters and not for the data. They may be using it here but I don’t see how. I would explore the page a bit to see where the data is for the rating (or if they are indeed using the ::after then how does the mechanism work leading to how to get the value).

Every time I reload the page the rating is different, can you look at the link here:

Advanced Topics?

Thank you

Sorry I didn’t realize that was a link to an example page. Was looking at that now. Well the rating is part of the element’s property content. And exploring though the devtools I see there is javascript for the page which they use to verify you have the right answer which one could in turn use to get the answer

 window.getComputedStyle(
                    document.querySelector('label.star-rating'), ':after'
                ).getPropertyValue('content');

I would think that this might work then

Execute Javascript   return  window.getComputedStyle(document.querySelector('label.star-rating'),':after').getPropertyValue('content');
1 Like

To me, and this is just from a quick glance, it seems like this is style of the element and a particular value within that style.

[Need to go offline and hike through our snow … be back online in a few hours … good luck!]

1 Like

Thank you, Have a great time