Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 0.6.1
-
Fix Version/s: 0.7.0
-
Component/s: None
-
Labels:None
-
Environment:OSX
-
Testcase included:yes
-
Number of attachments :
Description
Form control shortcuts work fine when used off of a $() selector, but fail when the same element is defined as a module property. Attached testcase illustrates both kinds of behavior. Here's a code snippet, for reference:
Form.html
<form class="update-form" action=''> <fieldset> <h3> Contact Information </h3> <div> <label for="field-name-first">First Name</label> <input type="text" name="name.first" id="field-name-first"> <label for="field-name-last">Last Name</label> <input type="text" name="name.last" id="field-name-last"> </div> </fieldset> </form>
FormControlShortcutsBugSpec.groovy
def setup(){
baseUrl = "file://local/path/to/test/resources/" //change to point at local location of resources test/resources folder
to FormPage
}
def 'form control shortcuts work when called on $() selector'() {
when:
$("form.update-form").'name.first' = 'foo'
then:
$("form.update-form").'name.first' == 'foo'
}
def 'explicit input value() operations work when called on module property'() {
when:
updateForm.firstName.value('foo')
then:
updateForm.firstName.value() == 'foo'
}
def 'read form control shortcuts work when called on module property'() {
when:
updateForm.firstName.value('foo')
then:
updateForm.firstName == 'foo'
}
def 'write form control shortcuts work when called on module property'() {
when:
updateForm.firstName = 'foo'
then:
updateForm.firstName.value() == 'foo'
}
PageAndModuleDefinitions.groovy
class FormPage extends Page{ static url = 'form.html' static content = { updateForm(required: false) { module UpdateForm } } } class UpdateForm extends Module{ static base = {$("form.update-form")} static content = { firstName {$('input', name: 'name.first')} lastName {'name.last'()} } }
Fixed in: https://github.com/geb/geb/commit/e1aa9cf1cbec1686ee953cb25ed5f1cb9d9de028