硒中识别按钮面临的问题

发布于 2025-01-05 15:34:13 字数 1422 浏览 3 评论 0原文

我正在开发 1 个项目,我必须在其中找到按钮,我已使用 xpath 进行相同的操作,但按钮 id 在每次刷新时都会更改,所以我遇到了问题。 下面是相同的屏幕截图 - 让我知道您可以识别该按钮,这样即使 id 更改也不会导致错误

<button type="button" id="ext-gen11" class=" x-btn-text">Login</button>

image

代码 HTML

<tr>
                <td></td>
                <td><div id="LoginButton" style="float: left;"><table style="width: auto;" id="ext-comp-1032" class="x-btn x-btn-noicon x-btn-over x-btn-focus" cellspacing="0"><tbody class="x-btn-small x-btn-icon-small-left"><tr><td class="x-btn-tl"><i>&nbsp;</i></td><td class="x-btn-tc"></td><td class="x-btn-tr"><i>&nbsp;</i></td></tr><tr><td class="x-btn-ml"><i>&nbsp;</i></td><td class="x-btn-mc"><em class="" unselectable="on"><button class=" x-btn-text" id="ext-gen12" type="button">Login</button></em></td><td class="x-btn-mr"><i>&nbsp;</i></td></tr><tr><td class="x-btn-bl"><i>&nbsp;</i></td><td class="x-btn-bc"></td><td class="x-btn-br"><i>&nbsp;</i></td></tr></tbody></table></div></td>
              </tr>

I am working on 1 project, where i have to locate button, i have used xpath for same, but button id change on every refresh, so i am facing problem in it..
Below is screenshot for same - let me know you can i identify that button so that it will not cause error even if id chages

<button type="button" id="ext-gen11" class=" x-btn-text">Login</button>

image

Code HTML

<tr>
                <td></td>
                <td><div id="LoginButton" style="float: left;"><table style="width: auto;" id="ext-comp-1032" class="x-btn x-btn-noicon x-btn-over x-btn-focus" cellspacing="0"><tbody class="x-btn-small x-btn-icon-small-left"><tr><td class="x-btn-tl"><i> </i></td><td class="x-btn-tc"></td><td class="x-btn-tr"><i> </i></td></tr><tr><td class="x-btn-ml"><i> </i></td><td class="x-btn-mc"><em class="" unselectable="on"><button class=" x-btn-text" id="ext-gen12" type="button">Login</button></em></td><td class="x-btn-mr"><i> </i></td></tr><tr><td class="x-btn-bl"><i> </i></td><td class="x-btn-bc"></td><td class="x-btn-br"><i> </i></td></tr></tbody></table></div></td>
              </tr>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

人生百味 2025-01-12 15:34:13

x路径:

//button[text()='Login']

xPath:

//button[text()='Login']
拥有 2025-01-12 15:34:13

XPath 应该可以解决这个问题:

Command: clickAndWait
Target: //input[@value='Login']

编辑

假设只有一个按钮的值为“Login”

XPath should do the trick:

Command: clickAndWait
Target: //input[@value='Login']

Edit

Assuming, that there is only one button with value "Login" on it

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文