我的量角器e2e测试不一致传递和失败.
这似乎可能是由于异步javascript,如下所述: 量角器:如何在单击按钮后等待页面完成?.
但是,这里提到了Protractor测试自动顺序/同步执行:https: //github.com/angular/protractor/issues/909
我的测试脚本:
describe('Login', function() {
var ptor;
beforeEach(function() {
browser.get('https://127.0.0.1:8443');
ptor = protractor.getInstance();
element(by.id('splash')).click();
browser.ignoreSynchronization = true; // <-- to proceed beyond splash screen
});
describe('with correct email and password', function() {
beforeEach(function() {
element(by.id('email')).sendKeys('admin@email.com');
element(by.id('password')).sendKeys('adminpassword');
element(by.id('loginButton')).click();
});
afterEach(function() {
ptor.findElement(by.id('logout')).then(function(elem) {
elem.click();
});
});
it('does not show alert', function() { // <-- sometimes passes, sometimes fails
expect(browser.isElementPresent(by.css('.alert-danger'))).toBe(false);
});
it('changes route to /admin', function() { // <-- sometimes passes, sometimes fails
expect(browser.getCurrentUrl()).toMatch(/\/admin/);
}); …Run Code Online (Sandbox Code Playgroud) 我正在AngularJS中构建一个应用程序,在使用Firefox时遇到选择下拉菜单的问题.
当我单击选择菜单并将鼠标悬停在选项上时,它会将所选选项从我的光标悬停的选项重置为默认/第一个选项.当选项数量很大时,选择正确的选项变得非常困难.
该应用程序需要JavaScript每秒更新一次屏幕,这似乎是原因.
但是,我似乎没有Chrome或Safari的这个问题.
有没有办法解决这个问题?
的index.html
<!DOCTYPE html>
<html ng-app="myapp">
<head>
<script data-require="angular.js@1.0.7" data-semver="1.0.7" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
<link href="style.css" rel="stylesheet" />
<script src="script.js"></script>
</head>
<body ng-controller="ctrl">
<div ng-init="updatetimer()">
<div>seconds: {{counter}}</div>
<select ng-model="something" ng-options="n.name for n in namelist">
<option value="">select person</option>
</select>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
的script.js
var app = angular.module('myapp', []);
var ctrl = ['$scope', '$timeout', function($scope, $timeout) {
$scope.counter=0;
$scope.namelist = [
{name: "Name1"}, {name: "Name2"}, {name: "Name3"}, {name: "Name4"}, {name: "Name5"},
{name: "Name6"}, {name: "Name7"}, {name: "Name8"}, {name: "Name9"}, …Run Code Online (Sandbox Code Playgroud) 我想在另一个控制器中共享一个控制器的$ scope函数,在本例中是一个AngularUI对话框.
特别是在下面的例子中,我希望$ scope.scopeVar在PopupCtrl中可用.
main.js
angular.module('MyApp', ['ui.bootstrap']);
var MainCtrl = ['$scope', '$dialog', '$rootScope', function($scope, $dialog, $rootScope) {
$scope.myTestVar = "hello";
$scope.myOpts = {
backdrop: true,
keyboard: true,
backdropClick: true,
resolve: { MainCtrl: function() { return MainCtrl; }},
templateUrl: 'myPopup.html',
controller: 'PopupCtrl'
};
$scope.scopeVar = 'scope var string that should appear in both index.html and myPopup.html.';
$rootScope.rootScopeVar = "rootScope var string that should appear in both index.html and myPopup.html.";
$scope.openDialog = function() {
var d = $dialog.dialog($scope.myOpts);
d.open().then(function() { …Run Code Online (Sandbox Code Playgroud) angularjs ×4
javascript ×4
angular-ui ×1
asynchronous ×1
firefox ×1
option ×1
protractor ×1
selection ×1