How to convert selenium webelelements to list of strings in python
As you have used the following line of code :
document=driver.find_elements_by_tag_name('td')
and see the output on Console as :
"<class'selenium.webdriver.firefox.webelement.FirefoxWebElement'>"
This is the expected behavior as Selenium
prints the reference of the Nodes
matching your search criteria.
As per your Code Attempt
to print the text leaving out the white spaces
you can use the following code block :
x=[]document = driver.find_elements_by_tag_name('td')for i in document : if (i.get_attribute("innerHTML") != "null") : x.append(i.get_attribute("innerHTML"))print(x[2])
My code was correct. But, the selected elements for displaying were space. By select another element, the result was shown.