Reputation: 263
I am very new to coding. We are using selenium tool writing scripts in python.
I have the following code for a single web element:
element = driver.find_element_by_css_selector("locator")
height = element.get_attribute('height')
print height
Now I have my xpath expression that is returning 8 items for which I have to print the "height" attribute. How can I do this in python?
Upvotes: 2
Views: 1137
Reputation: 473873
Use find_elements_by_css_selector()
:
for element in driver.find_elements_by_css_selector("locator"):
height = element.get_attribute('height')
print height
or, find_elements_by_xpath()
if you have an xpath
expression.
Upvotes: 2