Geb select element that contains something

感情迁移 提交于 2019-12-25 05:16:13

问题


How do I select the value of a form select field when it has random numbers in its name?

<select name="select_(random numbers)">
     <option value="1"></option>
</select>

I have tried:

formValidity {$("form").(contains('validity')) = "1 year"}

which fails.


回答1:


There are a few ways to achieve this:

formValidity { $("form select[name*='validity']") }

formValidity.value("1 year")

You were trying to use the Geb way.

Geb Selecting Manual

You can also use CSS and jquery selectors which I used above and also prefer.

CSS Selectors

JQuery Selectors



来源:https://stackoverflow.com/questions/25155330/geb-select-element-that-contains-something

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