我基本上是在尝试为这个网页编写测试:http ://www.talklocal.com/mobile/#/step1
我想填写表格中的信息,然后单击下一步按钮。虽然测试应该将我重定向到表单的第 2 步(检查 url),但它没有,而是失败了。测试代码:
describe('going from step1 to step 2', function() {
//fill out step 1 form
beforeEach(function() {
browser.get('index.html');
element(by.model('Request.categoryID')).click();
element(by.css('option[value=0]')).click();
element(by.class('where-text ng-pristine ng-valid').sendKeys('20902'));
element(by.class('btn action-button')).click();
});
it('should be on the step2 page', function() {
browser.getLocationAbsUrl().then(function(url) {
expect(url.split('#')[1]).toBe('/step2');
});
});
});
终端中的错误消息:
1) myApp going from step1 to step 2 should be on the step2 page
Message:
TypeError: Object [object Object] has no method 'class'
2) myApp going from step1 to step 2 should be on the step2 page
Message:
Expected '/step1' to be '/step2'.
3 tests, 5 assertions, 2 failures
我用谷歌搜索了这些错误,并一直在尝试为 element(by.attribute) 方法插入不同的类和属性,但无济于事。
我将不胜感激有关此问题的任何和所有反馈。谢谢!