Wednesday, September 6, 2017

Locating parent elements with parentElementArrayFinder

Leave a Comment

There is a parentElementArrayFinder attribute available on an ElementFinder object which, from I understand, may return a parent element of the current:

var myElement = $(".myclass"); var parentElement = myElement.parentElementArrayFinder; 

It is, though, not documented as a part of Protractor's public API. Is parentElementArrayFinder a reliable and stable method to locate a parent element and would always return the same element as myElement.element(by.xpath(".."))?

2 Answers

Answers 1

Check this link as it is a similar kind of problem. https://github.com/angular/protractor/blob/768fd393d1084a8da0ec6eeaa57508bf17519a3f/lib/element.ts#LC817

Answers 2

I found the code for the ElementFinder here which has a prop for parentElementArrayFinder here.

From what I have found in the code. It throws an error if parentElementArrayFinder does not exist.

super(); if (!elementArrayFinder) {   throw new Error('BUG: elementArrayFinder cannot be empty'); } this.parentElementArrayFinder = elementArrayFinder; 

From this, we can safely assume it will always be there so I think it is safe to use.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment