我是量角器的新手.我已经为第一个用户登录应用程序编写了一个角度测试,然后单击特定按钮来计算一个数字.有时它有效,有时不行!
这是代码:
describe('Protractor Demo App', function () {
it('should login to app', function () {
browser.get('http://localhost:8080/main');
var userName = element(by.id('username'));
var passWord = element(by.id('pwd'));
var loginBtn = element(by.id('loginBtn'));
userName.sendKeys('user');
passWord.sendKeys('1');
loginBtn.click();
expect(browser.getCurrentUrl()).toEqual('http://localhost:8080/main/#/intro');
});
it('should calculate something', function () {
browser.get('http://localhost:8080/main/#/something');
var next = element(by.css('[ng-click="calculate()"]'));
element(by.model('accountNo')).sendKeys('0293949223008');
next.click();
expect(element(by.binding('result')).getText()).toEqual('55017000000029');
});
it('should show error for invalid input no', function () {
browser.get('http://localhost:8080/main/#/something');
var next = element(by.css('[ng-click="calculate()"]'));
element(by.model('accountNo')).sendKeys('9999456123789');
next.click();
expect(element(by.css('[class="messageObject warning"]')).getText()).toEqual('message for invalid input');
});
});
Run Code Online (Sandbox Code Playgroud)
首先"它"总是有效,但第二和第三,有时是工作.碰巧只有一个人没有工作;
这是错误:
消息:失败:未知错误:元素...在点(1214,275)处不可点击.其他元素将收到点击:...(会话信息:chrome = 55.0.2883.87)(驱动程序信息:chromedriver = 2.26.436362(5476ec6bf7ccbada1734a0cdec7d570bb042aa30),平台= Windows …