使用regex在硒中选择一个动态复选框 [英] Selecting a dynamic checkbox in selenium using regex

查看:110
本文介绍了使用regex在硒中选择一个动态复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想选择一个复选框,其ID是动态生成的,但无法解决。

尝试了以下



  Selenium.check(x =(// input [@ type ='checkbox')); Selenium.check(id = regexp:ctl00_cphMain_cbx_ [a-zA-Z0-9 _,] ])[position()= 1])

此复选框也只有动态ID

解决方案

p>您尝试过 selenium.check('xpath = // input [@ type ='checkbox'and starts-with(@ id,'ctl00_cphMain_cbx _')])



这应该会得到你之后


I am trying to select a checkbox whose ids are generated dynamically but couldn't solve it.
Tried following

Selenium.check("id=regexp:ctl00_cphMain_cbx_[a-zA-Z0-9_,]*")
Selenium.check("xpath=(//input[@type='checkbox'])[position()=1]")

Also this check box has only dynamic id, no name etc. any idea what I am doing wrong.

Regards

解决方案

have you tried selenium.check('xpath=//input[@type='checkbox' and starts-with(@id,'ctl00_cphMain_cbx_')])

That should get what you are after

这篇关于使用regex在硒中选择一个动态复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆