【发布时间】:2016-03-15 16:09:03
【问题描述】:
it("Checking for file uploaded pop up window",function(){
expect(element(by.css('md-dialog-content')).isPresent()).toBe(true); //Check the upload success window
var h2 = element(by.css('md-dialog-content > h2')).getText(); //Get h2 of the pop up
expect(h2).toEqual("Attention"); //h2 is equal to attention
var h2Content = element(by.css('md-dialog-content > p')).getText(); //get h2 content
expect(h2Content).toEqual("File: "+"repair_anonymized_1000sample.json"+" uploaded"); //content h2 is equal to ...
element(by.css('.md-actions > button')).click(); //Click on the close button
expect(element(by.css('md-dialog-content')).isPresent()).toBe(false); //THe dialog box will not exist
});
我要做的是检查“md-dialog-content”元素的弹出对话框。我正在检查它里面的 h2 和 p 元素。
但是量角器给了我一个错误,说他们期望第一个期望是“假”而不是真的。这意味着他们没有检测到明显存在的 md-dialog-content。
是的,之前的“it”测试已经完成了所有必要的步骤来生成此对话框以弹出。
我的测试规范的前面步骤(我正在使用 ng-file-upload):
it("Upload files",function(){
var fileToUpload = "/home/vagrant/Desktop/repair_anonymized_1000sample.json";
var absolutePath = path.resolve(fileToUpload);
browser.executeAsyncScript(function(callback){ //Fire Fox needs this code to display the hidden input element or it will give error of element not visible
document.querySelectorAll('input[type="file"]')[0]
.style.visibility= 'visible';
callback();
});
var input = element(by.css('input[type="file"]'));
input.sendKeys(absolutePath);
browser.sleep(2000); //wait for the alert to appear
});
【问题讨论】:
标签: javascript selenium automation protractor