How to get attribute of element from Selenium?

0
0

I’m working with Selenium in Python. I would like to get the .val() of a <select> element and check that it is what I expect.

This is my code:

def test_chart_renders_from_url(self):
url
= 'http://localhost:8000/analyse/'
self
.browser.get(url)
org
= driver.find_element_by_id('org')
# Find the value of org?

How can I do this? The Selenium docs seem to have plenty about selecting elements but nothing about attributes.

  • You must to post comments
0
0

You are probably looking for get_attribute(). An example is shown here as well

def test_chart_renders_from_url(self):
url
= 'http://localhost:8000/analyse/'
self
.browser.get(url)
org
= driver.find_element_by_id('org')
# Find the value of org?
val
= org.get_attribute("attribute name")
  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website