Python Forum
Going through HTML table with selenium
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Going through HTML table with selenium
#1
Hello Team,

I am trying to iterate through a webpage that contains a table, I am trying to access the first column of that table and then click on the save button to download the file:


table_id = "//body/div[@id='contents']/div[@id='main']/div/table[1]"
        table = driver.find_element(By.XPATH, table_id)
        rows = table.find_elements(By.TAG_NAME, "tr")

        k = 0
        #files_2b_downloaded = []
        #soup = BeautifulSoup(webPage.text,'html.parser')
        
        for row in rows[4:]:
            cells = row.find_elements(By.TAG_NAME, "td")
            if cells:
                image_elements = cells[0].find_elements(By.TAG_NAME, "img")
                image_to_click = image_elements[0]
                link_element = cells[0].find_element(By.TAG_NAME, "a")
                filename = link_element.get_attribute("href")
                file_2b_downloaded = filename.split("=")[-1]
                image_to_click.click()
this cell contains 3 to 4 images and is the first image the one I need to click on, but after the first iteration it shows empty and doesn't go through the if, what could be wrong?

Attached Files

Thumbnail(s)
   
Reply


Messages In This Thread
Going through HTML table with selenium - by emont - Sep-26-2023, 12:39 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Tkinterweb (Browser Module) Appending/Adding Additional HTML to a HTML Table Row AaronCatolico1 0 970 Dec-25-2022, 06:28 PM
Last Post: AaronCatolico1
  reading html and edit chekcbox to html jacklee26 5 3,139 Jul-01-2021, 10:31 AM
Last Post: snippsat
  Fetch Oracle DB rows & print it in HTML file with table's col headers in table format tssr_2001 1 3,040 Sep-04-2020, 01:39 PM
Last Post: ibreeden
  Outlook Emails & HTML Table in Message Body JoeDainton123 1 11,527 Sep-02-2020, 05:15 AM
Last Post: buran
  Python code for exporting table using Selenium gj31980 4 3,076 Aug-04-2020, 01:29 AM
Last Post: gj31980
  importing CSV file into a HTML table using Python trybakov 1 2,325 Feb-22-2020, 09:47 PM
Last Post: scidam
  HTML to Python to Windows .bat and back to HTML perfectservice33 0 1,976 Aug-22-2019, 06:31 AM
Last Post: perfectservice33
  Greenplum Query results to Email HTML table krux_rap 1 2,539 Apr-10-2018, 09:12 PM
Last Post: Larz60+
  convert text file data to HTML table in python Tirumal 5 12,580 Dec-29-2017, 04:44 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020