I want to extract text using selenium in Python from an html. My text is under the id tag and when I try to retrieve the text this way gives me error.
date=browser.find_element_by_id('ctl00_ContentPlaceHolder1_lblIncDate')
date2=date.text
date1.append(date)
AttributeError Traceback (most recent call last)
<ipython-input-21-20d6df14a340> in <module>()
37 date1.append(date)
38 userid_element = browser.find_elements_by_id('ctl00_ContentPlaceHolder1_lblIncDate')
---> 39 userid = userid_element.text
40 userid1.append(userid)
41 time.sleep(20)
AttributeError: 'list' object has no attribute 'text'
Also, I tried with xpath but does not really work:
date2=date.text
date1.append(date)
File "<ipython-input-19-8b8e7fb86782>", line 35
date=browser.find_element_by_xpath(''//span[@id= 'ctl00_ContentPlaceHolder1_lblIncDate' ]'')
^
SyntaxError: invalid syntax