Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

await await #20

Open
kyleect opened this issue Jan 4, 2020 · 2 comments
Open

await await #20

kyleect opened this issue Jan 4, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@kyleect
Copy link
Member

kyleect commented Jan 4, 2020

Getting elements and acting on them are both async actions. This requires two separate await statements. Element id caching won't work because it has to be assumed to be async regardless of cache status.

Example:

class LoginForm extends WebElement {
  get username() {
    return this.$("#username");
  }

  get password() {
    return this.$("#password");
  }

  get loginButton() {
    return this.$("#loginButton");
  }

  async fill(username, password) {
    await (await this.username).sendKeys(username);
    await (await this.password).sendKeys(password);
    await (await this.loginButton).click();
  }
}
@kyleect
Copy link
Member Author

kyleect commented Jan 5, 2020

Api/syntax maybe?

await loginForm.do(
  $ => $.username.sendKeys("username"),
  $ => $.password.sendKeys("password"),
  $ => $.loginButton.click(),
)

@kyleect
Copy link
Member Author

kyleect commented Jan 5, 2020

Or

await loginForm.do(
  $ => $.username.sendKeys("username")
    && $.password.sendKeys("password")
    && $.loginButton.click()
)

@kyleect kyleect added the enhancement New feature or request label Jan 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant