'Can´t access pseudo ::before ::after element in Selenium

I want to get the text within a var tag which lies within a pseudo class: ::before ... <var class="added">Element</var> .. ::after

I tried How locate the pseudo-element ::before using Selenium Python And also the usual ways like:

x = driver.find_elements_by_class_name("added")

elem = [i.text for i in x]

Or trying to access it via the parent element. I always get an empty list as a result. Does anyone here have an idea what I´m doing wrong?

Thanks a lot!



Solution 1:[1]

Have you tried beautiful soup instead of selenium? This may be a bad workaround but it helped me in many such cases.

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 Chem Hub