0

我是 selenium 的新手,想知道如何识别表列信息,在这种情况下,可以使用 selenium 下载文件的“Em aberto”字段。

我的代码:

from selenium import webdriver

from time import sleep

from selenium.webdriver.common.keys import Keys

from selenium.webdriver.common.by import By

from selenium.webdriver.support.ui import WebDriverWait

navegador = webdriver.Chrome()

link = "https://app.gdjeokdk.com/login"

navegador.get(link)

user = "******"

password = "******"

sleep(1)

campo_user = navegador.find_element_by_id('login-input-usuario-id').send_keys(user)

campo_password = navegador.find_element_by_name('senha').send_keys(password)

button_enter = navegador.find_element_by_id('login-button-id').click()

sleep(5)

button_consultas = navegador.find_element_by_id("menu-consultas").click()

sleep(3)

iframe = navegador.find_element_by_id("iframeRf")

navegador.switch_to.frame(iframe)

sleep(2)

fatura = navegador.find_element_by_id("consultaspnl.row.8").click()

sleep(2)

#arquivo = navegador.find_element_by_id("g.image.visualizar").click()

table_id = navegador.find_element_by_id('faturaspnl.orderedflextablemo.tabela')

print(table_id)

sleep(1)

rows = table_id.find_elements_by_tag_name("tr") 
#print(rows)
for row in rows:       
    col = row.find_elements(By.TAG_NAME, "td")
    print(col)
#     for linhas in col:
#         if "Em aberto" in linhas[2].find_element_by_class_name("gwt-HTML"):
#             div = linhas.find_elements(By.TAG_NAME, "div")
#     print(div)


如果需要,我会为桌子拍照: 桌子

Html 如果需要: HTML 代码

在识别具有“Em Aberto”信息的行后,如何获得“Visualizar”按钮?

HTML 代码 2编码 HTML 2

4

1 回答 1

0

您可以尝试以下方法:

items = navegador.find_element_by_xpath("//td[@class='dataBaseTD nomeTD']/div[text()="Em aberto"]")

看看https://selenium-python.readthedocs.io/locating-elements.html

于 2021-07-21T19:51:34.150 回答