Skip to content
This repository has been archived by the owner on Oct 3, 2024. It is now read-only.

Reusable variables/constants for tab.run() / tab.wait() #43

Open
ghost opened this issue Jul 10, 2018 · 0 comments
Open

Reusable variables/constants for tab.run() / tab.wait() #43

ghost opened this issue Jul 10, 2018 · 0 comments

Comments

@ghost
Copy link

ghost commented Jul 10, 2018

At the moment any variables have to be explicitly passed during tab.run() and tab.wait(). However very often we would like to reuse the same value between multiple invocations of these methods.

We could do something simple as:

tabs.define({ // perhaps also tab.define()
    username: 'foo',
    password: 'bla',
    findAuthFields: async () => wait.selectorAll('input#username, input#password').amount(2),
})

await tab.run(async () => {
    await wait.documentComplete()
    const [usernameField, passwordField] = await findAuthFields()

    await interact.type(usernameField, [...username])
    await interact.type(passwordField, [...password])
})

If we restrict this so that:

  • define() only affects new invocations and not pending invocations
  • content scripts can not define()
  • serialization will occur immediately when define() is called

The implementation should be very simple, and the resulting API and its side-effects will be easy to understand for scripters.

@ghost ghost added the enhancement label Jul 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

0 participants