Protractor 如何在量角器中测试滑盒

Protractor 如何在量角器中测试滑盒,protractor,angularjs-e2e,Protractor,Angularjs E2e,我的一个量角器测试中描述了一个幻灯片框;我可以找到框并获得属性(即“多少”),但我如何在框中循环,以便测试和验证显示,例如: profilepage.slides.next() expect(profilepage.slide.slideTitle = 'Credentials' profilepage.slides.next() expect(profilepage.slide.slideTitle = "Info" etc. 控制器: .controller('ProfileCtrl',

我的一个量角器测试中描述了一个幻灯片框;我可以找到框并获得属性(即“多少”),但我如何在框中循环,以便测试和验证显示,例如:

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>
规格:

描述('Profile',函数(){
var ppage=new profilepage();
beforeach(函数(){
browser.ignoreSynchronization=false;
});
它('应该有正确的姓氏,在个人资料页上有四张幻灯片',函数(){
expect(browser.getCurrentUrl()).toEqual('http://localhost:8100/#/profile');
expect(ppage.lastname).toBe('Smith');
expect(ppage.slides.count()).toEqual(4);
浏览器睡眠(1000);
});
它('应滑动所有页面',函数(){
expect(browser.getCurrentUrl()).toEqual('http://localhost:8100/#/profile');

//将每页幻灯片放在这里想法是从规范文件中使用ionic的。为此,我们需要使其在全球范围内可访问:

var addProtractorSlideBox, nextSlide;

addProtractorSlideBox = function() {
  return browser.addMockModule("services", function() {
    return angular.module("services").run(function($ionicSlideBoxDelegate) {
      return window._$ionicSlideBoxDelegate = $ionicSlideBoxDelegate;
    });
  });
};

nextSlide = function() {
  return browser.executeScript('_$ionicSlideBoxDelegate.next()');
};

...

beforeEach(function() {
  ...
  addProtractorSlideBox();
  ...
});

it('...', function() {
  ...
  nextSlide();
  ...
})

此模式对其他离子/角度服务非常有用。

我不是程序员,但曾使用过量角器。您能解释一下用户将“滑动”到下一个“幻灯片”的操作吗?这是您正在制作/测试的示例吗?它看起来不错,只是缺少模块(“服务”,[])新模块的空括号:)
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);
})
var addProtractorSlideBox, nextSlide;

addProtractorSlideBox = function() {
  return browser.addMockModule("services", function() {
    return angular.module("services").run(function($ionicSlideBoxDelegate) {
      return window._$ionicSlideBoxDelegate = $ionicSlideBoxDelegate;
    });
  });
};

nextSlide = function() {
  return browser.executeScript('_$ionicSlideBoxDelegate.next()');
};

...

beforeEach(function() {
  ...
  addProtractorSlideBox();
  ...
});

it('...', function() {
  ...
  nextSlide();
  ...
})