本文介紹了是否可以在 Protractor 中使用 cssContainingText 獲得下一個兄弟姐妹的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
是否可以通過使用 by.cssContainingText() 獲取下一個兄弟
Is it possible to get the next sibling by using by.cssContainingText()
示例:HTML 代碼如下:
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>
通過使用獲取元素:
element(by.cssContainingText('div.text-label','SomeText'))
現在找到上述元素的下一個兄弟.
Now find the next sibling of the above element.
我知道 css=form input.username + input
查找兄弟的方法.但是,這在我的情況下不起作用!
I know of css=form input.username + input
way of finding the sibling. However, this is not working in my case!
我認為'chaining'可以用來實現這一點,但不知道如何!
I think 'chaining' can be used to achieve this, but don't know How!
謝謝,颯颯
推薦答案
如果你使用 by.xpath()
:
What if you would get it in one go using by.xpath()
:
element(by.xpath('//div[@class="text-label" and . = "SomeText"]/following-sibling::div'))
或者,您可以將其與 cssContainingText()
結合使用:
Or, you can combine it with cssContainingText()
:
element(by.cssContainingText('div.text-label','SomeText')).element(by.xpath('following-sibling::div'))
這篇關于是否可以在 Protractor 中使用 cssContainingText 獲得下一個兄弟姐妹的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!