Protractor find an element by tag inside a div(量角器在 div 中按标签查找元素)
问题描述
我在一个 HTML 页面中有一个 div,它的名称总是已知的,在这个 div 里面有一个 href,它的细节是未知的.它可能是父母的直系子女,也可能是进一步的孙子女.看起来像这样:
I've got a div in an HTML Page of which the name is always known and inside this div there is an href, the details of which are not known. It could be the direct child of the parent or it could be a further grandchild. Looks something like this:
<div class="divName">
...
<a href="some url">some text</a>
...
</div>
我知道这个 div 中只有一个链接,所以我想找到一个链接并单击它.
I know that there will only be one link within this div, so I want to find the one link and click it.
我尝试了以下方法,但似乎不起作用:
I've tried the following but it doesn't seem to be working:
element(by.classname('divName')).find('a').click();
有什么想法吗?
推荐答案
element(by.css('.divName a')).click();
或者更短的符号:
$('.divName a').click();
这篇关于量角器在 div 中按标签查找元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:量角器在 div 中按标签查找元素


基础教程推荐
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01