javascript - 点击事件未在 GWT 网站上触发
问题描述
我正在尝试在 GWT 构建站点的客户端自动化测试。我已经能够遍历所有 DOM 元素并找到可点击的 span 元素我尝试了 click() 方法,但它永远不会触发。
这只能在客户端完成。我无法调整源代码以包含任何 ID 或名称。
这是我的草稿本中的 HTML 代码。这确实找到了包含表格的 div 并获得了第一个 td 内的 span 标签。
<div tabindex="1779" id="isc_8C" style="left: 0px; top: 62px; width: 1566px; height: 165px; overflow: hidden; display: inline-block; position: absolute; z-index: 201998; cursor: default; background-color: white;" onfocus="isc.EH.focusInCanvas(ResultsGrid_1_body,true);"
onblur="if(window.isc)isc.EH.blurFocusCanvas(ResultsGrid_1_body,true);" onscroll="return ResultsGrid_1_body.$lh()" eventproxy="ResultsGrid_1_body">
<div id="isc_8B" style="width: 1566px; position: relative; z-index: 1000;">
<form onsubmit="return false;" action="javascript:void(0)">
<div id="ResultsGrid_1_body$28s" style="width: 1px; height: 0px; overflow: hidden; display: none;"><span style='width: 1px; height: 0px; vertical-align: text-top; display: inline-block;'></span>
</div>
<table width="1550" class="listTable" id="isc_8Ctable" role="presentation" style="overflow: hidden; table-layout: fixed;" border="0" cellspacing="0" cellpadding="2">
<tbody>
<tr role="listitem" aria-selected="true" aria-posinset="1" aria-setsize="1">
<td width="396" align="left" class="tallCellSelectedOver" style="height: 16px; overflow: hidden;">
<span class="clickable">748754434564</span>
</td>
<td width="180" align="left" class="tallCellSelectedOver" style="height: 16px; overflow: hidden;">Jon, smith</td>
</tbody>
</table>
<div id="ResultsGrid_1_body$284" style="width: 1px; height: 0px; overflow: hidden; display: none;"><span style='width: 1px; height: 0px; vertical-align: text-top; display: inline-block;'></span>
</div>
</form>
</div>
</div>
脚本代码是
$('div [eventproxy=ResultsGrid_1_body] table td span').click();
如何单击 span 标签?
解决方案
尝试将 id 与 span 相关联,然后在 body 标记的末尾添加函数,或者如果包含 js 文件,则在 body 标记上方调用它,而不是在开头。
<span id="sp"> </span>
工作示例可以在这里看到
推荐阅读
- docker - 如何为 Graylog 运行 Web 界面?
- c++ - CryptUnProtectData() 在 Windows 7 EMBEDDED COMPACT 上返回 ERROR_INSUFFICIENT_BUFFER(122) 错误
- mysql - 自加入表并计算返回值
- typescript - 在使用 TypeScript 的绑定函数中无法正确识别“thisArg”上下文
- php - 检查php中的内置函数
- r - Huxtable:quick_xlsx 导出后不显示数据
- c# - 如何在 Asp Net Core 中将 XML 输出从存储过程转换为 C# 对象
- api - 如何使用 Expo 连接到您的 React Native 中的 API?
- r - 无法从 R 中的 GitHub 加载 *.Rda 文件
- analytics - Azure DevOps Server - 谁通过历史更改了特定字段