I have troubles selecting a value from a List Box
<select name="max">
<option value="25">25</option>
<option value="50" selected="selected">50</option>
<option value="100">100</option>
</select>
In my Page I have:
class TableSectionModule extends Module {
static base = { $('#runList') }
static content = {
tablePaginationSelect { $("select", name : "max") }
}
}
I have used in my Spec all these calls:
runs.table.tablePaginationSelect = "100"
I have also tried this :
runs.table.tablePaginationSelect.value('100')
But I have an exception
org.openqa.selenium.WebElement.setSelected()V
java.lang.NoSuchMethodError: org.openqa.selenium.WebElement.setSelected()V
at org.openqa.selenium.support.ui.Select.selectByValue(Select.java:176)
at geb.navigator.NonEmptyNavigator.setSelectValue(NonEmptyNavigator.groovy:591)
at geb.navigator.NonEmptyNavigator.setInputValue(NonEmptyNavigator.groovy:548)
at geb.navigator.NonEmptyNavigator.setInputValues_closure33(NonEmptyNavigator.groovy:542)
at geb.navigator.NonEmptyNavigator.setInputValues(NonEmptyNavigator.groovy:541)
at geb.navigator.NonEmptyNavigator.value(NonEmptyNavigator.groovy:319)
at geb.content.NavigableSupport.methodMissing(NavigableSupport.groovy:123)
at geb.content.NavigableSupport.propertyMissing(NavigableSupport.groovy:141)
I am using Grails with Geb and here are the dependencies I am using :
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.
// runtime 'mysql:mysql-connector-java:5.1.22'
test("org.seleniumhq.selenium:selenium-chrome-driver:$seleniumVersion")
test("org.seleniumhq.selenium:selenium-firefox-driver:$seleniumVersion")
// You usually only need one of these, but this project uses both
//test "org.codehaus.geb:geb-spock:$gebVersion"
test "org.spockframework:spock-grails-support:0.7-groovy-2.0"
test "org.gebish:geb-spock:0.9.0"
test "org.codehaus.geb:geb-spock:0.7.2"
test "org.seleniumhq.selenium:selenium-support:2.0a7"
}
The .value('100')
syntax is correct. I used a sample gradle+geb (so no Grails, and so slightly different dependencies) project I had lying around, recreated your dropdown and your module, and was able to affect it with this syntax.
Try it without using the Module
. Bypass it entirely and see what this gives you:
$('select' name:'max').value('100')
Update
Here's what I did to watch the changes happening on-screen (with a couple sanity check println's):
def sel = $('select', name:'max')
sel.size() == 1
System.out.println(sel.getClass().name)
System.out.println(sel)
System.out.println(sel.value())
Thread.sleep( 500 )
sel.value ( "25" )
Thread.sleep( 500 )
sel.value ( "50")
Thread.sleep( 500 )
sel.value ( "100")
Thread.sleep( 500 )
System.out.println(sel.value())
Also, once your test is complete, be sure to look at your test output. For myself, that's in build/test-results
. Also, you can enable debug output on gradle: gradlew build --debug
. It can be pretty helpful.