Prashanth Sams Prashanth Sams - 1 year ago 150
Javascript Question

Difference between element(...) and element(...).getWebElement() in Protractor

  • Why we need
    when both works exactly the same

  • Why two APIs for the same functionality

Answer Source

Protractor is a convenient wrapper around WebDriverJS - javascript selenium bindings.

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("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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download