node.js - Multiple level of sections in page_objects in nightwatch.js -


i have started out using nightwatch.js , , using page_objects access elements in tests. wondering there anyway can have sections within sections in page objects? know can specify 1 level of section. have done :

module.exports = {   url : 'http://127.0.0.1:8111/local.html#open?view=shelf&lang=en_us',   sections : {     topcontainer : {       selector : '.top_container',       elements : {         logo : {           selector : '.logo'         },         settingsbutton : {           selector :'.dropdown'         },         searchbox : {           selector : '.search_box'         },         sortorderbutton : {           selector : '.icond'         }       }     },     library : {       selector : '.library',       booklist : {         selector : 'ul.library_container'       }     }   } }; 

can have sections inside sections , , in case not , how select in test case @variable

client.elements('css selector','@top_container ul.dropdown-menu li', function (result) {       if ( result.value.length == 3 ) {         this.verify.ok(result.value.length, '3 languages loaded');       }     }); 

thanks !

the nightwatch.js documentation "working page objects" specifies

note every command , assertion on section (other expect assertions) returns section chaining. if desired, can nest sections under other sections complex dom structures.

so , tried using hit , try make correct json structure , , works great :)

sample code in page_object

sections : { book_view : {     selector : '.read_book_view',     sections : {       top_container : {         selector : '.top_container',         elements : {           lib_view : {             selector : '.lib_view'           },           toc_link : {             selector : '.dropdown .dropdown-toggle'           },           toc_index : {             selector : '.dropdown .index-dropdown'           },           notes_and_hightlights : {             selector : '.page_access'           },           settings : {             selector : '#settings_b'           },           search : {             selector : '.search_trigger'           },           zoom : {             selector : '.zoom_iconsset'           }         }       }     }   } 

}

and referring them in test cases,

var booksection = bookview.section.book_view;  // top container var topsection = booksection.section.top_container; topsection.expect.element('@lib_view').to.be.present; 

thanks !


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -