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

Commit

Permalink
Merge pull request #81 from devbridge/79-add-clear-input-field-method
Browse files Browse the repository at this point in the history
Added clearText() method. Added test
  • Loading branch information
jevgenijusmarinuskinas authored Nov 24, 2020
2 parents 74ea04c + 903e6b4 commit 20694fd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
14 changes: 14 additions & 0 deletions example/tests/elementActions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,20 @@ describe("Element Actions", () => {
expect(await inputElement.value()).toEqual(inputNumber);
});

it("should clear element's text value", async () => {
//Arrange
await page.goto("http://the-internet.herokuapp.com/inputs");
const inputElement = new Element("input[type=number]");
const inputNumber = "456";
await inputElement.enterText(inputNumber);

//Act
await inputElement.clearText();

//Assert
expect(await inputElement.value()).toEqual("");
});

xit("should cover element", async () => {
//TODO: Test should be added and unxit`ed when DTAF-78 is implemented.
});
Expand Down
9 changes: 9 additions & 0 deletions framework/Element.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,15 @@ export default class Element {
await elementHandle.type(text);
}

async clearText() {
console.log(`Clearing the text value for ${this.selector} ...`);
await this.click();
await page.keyboard.down("Control");
await page.keyboard.press("A");
await page.keyboard.up("Control");
await page.keyboard.press("Backspace");
}

async takeScreenshot() {
console.log(`Taking the screenshot for ${this.selector} ...`);
const elementHandle = await this.wait();
Expand Down

0 comments on commit 20694fd

Please sign in to comment.