aisingapore / TagUI

Free RPA tool by AI Singapore
Apache License 2.0
5.6k stars 580 forks source link

table保存表格数据,由于页面html嵌套,基于xpath定位表格失败 - try this #1285

Closed git-chen513 closed 1 month ago

git-chen513 commented 1 year ago

hi,最近在使用table命令保存页面表格数据,遇到以下问题: 1、由于页面html嵌套,想要获取嵌套的html里的table xptah进行table定位失败 页面布局大致如下: problem

通过chrome f12,获取到的第一个table的xpath是://[@id="form1"]/div[4]/div[1]/table; 第二个table的xpath是://[@id="form1"]/table;然而第一个table正常保存了数据,但是第二个table提示not found 我排查之后就发现是html嵌套导致xpath路径不正确。

我按照官方文档下载了[SelectorsHub Chrome extension]插件,获取到的xpath同样不行。

2、或者不基于xpath我还能通过什么方式定位table,我尝试使用table编号,但只有编号1的table能成功。

以上问题困扰了数日得不到解决,希望能得到帮助,感谢!

ruthtxh commented 1 year ago

Hi @git-chen513 it seems like this table is nested inside an iframe. image

You can try:

frame content02
  table //[@id="form1"]/table to yourtable.csv

here's an example:

https://www.w3schools.com/html/tryit.asp?filename=tryhtml_table_intro
frame iframeResult
  table 1 to testtable.csv
git-chen513 commented 1 year ago

@ruthtxh ,非常感谢您的回复,我尝试了你的方法,但是依旧没有成功,不知道是否语法格式有误?我在官方文档中没有找到相类似的写法,以下是我的.tag文件截图和运行结果截图: image

image

xin911 commented 1 year ago

// some https://rpa-sg.org/tmp/frame2.php wait 1

// 目前看,必须名称或ID $x("//iframe") document.querySelectorAll("iframe")[0] dom document.querySelectorAll("iframe")[0].setAttribute("name", "frame_name"); frame frame_name { enter //input[@name="q"] as RPA click //button[.="Search"] }

wait 5

========== 用以上方法尝试下。包含iframe和正常的做法是不同的。 尝试了几种方式,目前这个是有效的。

kensoh commented 1 month ago

Closing but please ping back if this is still relevant or an issue.