Selecting a dynamic checkbox in selenium using regex

橙三吉。 提交于 2019-12-11 04:56:59

问题


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


回答1:


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

That should get what you are after



来源:https://stackoverflow.com/questions/7280972/selecting-a-dynamic-checkbox-in-selenium-using-regex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!