Protractor quot;by.css()quot; vs quot;$()quot; Dollar Sign vs quot;$$()quot; #39;Bling Bling#39;(量角器“by.css()vs“$()美元符号与“$$()亮闪闪)
问题描述
我不太明白 $ 和 $$ 命令的用途.我认为它们只是by.css"的替代品,但为什么要使用 $$?
I don't really understand what the $ and $$ commands are for. I thought they are just a replacement for 'by.css' but why the $$?
<element id = "eId"></element>
我认为,鉴于上述情况,这些将是等效的:
I thought, that given the above, these would be equivalent:
element(by.css('#eId'));
和
element($('#eId'));
但是,第一个有效,第二个无效.为什么,这三者有什么区别?
However, the first one works and the second doesn't. Why, what's the difference between the three?
docs 帮助不大.他们似乎暗示$"仅用于链接,例如element(by.css('#eId')).element($('#childId'));
或选择第一个元素,然后选择第一个元素内的第二个元素."但是,我已经看到使用 $ 来选择第一个元素的示例.
The docs are of little help. They seem to imply that "$" is for chaining only, e.g. element(by.css('#eId')).element($('#childId'));
or "Select the first element, and then select the second element within the first element.' However, I have seen examples with $ being used to select the first element.
不管怎样,这三个(by.css、$ 和 $$)之间有什么区别?"的文字很多.
Anyway, that's a lot of text for "What are the differences between the three (by.css, $, and $$)?"
推荐答案
$
和 $$
只是方便的快捷方式.
$
and $$
are just convenient shortcuts.
$("selector")
是 element(by.css("selector"))
的替代品.
$$("selector")
是 element.all(by.css("selector"))
的替代品.
仅供参考,引用自 源代码:p>
FYI, quote from the source code:
ElementFinder.prototype.$ = function(selector) {
return this.element(webdriver.By.css(selector));
};
ElementArrayFinder.prototype.$$ = function(selector) {
return this.all(webdriver.By.css(selector));
};
以及最初实现它的实际提交.
这篇关于量角器“by.css()"vs“$()"美元符号与“$$()"'亮闪闪'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:量角器“by.css()"vs“$()"美元符号与“$$()"'亮闪闪'


基础教程推荐
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01
- 直接将值设置为滑块 2022-01-01
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01
- 自定义 XMLHttpRequest.prototype.open 2022-01-01
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- Chart.js 在线性图表上拖动点 2022-01-01