I have text displayed in a GUI. I identified the element using its XPATH from Xpath Checker from Firebug. The item is highlighted correctly. In my code, I use a text attribute to print its value. I would like to print the value on the console. When I view the code using the PyCharm debugger, I see that the attribute of the variable text is empty. Why didn't the variable get a text value?
My code snippet:
def is_engine_number_displayed(self):
engine_no_element = self.get_element(By.XPATH, '//a[contains(., "Engine: 5.1.1")]')
print "engine_no_element.text***"
print engine_no_element.text
HTML:
<div class="GJPPK2LBKQ">
<a class="gwt-Anchor GJPPK2LBMQ" title="Click for about">Client: 5.1.1.6044</a>
<a class="gwt-Anchor GJPPK2LBMQ" title="Click for about">Engine: 5.1.1.5218</a>
My XPATH to find the text Engine: 5.1.1
Using XPATH, Engine: 5.1.1 text is highlighted in a graphical interface
get_element is in my base class. This is the implementation:
def get_element(self, how, what):
try:
element = self.driver.find_element(by=how, value=what)
except NoSuchElementException, e:
print what
print "Element not found "
print e
screenshot_name = how + what + get_datetime_now()
self.save_screenshot(screenshot_name)
raise
return element
Why is my text element value empty?
Thanks Riaz