Cloning elements

While researching the available methods ElementFinder

and ElementArrayFinder

, I noticed that there is a method clone()

that is briefly documented

Create a shallow copy of ElementFinder.

From what I understand clone()

does not come from WebdriverJS

and is a vendor specific function. What I don't understand is why you want to clone an element search or an array of elements in your tests? In what cases is it used clone()


I went through the source code protractor

to find examples of use, but only found a basic changeset that didn't help me get a clear picture.


source to share

1 answer

A clone was introduced here: . And to be honest, now I think about it, it was a mistake to present it as it does not offer any practical value.

Initially, it was dangerous that subsequent elementFinders chains would affect the previous ones:

var outerElement = element(;
var outerText = outerElement.getText();
var innerElement = innerElement.element(;
// Now that I chained more things onto outerElement, is the original outerElement still behaving the same as before? (i.e. is outerText the same as outerElement.getText() still)




All Articles