You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Selenium IDE中删除含指定内容的动态生成记录?

解决Selenium IDE中删除指定动态记录的步骤

以下是具体的命令操作流程,帮你通过索引定位到目标记录并完成删除:

  1. 初始化变量与获取总记录数

    • 命令:store
    • 目标:0
    • 值:currentIndex

    • 命令:storeXpathCount
    • 目标://span[@id='lblGuestName']
    • 值:totalRecords
  2. 循环遍历所有记录

    • 命令:while
    • 目标:${currentIndex} < ${totalRecords}
    • 值:(留空)
  3. 获取当前索引的记录名称

    • 命令:storeText
    • 目标:(//span[@id='lblGuestName'])[${currentIndex}]
    • 值:currentGuestName
  4. 判断是否为目标记录

    • 命令:if
    • 目标:contains(${currentGuestName}, 'TFrist TLast')
    • 值:(留空)
  5. 点击对应删除链接
    请根据页面实际DOM结构调整删除链接的XPath,核心是用当前索引关联到同一条记录的删除按钮,以下是两种常见场景的写法:

    • 如果删除按钮是目标span的兄弟元素:
      命令:click
      目标:(//span[@id='lblGuestName'])[${currentIndex}]/following-sibling::a[contains(@class, 'delete')]
    • 如果删除按钮和span在同一个父容器下:
      命令:click
      目标:(//span[@id='lblGuestName'])[${currentIndex}]/../a[@id='deleteBtn']
  6. 找到目标后退出循环

    • 命令:break
    • 目标:(留空)
    • 值:(留空)
  7. 未找到目标则索引自增

    • 命令:storeEval
    • 目标:${currentIndex} + 1
    • 值:currentIndex

注意事项

  • 若你的Selenium IDE版本较新,storeEval需替换为executeScript,目标内容调整为:return ${currentIndex} + 1;
  • 务必根据实际页面结构修改删除链接的XPath,确保它与目标span属于同一条记录。

内容的提问来源于stack exchange,提问作者Pooja Khatri

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.16 14:09:58