我似乎无法让Protractor意识到Angular已加载并正在运行.当它打开Chrome时,我的应用程序会在浏览器中完全加载,因此我知道Angular已加载并正常运行.
配置文件:
exports.config = {
seleniumServerJar: 'C:/Dev/PrismWeb/selenium/selenium-server-standalone-2.35.0.jar',
seleniumPort: null,
chromeDriver: 'C:/Dev/PrismWeb/selenium/chromedriver.exe',
seleniumArgs: [],
seleniumAddress: null,
allScriptsTimeout: 110000,
specs: ['c:/dev/prismweb/test/e2e/*.js'],
capabilities: {'browserName': 'chrome'},
baseUrl: 'http://localhost:8080',
rootElement: 'html',
jasmineNodeOpts: {
onComplete: null,
isVerbose: true,
showColors: true,
includeStackTrace: true,
defaultTimeoutInterval: 30000
}
};
Run Code Online (Sandbox Code Playgroud)
我只有一个测试,我试图运行它失败因为Protractor找不到Angular.
考试:
describe('homepage loads: ', function(){
var ptor;
ptor = protractor.getInstance();
beforeEach(function(){
ptor.get('/');
});
it('should load the prism homepage: ', function(){
var usernameField = ptor.findElement(protractor.By.id("username"));
//expect(usernameField).toBeDefined();
});
});
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误:
UnknownError:javascript错误:未定义angular(会话信息:chrome = 30.0.1599.69)(驱动程序信息:chromedriver = 2.2,platform = Windows NT 6.1 SP1 x86_64)(警告:服务器未提供任何堆栈跟踪信息)命令持续时间或超时:19毫秒构建信息:版本:'2.35.0',修订版:'c916b9d',时间:'2013-08-12 …
我是新手进行单元测试并试图掌握一些东西.我正在尽力遵循本教程:http://www.yearofmoo.com/2013/01/full-spectrum-testing-with-angularjs-and-testacular.html#testing-filters.在我的AngularJS应用程序中,我有一个需要测试的过滤器.我有Node,Testacular和Jasmine正确设置和运行.我试图测试的过滤器非常简单:
myApp.filter('bill_ship', function () {
return function (userData) {
var output = "---";
switch (userData) {
case "0":
output = "Billing";
break;
case "1":
output = "Shipping";
break;
}
return output;
}
});
Run Code Online (Sandbox Code Playgroud)
我以为我的测试设置正确,但一直都失败了.
describe("Unit Testing: Filters - ", function() {
beforeEach(angular.mock.module('prismApp', ['bill_ship']));
//BillShip Filter
it('should have a bill-ship filter: ', inject(function($filter){
expect($filter('bill_ship')).not.toEqual(null);
}));
});
Run Code Online (Sandbox Code Playgroud)
它失败并显示以下消息:错误:参数'fn'不是函数,从bill_ship获取字符串.
那么......我在哪里做错了?
在我正在构建的 Ionic3 应用程序的其中一个屏幕中,我最终需要告诉 ion-content 标签在数据更改后自行刷新。这个过程在Ionic文档中得到了很好的记录,并且工作起来不是问题。然后我开始更新我的测试,乐趣开始了。无论我做什么,我似乎都无法将内容注入到我的测试中。
错误:
类型错误:无法读取未定义的属性“调整大小”
有问题的测试套件:
import {async, TestBed} from '@angular/core/testing';
import {CUSTOM_ELEMENTS_SCHEMA, ViewChild} from "@angular/core";
import {NavController, NavParams, Content} from "ionic-angular";
import {NavControllerMock} from "../../../test-config/custom-mocks/navController.mock";
import {NavParamsMock, ContentMock} from "ionic-mocks";
import {MessagingService} from "../shared/services/messaging.service";
import {MessagingServiceMock} from "../../../test-config/custom-mocks/messaging.service.mock";
import {VehicleService} from "../shared/services/vehicle.service";
import {VehicleServiceMock} from "../../../test-config/custom-mocks/vehicle.service.mock";
import {Vehicle} from "../shared/interfaces/vehicle.interface";
import {AlertButtonConfigClass} from "../shared/classes/alertConfig.class";
import {VehiclesDetailsComponent} from "../vehicles-details/vehicles-details.component";
import {UserClass} from "../shared/classes/user.class";
import {UserClassMock} from "../../../test-config/custom-mocks/user.class.mock";
import {VehiclesComponent} from "./vehicles.component";
describe('Vehicles Component', () => { …Run Code Online (Sandbox Code Playgroud) 在我的测试中,有很多期待.但其中一些可能不够严重,不能停止测试.我可以暂时忽略错误并在测试结束时抛出它们吗?
有人能告诉我如何在完成帧切换后继续引用iframe中的元素吗?我已经看过如何切换iframes InternJS中提供的解决方案无效,而实用的功能测试框架中的信息是不适用的(还是.)以下脚本返回错误Cannot read property 'apply' of undefined type: TypeError:
return Remote
.findAllByTagName('iframe')
.then(function (frames) {
return new Remote.constructor(Remote.session)
.switchToFrame(frames[0])
.getProperty('title')
.then(function (result) {
expect(result).to.equal('Rich text editor, rtDescAttach');
});
});
Run Code Online (Sandbox Code Playgroud)
我可以看到脚本失败的唯一原因是框架未正确定位.页面上有两个,我需要第一个.一旦完成,我真的想把一个框架的引用放在一个页面对象(这是我觉得它属于的地方),但我必须能够成功找到它,所以不要把车放在马前.建议和帮助非常感谢.
jasmine ×4
javascript ×3
angularjs ×2
karma-runner ×2
protractor ×2
angular ×1
assertions ×1
iframe ×1
intern ×1
ionic3 ×1
leadfoot ×1
selenium ×1
unit-testing ×1