刚刚开始使用Protractor进行E2E测试,我在测试用例结构上遇到了一些问题。
我不确定是否可以将我的测试划分为单独的规范,然后从另一个规范中调用它们,或者我如何创建更好的辅助函数来处理这一问题。
我正在通过中继器查找元素,然后我想为中继器中的每个元素的每个操作进行测试。有点像这样:
describe('tasty', function () {
'use strict';
var ptor;
beforeEach(function () {
ptor = protractor.getInstance();
ptor.get('http://localhost:8000/');
});
it('Should sample three tasty fruits of every kind on my shopping list.', function () {
ptor.findElement(protractor.By.className('fruitstore')).click();
var fruitshelves = ptor.findElements(protractor.By.repeater('fruit in fruits').column('header'));
fruitshelves.then(function(arr) {
for (var i=0;i<arr.length; i++) {
// Pick up three fruits of this kind from the shelf and put in shopping cart
// Should be listed on my shopping list
// Open the wallet
// Should have money
// Pay for the fruits and put it in your shopping bag
// Should be able to complete the transaction
// For each one of the fruits in your shopping bag
// Take a bite
// Should be tasty
}
});
});
});
https://stackoverflow.com/questions/19998109
复制相似问题