Can someone help me with iteration and find elements?

I’m trying to iterate over a table row searching by the xpath of element “tr”. But when I’ll try find the elements “td” to iterate over them and get the text I get the error “invalid locator”. It’s just a test, but can someone help me with this? Below is the code:

from RPA.Browser.Selenium import Selenium

lib = Selenium()

lib.open_available_browser("https://ge.globo.com/futebol/brasileirao-serie-a/")
lib.wait_until_element_is_visible('xpath://*[@id="classificacao__wrapper"]/article/section[1]/div/table[2]/tbody/tr')
trs = lib.find_elements('xpath://*[@id="classificacao__wrapper"]/article/section[1]/div/table[2]/tbody/tr')

for tr in trs:
	td = tr.find_elements('tag:td')
	print(td)

Hi, @julian.cassemiro056! Welcome! :slight_smile:

Short answer:

from RPA.Browser.Selenium import Selenium

lib = Selenium()

lib.open_available_browser("https://ge.globo.com/futebol/brasileirao-serie-a/")
lib.wait_until_element_is_visible(
    'xpath://*[@id="classificacao__wrapper"]/article/section[1]/div/table[2]/tbody/tr')
trs = lib.find_elements(
    'xpath://*[@id="classificacao__wrapper"]/article/section[1]/div/table[2]/tbody/tr')

for tr in trs:
    tds = tr.find_elements_by_tag_name('td')
    for td in tds:
        print(td.text)

Longer answer:

You might want to take a look at this example robot that uses the beautifulsoup4 library if you need to do lots of HTML parsing in Python: