javascript - 我怎样才能点击同一个按钮 99 次或直到代码结束?
问题描述
需要解决方案,请帮忙。
我有相同的跳过按钮类型,所有产品的名称 id 属性。只有 Xpath 发生了变化。请指导我如何快速单击 99 个相同的跳过按钮和一个取消弹出按钮。
这是我跳过按钮的图像
这里是我的图片,点击 SKip 后,我会得到一个这样的弹出窗口。我需要点击取消
下来我将附上跳过和取消的代码。
从跳过按钮的 Html 代码中,我选择了一个 Xpath,它只工作,
我的 Xpath 是
//input[@id='CustomPaging_GridView_gv_edit1_0'])-Product1
//input[@id='CustomPaging_GridView_gv_edit1_1'])-Product2
//input[@id='CustomPaging_GridView_gv_edit1_2'])-Product3
Like this 99 Products I Have To Write Xpath. It's Going Too Lengthy
跳过按钮的 Html 代码是
<input type="submit" name="CustomPaging_GridView$ctl02$gv_edit1" value="SKIP" onclick="product_skip(37639 );" id="CustomPaging_GridView_gv_edit1_0" class="button2">
取消按钮的 HTML 代码,
<div class="modal-footer">
<span id="prcid" style="display:none;">processing...</span>
<button type="button" id="skipok" onclick="skipoverall(this)" class="btn btn-primary" data-id="37639">Ok</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
</div>
PS:每次点击跳过按钮时,我都需要同时点击取消按钮。就像那样,我需要为 99 个产品单击跳过按钮和取消按钮
解决方案
因此,鉴于信息我会尝试下面的代码。既然你没有提到语言,我会在 python 中给出逻辑
elems = driver.find_elements_by_xpath("//input[starts-with(@id, 'CustomPaging_GridView_gv_edit1_')]")
for elem in elems:
elem.click()
driver.find_element_by_xpath("//button[text()='Cancel']").click()
推荐阅读
- arrays - 在 Laravel 中显示数组中的多个图像
- linux - KeyError: 'ifname' in convert an OpenWRT tar.gz to NetJSON
- swift - 使用 SSZipArchive 解压缩下载的 zip 文件
- mysql - MySql 约束问题
- java - Java中方法的向上转换和向下转换混淆
- c# - 从特定列中读取 Excel 中的 EPPlus 数据表
- html - 试图弄清楚
- reactjs - 从反应打字稿中的对象数组中获取所有值
- php - 将 Html 内容加载到 jQuery 变量中
- office-ui-fabric - 如何在fabric-ui中更改字体