I'm trying to use Selenium to automate some web browsing. Currently I'm trying to access a specific element by class name and return the text within it (the element im selecting on the page definetly has text in it) and when I try to return it in my function I get
TypeError: 'unicode' object is not callable
My code for the function is as follows:
driver = webdriver.Chrome("my chromedriver installation path")
driver.get("website URL")
def getText():
return driver.find_element_by_class_name("class with text").text()
print getText()
.text
is not a method, it is an attribute:
driver.find_element_by_class_name("class with text").text
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With