Skip to content

Commit

Permalink
Send enter after text to element optionally
Browse files Browse the repository at this point in the history
  • Loading branch information
schipiga committed Jul 23, 2018
1 parent d755dfe commit 24c6258
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/pom/element.js
Expand Up @@ -88,19 +88,23 @@ Element.prototype.getText = async function (opts) {
* @arg {boolean} [opts.now=false] - Make it immediately.
* @arg {?number} [opts.timeout] - Time to wait for element visibility, sec.
* @arg {boolean} [opts.scroll=true] - Scroll to element.
* @arg {boolean} [opts.enter=false] - Send `Enter` after text.
* @return {Promise}
*/
Element.prototype.setText = async function (text, opts) {

opts = U.defVal(opts, {});
var now = U.defVal(opts.now, false);
var scroll = U.defVal(opts.scroll, true);
const enter = U.defVal(opts.enter, false);

if (scroll) {
await this.scrollIntoView(opts);
} else if (!now) {
await this.waitForVisible(opts.timeout);
};
if (enter) text += "\n";

await this._getDriver().setValue(this.selector, text);
};
/**
Expand Down
3 changes: 1 addition & 2 deletions tests/e2e/tests.js
Expand Up @@ -18,8 +18,7 @@ Steps.register({
*/
searchPom: async function (text) {
await this.openPage(indexPage.name);
await indexPage.searchField.setText(text);
await indexPage.searchButton.click();
await indexPage.searchField.setText(text, { enter: true });
await this.pause(1, "wait for result");
},
/**
Expand Down

0 comments on commit 24c6258

Please sign in to comment.