0

I have html o page:

<div id="foo" class="bar" title>
  ::before
</div>

With Chrome or Firefox on selection ::before I can see css on Styles tab:

.SomeTitle .bar::before{
content: "required_value"
}

After selection <div id="foo" class="bar" title> it presented in Pseudo ::before element. I did try to get value of content:

browser = webdriver.Firefox()
browser.get(my_url)
my_element = browser.find_element_by_xpath("//*[@id='foo']")
my_elemet.value_of_css_property("content")

But it does returns none. How can I get value of content?

nick_gabpe
  • 5,113
  • 5
  • 29
  • 38
  • This is not duplicate. I want use python selenium not jquery. – nick_gabpe May 05 '17 at 11:19
  • Try this: http://stackoverflow.com/questions/28244911/selenium-webdriver-get-text-from-css-property-content-on-a-before-pseudo-ele – Pete May 05 '17 at 11:29

1 Answers1

2

Looks like I did find solution. This is not pure selenium but it does works.

browser.execute_script("return window.getComputedStyle(document.querySelector('.SomeTitle .bar'),':before').getPropertyValue('content')")

Hope this will helps to someone.

nick_gabpe
  • 5,113
  • 5
  • 29
  • 38