0

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.

Alex
  • 8,093
  • 6
  • 49
  • 79
Eligijus
  • 634
  • 1
  • 6
  • 15
  • Found the answer my self: formValidity { $("form").find("select", name: contains('validity')).value("1 year")} – Eligijus Aug 06 '14 at 10:00
  • May be answer it yourself and accept it so that question doesn't remain eternally open :) – kdabir Aug 06 '14 at 12:40

1 Answers1

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

Alex
  • 8,093
  • 6
  • 49
  • 79
twinj
  • 2,009
  • 18
  • 10