wd icon indicating copy to clipboard operation
wd copied to clipboard

Adding a custom command with that works with the current element

Open DullReferenceException opened this issue 10 years ago • 1 comments

Is there a way to add a custom method with addPromiseChainMethod in a way where the current element is somehow available? For example, if we want to add a clickWithJS command:

browser
  .getElementByCss(...)
  .clickWithJS()

...how would we go about gaining access to that element that was previously selected?

DullReferenceException avatar Oct 28 '15 21:10 DullReferenceException

I don't know when they added it, but you now have addElementPromiseChainMethod. The this object inside a method you add with it will be the element from the element scope (what you call the "current element"). So clickWithJS could do something like this.click().

ohadschn avatar Dec 29 '16 14:12 ohadschn