wd
wd copied to clipboard
Adding a custom command with that works with the current element
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?
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().