AngularJS Protractor - 使用 Ng-Click 绑定在页面上查找元素 [英] AngularJS Protractor - Finding an Element on a Page Using Ng-Click Binding

查看:13
本文介绍了AngularJS Protractor - 使用 Ng-Click 绑定在页面上查找元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在页面上有一个按钮,如下所示:

I have a button on a page that looks like:

<button ng-click="myFunction()" ng-show="flag">
    Submit
</button>

元素没有 ID.

有没有办法使用绑定到 Ng-Click 的函数找到这个元素?还是我必须为此元素分配一个 ID 才能使用 Jasmine/Protractor 定位它?

Is there a way to find this element using the function bound to Ng-Click? Or do I have to assign an ID to this element to locate it using Jasmine / Protractor?

推荐答案

我通过 Protractor API 并没有找到任何与通过 ng-click 查找元素相关的内容.我确实找到了

I went through the Protractor API and didn't find anything related to finding an element through ng-click. I did find

element(by.buttonText("Submit"));

不太一样,但在我的环境中可以胜任.

Not quite the same, but does the job in my environment.

这篇关于AngularJS Protractor - 使用 Ng-Click 绑定在页面上查找元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆