w3c / w3c/webdriver

Supporting `await` in Execute Script

Open
#1,436 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Execute Script
Dominant language
HTML
Stars
718
Forks
228
PR merge metrics
No merged PRs in 30d

Description

There's been some talk about supporting await in the Execute Script and potentially Execute Async Script. This could be a great improvement, but it needs a little more definition before we can move on it.

  • Should "Execute Script" be interpreted with an async function?
  • Should "Execute Async Script" honor Promise return values?
  • Should "Execute Async Script" be interpreted with an async function?

The answer to the first question seems to be "yes," but it would be nice to have verification here in the project's issue tracker.

2 is possible if we're willing to make inferences on developer intent based on the type of the return value (i.e. if it's a "thenable", then ignore the callback function).

I think believe that is the only way to implement 2. If that's right, then 3 may not be feasible. If Execute Async Script were interpreted with an async function, then it would always return a thenable, and we would have no way to determine when to wait for the invocation of the callback function.

Personally, I think we should consider Execute Async Script a legacy API and not bother with any enhancements to it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Execute Script and Execute Async Script questions in this issue, then read the linked WebDriver meeting minutes. Define the intended Promise, async-function, and callback behavior before making any change; done means the API semantics are agreed and documented clearly enough to implement.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.