protractor cannot locate element with css on ng-click element

前端 未结 1 717
[愿得一人]
[愿得一人] 2021-01-18 23:21

html:

1条回答
  •  野的像风
    2021-01-18 23:41

    Having your locator based on the ng-click is not quite reliable and readable.

    Instead I would rely on the button text:

    by.xpath('//button[contains(., "Select None")]')
    

    or, on the class:

    by.css('button.helperButton')
    

    Or, if have a control over the application HTML templates - add an id attribute and use:

    by.id('mybuttonid')
    

    If you still want to use ng-click - try using starts-with CSS selector syntax to check ng-click attribute:

    by.css('button[ng-click^=select]')
    

    0 讨论(0)
提交回复
热议问题