Files
Ken Sodemann 9cc0e5519c fix(e2e): make the wait logic more flexible
We will now by default wait for something to be hydrated, and then wait for the passed in tag to be visible whether it is hydrated or not.

This allows the tag passed in to be associated with a standard (non-stencil) element.
2018-02-07 11:27:31 -06:00

26 lines
895 B
JavaScript

const webdriver = require('selenium-webdriver');
const By = webdriver.By;
const until = webdriver.until;
module.exports = class E2ETestPage {
constructor(driver, url) {
this.url = url;
this.driver = driver;
}
async navigate(tagName = '') {
this.driver.navigate().to(this.url);
this.driver.manage().timeouts().implicitlyWait(10000);
await this.driver.wait(until.elementLocated(By.css(`.hydrated`)));
const tag = tagName || '.hydrated';
return await this.driver.wait(until.elementIsVisible(this.driver.findElement(By.css(tag))));
}
async present(clickTarget, options) {
await this.navigate(clickTarget);
this.driver.findElement(By.css(clickTarget)).click();
await this.driver.wait(until.elementLocated(By.css(options.waitFor)));
return await this.driver.wait(until.elementIsVisible(this.driver.findElement(By.css(options.waitFor))));
}
}