1
我在我的量角器测试之一中有一个滑块,我可以找到盒子并且可以获得属性(即'多少'),但是我怎样才能在盒子中循环,以便我可以测试验证显示器,例如,如何在量角器中测试滑块
profilepage.slides.next()
expect(profilepage.slide.slideTitle = 'Credentials'
profilepage.slides.next()
expect(profilepage.slide.slideTitle = "Info"
etc.
控制器:
.controller('ProfileCtrl', function ($scope, ProfileService) {
$scope.data = {
numViewableSlides: 0,
slideIndex: 0,
initialInstruction: true,
secondInstruction: false, slides: [
{
'template': 'templates/slidebox/credentials.html',
'viewable': true
},
{
'template': 'templates/slidebox/contactinfo.html',
'viewable': true
},
{
'template': 'templates/slidebox/employeeinfo.html',
'viewable': true
},
{
'template': 'templates/slidebox/assignmentinfo.html',
'viewable': true
}
]
}
. . .
模板:
<ion-slide-box on-slide-changed="slideChanged(index)" show-pager="true">
<ion-slide ng-repeat="slide in data.slides | filter:{viewable : true}">
<div ng-include src="slide.template"></div>
</ion-slide>
</ion-slide-box>
页面对象:
profilepage.prototype = Object.create({}, {
backButton: {
get: function() {
return element(by.css('ion-ios7-arrow-back'));
}
},
slides: {
get: function() {
return element.all(by.repeater('slide in data.slides'));
}
},
slideTitle: {
get: function (id) {
element.all(by.repeater('slide in data.slides')).then(function (slidelist) {
var titleElement = slidelist[id].element(by.css('#slideName'));
return titleElement.getText();
});
}
},
. . .
规格:
describe('Profile', function() {
var ppage = new profilepage();
beforeEach(function() {
browser.ignoreSynchronization = false;
});
it('should have correct lastname and have four slides on profile page', function() {
expect(browser.getCurrentUrl()).toEqual('http://localhost:8100/#/profile');
expect(ppage.lastname).toBe('Smith,');
expect(ppage.slides.count()).toEqual(4);
browser.sleep(1000);
});
it('should slide all the pages', function(){
expect(browser.getCurrentUrl()).toEqual('http://localhost:8100/#/profile');
// SLIDE EACH PAGE ABOUT HERE <------------
browser.sleep(1000);
})
我不是程序员,但已经与量角器一起工作了一下。 你能解释一下用户的操作是“滑动”到下一个“幻灯片”吗?这是你正在制造/测试的例子吗? http://codepen.io/keithjgrant/pen/vqnaA – user249656