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
CSS Next Sibling Selector matches all element that are only next sibling of specified element. This Selector identify by + (plus sign) between two selector element. Next sibling selected match only one element that are sibling of specified element.
Child Selector: The child selector selects all elements that are the immediate children of a specified element. Adjacent Sibling Selector: The adjacent sibling selector selects an element that is the adjacent siblings of a specified element.
This Selector identify by + (plus sign) between two selector element. Next sibling selected match only one element that are sibling of specified element. This syntax apply to match all <p> element that are only next sibling of specified <div> element.
It is used in HTML to make a web element’s layout and style beautifully. A CSS selector is a path pattern that can use the web element’s attributes to locate a web element on the web page. A CSS selector is more simpler and faster than XPath, especially in Internet Explorer.
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'))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With