In a test case I would like to compare the text of an anchor with an expected one, but the anchor also contains i tags. Does anybody have a hint on how to do it?
在一个测试用例中,我想比较锚点的文本和预期的锚点,但是锚点也包含I标记。有人知道怎么做吗?
E.g. (how to get the name of the selected language):
例(如何获得所选语言的名称):
<a class="dropdown-button btn" href="#" data-activates="languageDropdown">
<i class="material-icons">language</i>
{{selectedLanguage.name}}
<i class="material-icons">arrow_drop_down</i>
</a>
2 个解决方案
#1
2
In this case, select it by Angular binding, and then you can forget about the DOM entirely:
在这种情况下,通过角绑定选择它,然后您就可以完全忘记DOM:
expect(element(by.binding('selectedLanguage.name')).getText()).toBe('Expected Language');
#2
0
I really like the by.binding()
approach presented by @SkinnyJ. Alternatively options:
我非常喜欢@SkinnyJ提出的by.binding()方法。或者选择:
element(by.css('a.dropdown-button'))
element(by.css('a[data-activates=languageDropdown]'))
#1
2
In this case, select it by Angular binding, and then you can forget about the DOM entirely:
在这种情况下,通过角绑定选择它,然后您就可以完全忘记DOM:
expect(element(by.binding('selectedLanguage.name')).getText()).toBe('Expected Language');
#2
0
I really like the by.binding()
approach presented by @SkinnyJ. Alternatively options:
我非常喜欢@SkinnyJ提出的by.binding()方法。或者选择:
element(by.css('a.dropdown-button'))
element(by.css('a[data-activates=languageDropdown]'))