Sep-26-2023, 12:39 AM
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:
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?