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?

2
  • This is not duplicate. I want use python selenium not jquery. Commented May 5, 2017 at 11:19
  • Try this: stackoverflow.com/questions/28244911/… Commented May 5, 2017 at 11:29

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.