【发布时间】:2017-05-11 14:59:24
【问题描述】:
我是量角器的新手。我已经为 Angular 编写了一个测试,该测试首先用户登录到应用程序,然后单击特定按钮来计算一个数字。有时有效,有时无效!
这是代码:
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');
});
});
第一个“它”总是有效,但第二个和第三个,有时有效。碰巧只有一个没有工作;
这是错误:
消息: 失败:未知错误: 元素 ... 在点 (1214, 275)。其他元素会收到点击:... (会话信息:chrome=55.0.2883.87) (驱动信息: chromedriver=2.26.436362 (5476ec6bf7ccbada1734a0cdec7d570bb042aa30),platform=Windows NT 10.0.10240 x86_64)(警告:服务器未提供任何堆栈跟踪信息) 命令持续时间或超时:78 毫秒 构建信息:版本:'2.53.1',修订:'a36b8b1',时间:'2016-06-30 17:37:03' 系统信息:主机:'user',ip:'ip',os.name:'Windows 8.1',os.arch:'amd64',os.version:'6.3',java.version:'1.8.0_45' 驱动程序信息:org.openqa.selenium.chrome.ChromeDriver 功能 [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, 铬={铬驱动程序版本=2.26.436362 (5476ec6bf7ccbada1734a0cdec7d570bb042aa30), userDataDir='add'}, 需要HeapSnapshot=true,pageLoadStrategy=正常, databaseEnabled=false,handlesAlerts=true,hasTouchScreen=false, 版本=55.0.2883.87,平台=WIN8_1,browserConnectionEnabled=false, nativeEvents=true,acceptSslCerts=true,locationContextEnabled=true, webStorageEnabled=true,browserName=chrome,takeScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, 意外警报行为=}] 会话 ID:45d78fbebf15daa1dde971f5f7470551
我不知道问题是什么。谁能帮我? 提前致谢。
【问题讨论】:
标签: javascript angularjs jasmine protractor end-to-end