'Having issues with python selenium and getting text out of the webelement

I am having an issue with python selenium and getting text out of a webelement. I am running python 3.6.8 and selenium 3.141.0.

I am finding a webelement using the xpath and loading it into a test variable (testvar). That test variable is a list of only one index (testvar[0]). I am basically trying to get the text string ('0.000') out of the webelement and into a testtext variable.

Shown below is the current variable output, code, and debug screens. As you can see the testtext variable is blank but the testvar[0] text has '0.000' in it.

I have tried: testtext=testvar[0].text() but this comes back with an error of "'str' object is not callable"

I am not sure what I am doing wrong, but if someone can point out what I am doing wrong, It would be very helpful.

Code, variables, and debug

EDIT: Just for more information, if I change code on line 67 from .text to .tag_name, the testtext variable gets 'uni-view' like I suspected.

FINAL EDIT - SOLUTION The problem ended up being two issues. The first was I was using find_elements_by_xpath and that was giving me the list. The second issue was that I was not giving enough time between when I requested the webpage and when I started finding the element. I added a sleep 5 between the get request and the find_element_by_xpath. Once I did that testvar.text worked just fine.



Solution 1:[1]

SOLUTION The problem ended up being two issues. The first was I was using find_elements_by_xpath and that was giving me the list. The second issue was that I was not giving enough time between when I requested the webpage and when I started finding the element. I added a sleep 5 between the get request and the find_element_by_xpath. Once I did that testvar.text worked just fine.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Xgamer911