Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

testing login form with angularjs and karma

I am trying to create a E2E test using angular-js and karma, but for some reason the test is not progressing and hangs on the navigateTo().

the code I am using is

describe('Login', function(){
        beforeEach(function(){
            browser().navigateTo('http://localhost/blah');
            window.sleep(1);
        });

        it('should log in a user and redirect', function(){
           input('email').enter('user');
           input('password').enter('pass');
           element(':button').click();
           expect(browser().location().url()).toBe('/newBlahPage');
        });
    });

the html mark up is

<form action="" method="">
    <input type="test" name="email" id="email />
    <input type="password" name="pass" id="pass" />
    <button type=""submit">login</button>
</form>

I'm not sure if it is the test its self or the server side authenticate or if I am just missing something I have thought of yet.

like image 498
Ian Richards Avatar asked Nov 29 '25 17:11

Ian Richards


1 Answers

You have to change your form like this;

<form action="" method="" ng-submit="somefunctionname">
    <input type="test" name="email" id="email" ng-model="email" />
    <input type="password" name="pass" id="pass"  ng-model="pass"/>
    <button type=""submit">login</button>
</form>

Then write your test case as above. I think this will help.

like image 135
BKM Avatar answered Dec 01 '25 09:12

BKM



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!