How can i identify element by model or by name in this the following example?

旧城冷巷雨未停 提交于 2019-12-06 12:25:10

问题


I 'm using protractor to automate my tests, in order to click into the login button the action couldn't be executed when i tried to identify element by name, xpath, id ...

element(by.name('Login')).click();

It works only when i identify it by css :

element(by.css('.login-button')).click();

or

  element(by.css('button[ng-disabled=clicked]')).click();

But the problem the test is passed and user isn't redirected to home page even if i put browser.sleep(8000); Is the login button identified by the right way with element(by.css('button[ng-disabled=clicked]')).click(); ?

You can find here the html code :

 <md-button type="submit" class="md-raised login-button" ng-disabled="clicked" translate="login.LOGIN">Login</md-button> </section>

 </div> </fieldset> </form> <md-divider></md-divider> <footer class="login-footer"> <div layout="row" layout-align="center center"> <md-button ng-click="goToCustomerCare()" class="login-footer-link" translate="login.CUSTOMER_CARE">Contact Customer Care</md-button> <div> | </div> <md-button ng-click="showDisclaimer()" class="login-footer-link" translate="login.DISCLAIMER">Disclaimer</md-button> </div> </footer> </div>

回答1:


There are a few buttons in the HTML code that you posted, but if you are trying to click the login button, you should be able to do

$('.md-raised').click(); or $('.md-raised.login-button').click();

This should search for the element by class.



来源:https://stackoverflow.com/questions/36861000/how-can-i-identify-element-by-model-or-by-name-in-this-the-following-example

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!