量角器通过模板引用变量(#)查找元素

时间:2019-04-08 10:15:03

标签: angular protractor

是否可以通过模板引用变量名称(#)定位元素?

<input #someInput>

2 个答案:

答案 0 :(得分:0)

您可以使用量角器定位器cssContainingText

Element(by.cssContainingText('input', 'variable name'));

答案 1 :(得分:0)

Update:

These template references do not get rendered in the DOM so you will not be able to use them to identify your elements. They are only present in your Angular templates.


Previous answer:

Can you try just locating by css directly like so

element(by.css('#someInput'));

I manually tested this in the browser and it appeared to work as seen below.

enter image description here