I'm creating the e2e test for my application and I have a problem when I'm testing the login page. I want to test both the correct login and the incorrect one but the problem is that when you enter incorrect credentials you get an alert("Your email or password is incorrect") and that also gets triggered in the e2e test which means I have to click the "OK" button on the alert() in order to continue the test. Is there anyway to ignore the alert() in the test ?
Angularjs e2e testing with scenario test runner - ignore alert()
499 views Asked by Adrian Neatu At
2
There are 2 answers
1
Jesus is Lord
On
Granted this wouldn't necessarily qualify as E2E anymore - but you could abstract alert to a service in whatever directive or controller or service has the alert() call and then just mock that particular service. Here's an example:
Javascript
var myApp = angular.module('myApp', []);
myApp.factory('alert', function () {
return function (message) {
alert(message);
};
});
myApp.controller('MyController', function ($scope, alert) {
$scope.alert = alert;
});
View
<body ng-app="myApp" ng-controller="MyController">
<div ng-init="alert('test')"></div>
</body>
Related Questions in JAVASCRIPT
- Using Puppeteer to scrape a public API only when the data changes
- inline SVG text (js)
- An array of images and a for loop display the buttons. How to assign each button to open its own block by name?
- Storing the preferred font-size in localStorage
- Simple movie API request not showing up in the console log
- Authenticate Flask rest API
- Deploying sveltekit app with gunjs on vercel throws cannot find module './lib/text-encoding'
- How to request administrator rights?
- mp4 embedded videos within github pages website not loading
- Scrimba tutorial was working, suddenly stopped even trying the default
- In Datatables, start value resets to 0, when column sorting
- How do I link two models in mongoose?
- parameter values only being sent to certain columns in google sheet?
- Run main several times of wasm in browser
- Variable inside a Variable, not updating
Related Questions in ANGULARJS
- How to automatically change path in angular when scrolling
- Error two clicks to be able to login Angular 16
- Passing an array of objects through the $http.post method in angular JS does not work
- Understanding how to apply Angular Signals from beginning on an existing service
- provider duplicate while compiling a Cordova application for the Android platform
- How can I use angularjs $parse service in Angular?
- Width of custom headers in ag-grid (angular) doesn't match with column's width
- Issues with Katex/ngx-markdown Rendering in Angular 16
- How to make Angular SSR wait for async operations to finish that are initiated in ngOnInit?
- I want to install @angular/google-maps npm Package in angular 16.2.12 but "npm install @angular/google-maps" this is not working/ tell me other query
- Angular 17 standalone application integrate CKEditor 5 -- Error: window is not defined
- Why is $scope >= 0 showing true in interpolation while empty in controller?
- The XMLHttpRequest compatibility library was not found
- Making Gantt Chart Column Labels More Readable
- Pass key-value pairs of object as individual arguments to component in Angular
Related Questions in ANGULARJS-E2E
- How to locate a div with specific text and test id with Playwright?
- How to adjust Playwright Codegen's locating priority/strategy in an Angular project with third-party component libraries?
- How to reuse and run same test cases in every page of application using PROTRACTOR E2E?
- Error attempting to retrieve CODE sent to gmail account using MailListener Protractor/Jasmine end to end Test
- Error for e2e : Process exited with error code 135
- chromedriver unknown error: cannot create temp dir for user data dir (80.0.3987.16)
- How to clear browser cache in protractor
- Element is not clickable in Protractor
- How to fix "UnsupportedOperationError: The command 'POST /session/:id/timeouts/async_script' was not found." e2e tests,Safari,protractor,selenium?
- Angular e2e Fails at simple by.css expectation
- How to wait browser on protractor e2e test?
- protractor: random test fail
- How to find an element by using 'translate'? I have a common class name. So , i can't use class name to find elements
- Run several small test within one 'it' in E2E test using Protractor
- Failed conversion the IF/Else condition to Ramda Cond
Related Questions in ANGULAR-SCENARIO
- What is the test case format in gherkin language?
- $document.injector is not a function in Karma E2E Tests
- Angular Scenario Runner vs Protractor
- Subsequent variable declarations must have the same type. Variable 'angular' must be of type 'IAngularStatic', but here has type 'IAngularStatic'
- Scope variables undefined when testing controller with Karma and Jasmine with ng-scenario as framework
- Update View when Scope changes Angular js
- angularjs add a model layer
- Using Helper in AngularJS
- Angular Karma e2e with Grunt
- Karma, the test doesn't run
- Why was Protractor chosen over angular-scenario?
- Angularjs e2e testing with scenario test runner - ignore alert()
- Reuse E2E testing scenario in multiple scenarios
- Trouble with Karma + AngularJS Scenario Test Runner and a form
- Including angular-scenario.js breaks my Rails Jasmine tests, as in they don't run
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Please take a look at https://github.com/katranci/Angular-E2E-Window-Dialog-Commands
You can add
alertOK();in your test, before the alert will be shown and this let you skipped it.