码迷,mamicode.com
首页 > 其他好文 > 详细

[Protractor] Locators and Suites in Protractor

时间:2016-02-23 06:08:23      阅读:225      评论:0      收藏:0      [点我收藏+]

标签:

HTML:

<ul class="list">
   <li 
        ng-repeat="item in itmes"
        ng-click="selectItem(item)"
        ng-class="{selected: item.isSelected}">{{ item.name }}</li>
</ul>

 

// Get by binding
expect(element.all(by.binding(‘item.name‘)).first().getText()).toBe(‘Ben‘);

// Get by tagName
expect(element(by.css(‘.list‘)).all(by.tagName(‘li‘)).get(2).getText()).toBe(‘Sophi‘);

// Get by repeater
expect(element(by.repeater(‘item in items‘).row(4).column(‘{{ item.name }}‘)).getText()).toBe(‘Herny‘);

Notice, when you use repeater, ‘{{ item.name }}‘ should be prefect match with what you have in html. Speace between {} also matters.

 

var listItems = element(by.css(‘.list‘)).all(by.tagName(‘li‘));
var ben = listItems.first();
var sophi = listItems.get(2);
sophi.cliick();

expect(sophi.getAttribute(‘class‘)).toMatch(‘selected‘);
expect(ben.getAttribute(‘class‘)).not.toMatch(‘selected‘);

 

--------------------------

In conf.js:

var config = {
   suites: {
      basics: ‘./e2etest/index.spec.js‘,
      locators: ‘./e2etest/locators.spec.js‘
   }
};

What we write into the suites is what we gonne run in the test, if we want to skip ‘basics‘ tests, we can do in scripts:

protractor conf.js --chrome --suite=locators

 

[Protractor] Locators and Suites in Protractor

标签:

原文地址:http://www.cnblogs.com/Answer1215/p/5208662.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!