javascript - protractor howto test last item'class on a list -
in application have list of items, can add new item it,i can check list got new item, test if new item has class 'nuovo', test case:
it("should add item address list class 'nuovo'",function(){ ptor.findelements(protractor.by.repeater('a in customer.lives_in')).then(function(arr) { expect(arr.length).toequal(2); var initial_length = arr.length; // set values new address ptor.findelement(protractor.by.model('street')).sendkeys('via'); ptor.findelement(protractor.by.model('city')).sendkeys('g'); ptor.findelement(protractor.by.model('number')).sendkeys('xx'); ptor.findelement(protractor.by.model('use')).sendkeys('n'); element(by.id('addaddressbutton')).click(); //check 1 address more ptor.findelements(protractor.by.repeater('a in customer.lives_in')).then(function(arr) { expect(arr.length).toequal(initial_length+1); var inserted_item = element(arr[arr.length-1]) //get last element, inserted 1 //console.log(inserted_item); var lastrow = element(by.repeater('a in customer.lives_in').last); expect(lastrow).tohaveclass('nuovo'); }) }); })
i error:
failures: 1) e2e: main page should add item address list class 'nuovo' message: typeerror: object [object object] has no method 'tohaveclass' stacktrace: error @ null.<anonymous> (/home/arpho/projects/neo4scrum/test/e2e/addaddress_spec.js:19:1) @ object.<anonymous> (/home/arpho/projects/neo4scrum/test/e2e/addaddress_spec.js:2:1) @ async task: typeerror: object [object object] has no method 'tohaveclass' @ /home/arpho/projects/neo4scrum/test/e2e/addaddress_spec.js:38:29 ==== async task ==== webdriver.call(function) @ object.findelementsoverride (/home/arpho/projects/neo4scrum/node_modules/protractor/lib/locators.js:273:21) @ protractor.findelements (/home/arpho/projects/neo4scrum/node_modules/protractor/lib/protractor.js:765:21) @ /home/arpho/projects/neo4scrum/test/e2e/addaddress_spec.js:31:14 ==== async task ==== asynchronous test function finished in 20.703 seconds
i have done this:
expect(lastrow.getattribute('classname')).tomatch('nuovo');
Comments
Post a Comment