rows = driver.find_element_by_xpath("//div[@style='display: block;']//table[@style='display: table;']//tr")
When I try to iterate over rows It throws an error TypeError: 'WebElement' object is not iterable
def get_size(e):
for entry in e:
count = count + 1
return count
get_size(rows)
Code Explanation: Using chrome driver we locate the web table and get total number of row using XPath “.//*[@id='leftcontainer']/table/tbody/tr/td[1]” Using for loop, we iterate through total number of rows and fetch values one by one. To get next row we use (i+1) in XPath.
What Is getText() Method? The Selenium WebDriver interface has predefined the getText() method, which helps retrieve the text for a specific web element. This method gets the visible, inner text (which is not hidden by CSS) of the web-element.
Go to the First name tab and right click >> Inspect. On inspecting the web element, it will show an input tag and attributes like class and id. Use the id and these attributes to construct XPath which, in turn, will locate the first name field.
Try this . This should work. use find_elements_by_xpath
Listlinker = []
Listlinker = driver.find_elements_by_xpath(""//div[@style='display: block;']//table[@style='display: table;']//tr")
for link in Listlinker:
// more code
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