量角器 ElementArrayFinder .last() [object Object] 没有方法 'indexof'
protractor ElementArrayFinder .last() [object Object] has no method 'indexof'
我正在尝试 运行 完成教程 http://angular.github.io/protractor/#/tutorial
当我尝试使用 .first()
或 .last()
方法获取元素时
测试失败并出现错误:
TypeError Object [object Object] has no method 'indexof'
这里是spec.js
var firstNumber = element(by.model('first'));
var secondNumber = element(by.model('second'));
var go = element(by.id('gobutton'));
var latest = element(by.binding('latest'));
var history = element.all(by.repeater('result in memory'));
beforeEach(function() {
browser.get('http://juliemr.github.io/protractor-demo/');
});
//...other tests passed
it('should have a history', function(){
firstNumber.sendKeys(1);
secondNumber.sendKeys(2);
go.click();
expect(history.count()).toEqual(1);
// expect(history.last()).toContain('1 + 2'); //error here
firstNumber.sendKeys(3);
secondNumber.sendKeys(5);
go.click();
expect(history.count()).toEqual(2);
// expect(history.first()).toContain('3 + 5'); //and here
});
关于这个 ElementArrayFinder API 应该 运行 没问题
我正在使用
- 茉莉花-1.3.1
- 量角器版本 1.8.0
您可能是想期待元素的文本:
expect(history.last().getText()).toContain('1 + 2');
expect(history.first().getText()).toContain('3 + 5');
我正在尝试 运行 完成教程 http://angular.github.io/protractor/#/tutorial
当我尝试使用 .first()
或 .last()
方法获取元素时
测试失败并出现错误:
TypeError Object [object Object] has no method 'indexof'
这里是spec.js
var firstNumber = element(by.model('first'));
var secondNumber = element(by.model('second'));
var go = element(by.id('gobutton'));
var latest = element(by.binding('latest'));
var history = element.all(by.repeater('result in memory'));
beforeEach(function() {
browser.get('http://juliemr.github.io/protractor-demo/');
});
//...other tests passed
it('should have a history', function(){
firstNumber.sendKeys(1);
secondNumber.sendKeys(2);
go.click();
expect(history.count()).toEqual(1);
// expect(history.last()).toContain('1 + 2'); //error here
firstNumber.sendKeys(3);
secondNumber.sendKeys(5);
go.click();
expect(history.count()).toEqual(2);
// expect(history.first()).toContain('3 + 5'); //and here
});
关于这个 ElementArrayFinder API 应该 运行 没问题
我正在使用
- 茉莉花-1.3.1
- 量角器版本 1.8.0
您可能是想期待元素的文本:
expect(history.last().getText()).toContain('1 + 2');
expect(history.first().getText()).toContain('3 + 5');