2

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?

Rubens
  • 14,478
  • 11
  • 63
  • 92
user3587233
  • 253
  • 1
  • 2
  • 13

1 Answers1

2

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.

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • Hi Alec, Can you please look at and let me know if you can help please....http://stackoverflow.com/questions/26742148/system-is-unable-to-find-the-element-for-the-second-time?noredirect=1#comment42077930_26742148 – user3587233 Nov 05 '14 at 02:50