Skip to content Skip to sidebar Skip to footer

Python Selenium: Find Object Attributes Using Xpath

I am new to xpath, trying to get value of the 'value' using xpath: while i

Solution 1:

I finally used get_attribute("value") as:

foriinbrowser.find_elements_by_xpath("//*[@type='submit']"):
    printi.get_attribute("value")

Solution 2:

It would be like this

browser.find_elements_by_xpath("//*[@type='submit']/@value").text

Update:

With the function used by you, we can only extract the element not its attribute. To get its attribute, the expression should be something like this

browser.find_elements_by_xpath("//*[@type='submit']").get_attribute("value")

Ref: http://selenium-python.readthedocs.org/en/latest/api.html#selenium.webdriver.remote.webelement.WebElement.find_elements_by_tag_name

Post a Comment for "Python Selenium: Find Object Attributes Using Xpath"