下载使用Selenium在内部窗口中打开的文件
我想在 https://aplicaciones007.jne.gob.pe/srop_publico/consulta/padronafiliado# 我面临的问题是,当我单击某些条目时,例如第一个“ Accion Pocul”时,一个新的内窗口弹出,我无法与Selenium进行互动。这是单击“ Accion Pocul”后打开的6个文件之一的行。但是,它没有单击这些文件,我基本上尝试了所有可能的XPATH用于文件。
for i in range(1,7):
file_path = '//*[@id="MiVentanaContenido"]/div[2]/table/tbody/tr[1]/td'
file = driver.find_element(By.XPATH, file_path)
print(file.text)
file.click()
I want to download files on https://aplicaciones007.jne.gob.pe/srop_publico/Consulta/PadronAfiliado#
The problem I am facing is when I click on some of the entries, for instance the first one 'ACCION POPULAR', a new inner window pops up which I cannot interact with Selenium. Here are the lines to click on one of the 6 files opened after clicking on 'ACCION POPULAR'. However, it doesn't click on the files and I basically tried all possible XPATHS for the files.
for i in range(1,7):
file_path = '//*[@id="MiVentanaContenido"]/div[2]/table/tbody/tr[1]/td'
file = driver.find_element(By.XPATH, file_path)
print(file.text)
file.click()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它之所以没有单击
6链接
之后,单击Accion Poncome 是因为我们指定要单击表数据行//*[@ID =“ miventanacontenido”]/div [2]/table/tbody/tr [1]/td
而不是锚定链接
IE//*[@ID =“ Miventanacontenido”]/div [2]/table/tbody/tbody/tr [1]/td/a
您的解决方案看起来像
The reason it is not clicking on the
6 links
afterclicking on ACCION POPULAR
is because we are specifying to click on the table data row//*[@id="MiVentanaContenido"]/div[2]/table/tbody/tr[1]/td
instead of theanchor link present in the row
i.e//*[@id="MiVentanaContenido"]/div[2]/table/tbody/tr[1]/td/a
Your solution would look like