angularjs - Trouble with Protractor and Angular 2 application with Angular sign in -
i've been having issues getting protractor e2e test work. application i'm testing angular 2 , sign in through separate angularjs site. i'm trying create test logging in, checking site loads correctly given credentials, , logging out. can log in fine, navigate site, , navigate auth page. however, once gets there, protractor stops before clicks sign out button , webdriver stays stuck on page instead of closing.
here page object code functions:
`var loginpage = function() { this.loginemail = element(by.css('[id="email-input"]')); this.loginpassword = element(by.css('[ng-model="loginform.password"]')); this.signinbutton = element(by.css('[name="signin"]')); this.twofactorcodeinput = element(by.css('[id="code-input"]')); this.verifytwofactorbutton = element(by.css('[name="verifytwofactor"]')); this.signoutbutton = element(by.css('[ng-click="signout()"]')); this.navigate = function() { browser.get('http://spectrumxg.dev:3007'); }; this.loginas = function (username, password) { this.loginemail.sendkeys(username); this.loginpassword.sendkeys(password); this.signinbutton.click(); browser.sleep(2000); this.twofactorcodeinput.sendkeys('0000000'); this.verifytwofactorbutton.click(); browser.sleep(2000); browser.get('http://xpect.spectrumxg.dev:9000'); }; this.logout = function () { browser.get('http://spectrumxg.dev:3007'); browser.refresh(); browser.sleep(3000); this.signoutbutton.click(); }; }; module.exports = loginpage;`
here test:
var loginpage = require('../pageobjects/login.po.js'); var loginpage = new loginpage(); var dashboardpage = require('../pageobjects/dashboard.po.js'); var dashboardpage = new dashboardpage(); describe('logging in', function() { loginpage.navigate(); loginpage.loginas('s@a.com', '123'); browser.sleep(3000); beforeeach(function() { browser.ignoresynchronization = true; }); it('should able login', function() { expect(browser.driver.getcurrenturl()).tocontain('xpect.spectrumxg.dev:9000/#/dashboard'); expect(dashboardpage.navbar.isdisplayed()).tobe(true); }); it('should able logout', function() { this.signoutbutton.click(); browser.sleep(3000); expect(loginpage.loginemail.isdisplayed()).tobe(true); }); });
i able click on signout button in element explorer. not sure if has going angularjs angular 2 , angular js.
here webdriver log:
15:17:36.429 info - executing: [execute async script: try { return (function (rootselector, callback) { var el = document.queryselector(rootselector); try { if (window.getangulartestability) { window.getangulartestability(el).whenstable(callback); return; } if (!window.angular) { throw new error('window.angular undefined. either ' + 'because non-angular page or because test involves ' + 'client-side navigation, can interfere protractor\'s ' + 'bootstrapping. see http://git.io/v4gxm details'); } if (angular.gettestability) { angular.gettestability(el).whenstable(callback); } else { if (!angular.element(el).injector()) { throw new error('root element (' + rootselector + ') has no injector.' + ' may mean not inside ng-app.'); } angular.element(el).injector().get('$browser'). notifywhennooutstandingrequests(callback); } } catch (err) { callback(err.message); } }).apply(this, arguments); } catch(e) { throw (e instanceof error) ? e : new error(e); }, [body]]) 15:17:36.572 info - done: [execute async script: try { return (function (rootselector, callback) { var el = document.queryselector(rootselector); try { if (window.getangulartestability) { window.getangulartestability(el).whenstable(callback); return; } if (!window.angular) { throw new error('window.angular undefined. either ' + 'because non-angular page or because test involves ' + 'client-side navigation, can interfere protractor\'s ' + 'bootstrapping. see http://git.io/v4gxm details'); } if (angular.gettestability) { angular.gettestability(el).whenstable(callback); } else { if (!angular.element(el).injector()) { throw new error('root element (' + rootselector + ') has no injector.' + ' may mean not inside ng-app.'); } angular.element(el).injector().get('$browser'). notifywhennooutstandingrequests(callback); } } catch (err) { callback(err.message); } }).apply(this, arguments); } catch(e) { throw (e instanceof error) ? e : new error(e); }, [body]]
Comments
Post a Comment