Protractor: How to locate a sibling of a given element?

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.


This is what I actually implement on a Page Object:

  this.widgets['select-status'] = this.ids['select-status']
      .element(by.xpath('following-sibling::div[1]'));
  this.widgets['select-status.dropdown'] = element(by.css('.btn-group.bootstrap-select.open'));

The page is based on Bootstrap along with Bootstrap Select. Anyways, we traverse the DOM along the following-sibling axis. Refer to XPATH specification for yourself.