Skip to content Skip to sidebar Skip to footer

Python + Selenium: Get Span Value From "ng-bind"

So I have Selenium code that goes to a page using chrome. Now at that page, there is this HTML; Heloooo How can I get the value

Solution 1:

You can use the following CSS Selector for locating the element:

span[ngbind='pageData.Message']

Code:

element = driver.find_element_by_css_selector("span[ngbind='pageData.Message']")
print(element.text)  # Will print the "Heloooo" value.

Hope it helps you!

Solution 2:

You can try using XPath to get the text of the element:

element1 = driver.find_element_by_xpath("//span[@ngbind='pageData.Message']")
print(element1.text)

It's just another option.

Post a Comment for "Python + Selenium: Get Span Value From "ng-bind""