问题描述
是否有可能通过使用by.cssContainingText()
要得到一个同级例如:
HTML code是象下面这样:
< DIV NG重复=SomeNgRepeat级=NG-范围>
< DIV CLASS =文字标签> SomeText< / DIV>
< DIV CLASS =一些一流> someValue中< / DIV>
< / DIV>
利用获取的元素:
元素(by.cssContainingText('div.text标签','SomeText'))
现在发现上述元素的下一个兄弟。
我知道 CSS =形式input.username +输入
寻找兄弟的方式。然而,这并不在我的案子!
我觉得可以用来实现这个链,但不知道如何!
谢谢,
Sakshi
如果你使用会得到它一气呵成<一个href=\"http://angular.github.io/protractor/#/api?view=webdriver.By.xpath\"><$c$c>by.xpath()$c$c>:
元素(by.xpath('// DIV [@类=TEXT-标签和=SomeText则会] /以下同胞:: DIV'))
或者,您可以用 cssContainingText结合起来()
:
Is it possible to get the next sibling by using by.cssContainingText()
Example:HTML code is like below:
<div ng-repeat="SomeNgRepeat" class="ng-scope">
<div class="text-label" >SomeText</div>
<div class="some-class">SomeValue</div>
</div>
Get element by using:
element(by.cssContainingText('div.text-label','SomeText'))
Now find the next sibling of the above element.
I know of css=form input.username + input
way of finding the sibling. However, this is not working in my case!
I think 'chaining' can be used to achieve this, but don't know How!
Thanks,Sakshi
What if you would get it in one go using by.xpath()
:
element(by.xpath('//div[@class="text-label" and . = "SomeText"]/following-sibling::div'))
Or, you can combine it with cssContainingText()
:
element(by.cssContainingText('div.text-label','SomeText')).element(by.xpath('following-sibling::div'))
这篇关于是否有可能在用量角器来cssContainingText得到一个同级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!