jeudi 15 septembre 2016

Spock: Iterating a navigator's each element got error for size = 0

I have the below code to process each element of a navigator:

def child_age_boxes = child_criteria.find("li",class:"targetChildAgeForm",style:"")

            println child_age_boxes.size() // pronts: 0
            println child_age_boxes.length() // prints []

            child_age_boxes.each {Navigator element -> 
                ...Some code here

            }

The child_age_boxes.each should be ignored for size = 0 but this is not happening. Instead giving error like:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Spec expression: 1: expecting '}', found '' @ line 1, column 298.
......

How to prevent the execution of the each block for size = 0 ?

Aucun commentaire:

Enregistrer un commentaire