@@ -69,14 +69,19 @@ angular.scenario.dsl('navigateTo', function() {
6969
7070/**
7171 * Usage:
72- * using(selector) scopes the next DSL element selection
72+ * using(selector, label ) scopes the next DSL element selection
7373 *
7474 * ex.
75- * using('#foo').input('bar')
75+ * using('#foo', "'Foo' text field" ).input('bar')
7676 */
7777angular . scenario . dsl ( 'using' , function ( ) {
78- return function ( selector ) {
78+ return function ( selector , label ) {
7979 this . selector = ( this . selector || '' ) + ' ' + selector ;
80+ if ( angular . isString ( label ) && label . length ) {
81+ this . label = label + ' (' + this . selector + ' )' ;
82+ } else {
83+ this . label = this . selector ;
84+ }
8085 return this . dsl ;
8186 } ;
8287} ) ;
@@ -148,15 +153,15 @@ angular.scenario.dsl('input', function() {
148153
149154/**
150155 * Usage:
151- * repeater('#products table').count() number of rows
152- * repeater('#products table').row(1) all bindings in row as an array
153- * repeater('#products table').column('product.name') all values across all rows in an array
156+ * repeater('#products table', 'Product List' ).count() number of rows
157+ * repeater('#products table', 'Product List' ).row(1) all bindings in row as an array
158+ * repeater('#products table', 'Product List' ).column('product.name') all values across all rows in an array
154159 */
155160angular . scenario . dsl ( 'repeater' , function ( ) {
156161 var chain = { } ;
157162
158163 chain . count = function ( ) {
159- return this . addFutureAction ( 'repeater ' + this . selector + ' count' , function ( $window , $document , done ) {
164+ return this . addFutureAction ( 'repeater ' + this . label + ' count' , function ( $window , $document , done ) {
160165 try {
161166 done ( null , $document . elements ( ) . length ) ;
162167 } catch ( e ) {
@@ -166,7 +171,7 @@ angular.scenario.dsl('repeater', function() {
166171 } ;
167172
168173 chain . column = function ( binding ) {
169- return this . addFutureAction ( 'repeater ' + this . selector + ' column ' + binding , function ( $window , $document , done ) {
174+ return this . addFutureAction ( 'repeater ' + this . label + ' column ' + binding , function ( $window , $document , done ) {
170175 var values = [ ] ;
171176 $document . elements ( ) . each ( function ( ) {
172177 _jQuery ( this ) . find ( ':visible' ) . each ( function ( ) {
@@ -181,7 +186,7 @@ angular.scenario.dsl('repeater', function() {
181186 } ;
182187
183188 chain . row = function ( index ) {
184- return this . addFutureAction ( 'repeater ' + this . selector + ' row ' + index , function ( $window , $document , done ) {
189+ return this . addFutureAction ( 'repeater ' + this . label + ' row ' + index , function ( $window , $document , done ) {
185190 var values = [ ] ;
186191 var matches = $document . elements ( ) . slice ( index , index + 1 ) ;
187192 if ( ! matches . length )
@@ -196,16 +201,16 @@ angular.scenario.dsl('repeater', function() {
196201 } ) ;
197202 } ;
198203
199- return function ( selector ) {
200- this . dsl . using ( selector ) ;
204+ return function ( selector , label ) {
205+ this . dsl . using ( selector , label ) ;
201206 return chain ;
202207 } ;
203208} ) ;
204209
205210/**
206211 * Usage:
207- * select(selector ).option('value') select one option
208- * select(selector ).options('value1', 'value2', ...) select options from a multi select
212+ * select(name ).option('value') select one option
213+ * select(name ).options('value1', 'value2', ...) select options from a multi select
209214 */
210215angular . scenario . dsl ( 'select' , function ( ) {
211216 var chain = { } ;
@@ -237,19 +242,19 @@ angular.scenario.dsl('select', function() {
237242
238243/**
239244 * Usage:
240- * element(selector).count() get the number of elements that match selector
241- * element(selector).click() clicks an element
242- * element(selector).attr(name) gets the value of an attribute
243- * element(selector).attr(name, value) sets the value of an attribute
244- * element(selector).val() gets the value (as defined by jQuery)
245- * element(selector).val(value) sets the value (as defined by jQuery)
246- * element(selector).query(fn) executes fn(selectedElements, done)
245+ * element(selector, label ).count() get the number of elements that match selector
246+ * element(selector, label ).click() clicks an element
247+ * element(selector, label ).attr(name) gets the value of an attribute
248+ * element(selector, label ).attr(name, value) sets the value of an attribute
249+ * element(selector, label ).val() gets the value (as defined by jQuery)
250+ * element(selector, label ).val(value) sets the value (as defined by jQuery)
251+ * element(selector, label ).query(fn) executes fn(selectedElements, done)
247252 */
248253angular . scenario . dsl ( 'element' , function ( ) {
249254 var chain = { } ;
250255
251256 chain . count = function ( ) {
252- return this . addFutureAction ( 'element ' + this . selector + ' count' , function ( $window , $document , done ) {
257+ return this . addFutureAction ( 'element ' + this . label + ' count' , function ( $window , $document , done ) {
253258 try {
254259 done ( null , $document . elements ( ) . length ) ;
255260 } catch ( e ) {
@@ -259,7 +264,7 @@ angular.scenario.dsl('element', function() {
259264 } ;
260265
261266 chain . click = function ( ) {
262- return this . addFutureAction ( 'element ' + this . selector + ' click' , function ( $window , $document , done ) {
267+ return this . addFutureAction ( 'element ' + this . label + ' click' , function ( $window , $document , done ) {
263268 var elements = $document . elements ( ) ;
264269 var href = elements . attr ( 'href' ) ;
265270 elements . trigger ( 'click' ) ;
@@ -274,33 +279,33 @@ angular.scenario.dsl('element', function() {
274279 } ;
275280
276281 chain . attr = function ( name , value ) {
277- var futureName = 'element ' + this . selector + ' get attribute ' + name ;
282+ var futureName = 'element ' + this . label + ' get attribute ' + name ;
278283 if ( value ) {
279- futureName = 'element ' + this . selector + ' set attribute ' + name + ' to ' + value ;
284+ futureName = 'element ' + this . label + ' set attribute ' + name + ' to ' + value ;
280285 }
281286 return this . addFutureAction ( futureName , function ( $window , $document , done ) {
282287 done ( null , $document . elements ( ) . attr ( name , value ) ) ;
283288 } ) ;
284289 } ;
285290
286291 chain . val = function ( value ) {
287- var futureName = 'element ' + this . selector + ' value' ;
292+ var futureName = 'element ' + this . label + ' value' ;
288293 if ( value ) {
289- futureName = 'element ' + this . selector + ' set value to ' + value ;
294+ futureName = 'element ' + this . label + ' set value to ' + value ;
290295 }
291296 return this . addFutureAction ( futureName , function ( $window , $document , done ) {
292297 done ( null , $document . elements ( ) . val ( value ) ) ;
293298 } ) ;
294299 } ;
295300
296301 chain . query = function ( fn ) {
297- return this . addFutureAction ( 'element ' + this . selector + ' custom query' , function ( $window , $document , done ) {
302+ return this . addFutureAction ( 'element ' + this . label + ' custom query' , function ( $window , $document , done ) {
298303 fn . call ( this , $document . elements ( ) , done ) ;
299304 } ) ;
300305 } ;
301306
302- return function ( selector ) {
303- this . dsl . using ( selector ) ;
307+ return function ( selector , label ) {
308+ this . dsl . using ( selector , label ) ;
304309 return chain ;
305310 } ;
306311} ) ;
0 commit comments