Reputation: 21149
element(...).getWebElement()
over element(...)
when both works exactly the sameUpvotes: 8
Views: 3524
Reputation: 474003
Protractor
is a convenient wrapper around WebDriverJS
- javascript selenium bindings.
element(...)
would result into an ElementFinder
instance introduced in Protractorelement(...).getWebElement()
would result into a WebElement
instance from WebDriverJS
. Basically, this gives you access to the pure "bare-metal" WebElement
.The most common use-case for using getWebElement()
is when you need to pass an ElementFinder
as a script argument - currently you have to call getWebElement()
for this to work:
var elm = element(by.id("myid"));
browser.executeScript("arguments[0].click()", elm.getWebElement());
There is an open feature-request to be able to pass ElementFinder
directly:
browser.executeScript("arguments[0].click()", elm); // not gonna work as of now
Upvotes: 15