w3c / webdriver

Remote control interface that enables introspection and control of user agents.
https://w3c.github.io/webdriver/
Other
676 stars 190 forks source link

Consider introducing per-Element script execution. #1776

Open ioquatix opened 7 months ago

ioquatix commented 7 months ago

13.2 Executing Script

It would be nice if we could have the identical document level script execution, per element, such that this would be set to the element in question.

I emulated this, but I think it's such a useful feature it should be a first class operation.

class Element
  # ...
  def execute(script, *arguments)
    @session.execute("return (function(){#{script}}).call(...arguments)", self, *arguments)
  end

  def execute_async(script, *arguments)
    @session.execute_async("return (function(){#{script}}).call(...arguments)", self, *arguments)
  end
  # ...