Skip to content

Instantly share code, notes, and snippets.

@koola
Created September 1, 2017 02:11
Show Gist options
  • Save koola/428064def65e0334d5bc731ad9df1faa to your computer and use it in GitHub Desktop.
Save koola/428064def65e0334d5bc731ad9df1faa to your computer and use it in GitHub Desktop.
class BrowserActions {
click(element, timeout=5000) {
return this.waitForElementToBeClickable(element, timeout).then(() => {
return element.click();
})
}
waitForElementToBeClickable(ele, timeout=5000) {
return browser.wait(EC.visibilityOf(ele), timeout).then(() => {
return browser.wait(EC.elementToBeClickable(ele), timeout);
});
}
waitForAllElement(ele, index, timeout=5000) {
return browser.wait(ele => ele.count>=index,timeout);
}
sendKeys(element, text, timeout=5000) {
return this.waitForElementToBeClickable(element, timeout).then(() => {
return element.clear().then(() => {
return element.sendKeys(text);
});
});
}
}
module.exports = new BrowserActions();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment