Sak*_*gla 5 javascript end-to-end css-selectors angularjs protractor
是否可以通过使用by.cssContainingText()获得下一个兄弟
示例:HTML代码如下所示:
<div ng-repeat="SomeNgRepeat" class="ng-scope">
<div class="text-label" >SomeText</div>
<div class="some-class">SomeValue</div>
</div>
Run Code Online (Sandbox Code Playgroud)
通过使用获取元素:
element(by.cssContainingText('div.text-label','SomeText'))
Run Code Online (Sandbox Code Playgroud)
现在找到上面元素的下一个兄弟.
我知道css=form input.username + input找到兄弟姐妹的方法.但是,这不适用于我的情况!
我认为'链接'可以用来实现这一点,但不知道怎么做!
谢谢,Sakshi
如果你一次性使用它会怎么样by.xpath():
element(by.xpath('//div[@class="text-label" and . = "SomeText"]/following-sibling::div'))
Run Code Online (Sandbox Code Playgroud)
或者,您可以将其与cssContainingText():
element(by.cssContainingText('div.text-label','SomeText')).element(by.xpath('following-sibling::div'))
Run Code Online (Sandbox Code Playgroud)