eclipse - Katalon IDE 生成的脚本在 Eclipse 中出现错误
问题描述
我正在使用 Katalon IDE 生成脚本。
由于我的应用程序在右上角有一个退出按钮,当我单击它时,IDE 将生成
xpath=(.//*[normalize-space(text()) and normalize-space(.)='S'])[3]/following::span[3]
在 Eclipse 中运行它时,此行会出错。在检查这个元素时,我发现了这个:
<td id="titlebar_hyperlink_8-co_0" role="presentation"
nowrap="nowrap" align="left" class=" verticalSpacer"
style="vertical-align:top;">
<span id="titlebar_hyperlink_8-lbsignout" align="left"
ctype="label" tabindex="0" targetid=
"titlebar_hyperlink_8-lbsignout" mxevent="click" accesskey="S"
class="text powerwhite anchor" style="display:block;cursor:pointer;"
title="Sign Out ALT+S" hotkey="83"><img id="titlebar_hyperlink_8-
lbsignout_image" src="btn_signout.gif" class="pwimg" border="0"
style="vertical-align:top;margin:0px;margin-left:3px;margin-right:3px;"
alt="Sign Out ALT+S"><span><span></span><span class="text hl
hlak">S</span><span>ign Out</span></span></span></td>
我是硒及其所有相关内容的新手。我将不胜感激任何形式的帮助。谢谢,堆栈溢出社区。
解决方案
尝试将 xpath 更改为
'.//*[@title="Sign Out ALT+S"]'
解释:
您想要唯一地定位一个元素。通常,您会尝试使用id
,但元素的 id 似乎是动态的,因此它可能并非在所有情况下都有效。
*
- 这意味着任何元素,并且在括号内[ ]
放置要查找元素的属性。我选择标题是因为它在给定页面上可能是唯一的。
我推荐这个备忘单作为 xpath 参考。
推荐阅读
- python - 拆分包含字典列表的 pandas 列
- javascript - 我们如何从 php 中的脚本传递一个变量并将其设置为新的变量?(关闭)
- perl - 如何让 Perl 的剪贴板模块将 utf-8 正确写入剪贴板?
- angular - 将项目添加到 cdkVirtualFor
- sequelize.js - sequalize 类型 'void' 不可分配给类型 'Model
' - c++ - gcov 不适用于 pthread、WSL-2、Clion
- html - 如何使div中的元素居中
- javascript - 跳过 JS 表格循环中的第一列
- discord.js - 我正在尝试在 discord.js 中创建超过 1 个输入命令
- emacs - 防止 clang-format 删除 emacs 的换页符