Protractor: How to locate a sibling of a given element?
jasmine, javascript, karma-runner, protractor, ui-testing
Solution
Thanks for the inspiration. Here's my solution, not the one I was hoping for, but it works:
element(by.css('???')).element(by.xpath('..')).element(by.css('???')).click();
The chaining and the by.xpath, which allows to get back to the parent are the keys of the solution.
Problem
``` <div> <a href='...'>LINK</a> <img class='image' /> </div> <div> ... </div> ``` I want to get a protractor element for the `img` tag with `image` class. I already know the link text 'LINK'. In other words, "How do I locate a sibling of a given element?". The first line of the code could look like this: ``` browser.findElement(by.linkText('LINK')) ``` Any ideas? Thanks & Cheers