javascript - click on hyperlinks in unit testing using protactor in angularjs -


i new in unit testing in angularjs. read tutorial from:

https://github.com/angular/protractor/blob/master/docs/tutorial.md.

i want click on hyperlink dont know how can achieve this.

here code:

<li ng-repeat="menu in sidebarlinks" ng-if="menu.visible == true " ng-class="{active: isactive('/{{menu.action}}')}">                     <a ng-href="#/{{menu.action}}" title="{{menu.name}}" ng-click="loadsubmenus(menu.action)"  ng-class="{active: isactive('/{{menu.action}}')}">                         <div class="icon {{menu.icon}}" ng-class="{active: isactive('/{{menu.action}}')}"></div>                             <span>{{menu.name}} </span>                     </a>                 </li>    

in unit testing:

describe('protractor demo app', function() {     browser.driver.get('https://localhost:8443/login.html');  browser.driver.findelement(by.id('name')).sendkeys('test'); browser.driver.findelement(by.id('password')).sendkeys('test'); browser.driver.findelement(by.id('login')).click();  }); 

after login url https://localhost:8443/#/dash

after click on link url should https://localhost:8443/#/hypera

since links won't work else because you're running locally on machine, can tell best way it.

if you're dealing hyperlinks, need element you've set 'login'. i'm not seeing in html snippet can't give correct path.

if basic hyperlink, find using like:

element(by.linktext('login')).click() 

if login button's text indeed 'login'. if else, button, you'll need find exact element , like:

element(by.css('span[class="login"]')).click() 

if login button under 'span' tag in html page.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -