gpt4 book ai didi

xpath - Selenium IDE : How to detect the xpath's if div id's , 类每次都是随机生成的?

转载 作者:行者123 更新时间:2023-12-01 19:53:19 25 4
gpt4 key购买 nike

我正在尝试检测 xpath 或 css,但每次运行脚本时,div id 和类名都会发生变化,导致脚本失败。

<div class="yui-dt-bd" style="height: 300px; width: 100%;">
<table id="yuievtautoid-0" summary="" style="margin-top: 0px;">
<tr id="yui-rec28" class="yui-dt-rec yui-dt-first yui-dt-even yui-dt-selected" style="">
<td id="yui-gen52" class="yui-dt23-col-professorId yui-dt-col-professorId yui-dt- sortable yui-dt-first" headers="yui-dt23-th-professorId ">
<div id="yui-gen51" class="yui-dt-liner">1</div>
</td>
<td id="yui-gen44" class="yui-dt23-col-professorName yui-dt-col-professorName yui-dt-sortable yui-dt-last" headers="yui-dt23-th-professorName ">
<div id="yui-gen43" class="yui-dt-liner">John Power</div>
</td>
</tr>
</table>
</div>

我写了 xpath=//*[@id="yui-gen46"],但 id 不断变化。也尝试过写表id。但这不起作用。xpath=id('yuievtautoid-1')。

感谢一些意见。

最佳答案

您可以指定不更改的类或 ID 的一部分。例如:

//*[contains(@class, 'col-professorName')]

//*[contains(@id, 'yuievtautoid')]

或 CSS 版本:

css=*[class*="col-professorName"]
css=*[id^="yuievtautoid"]

关于xpath - Selenium IDE : How to detect the xpath's if div id's , 类每次都是随机生成的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11055980/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com