From f45aad92f5b72242e4021866c757e1cbda4cc976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr> Date: Wed, 5 Apr 2023 14:30:22 +0200 Subject: [PATCH] feat(e2e): add reliable input clearing function refs #616 --- e2e/calculator.po.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/e2e/calculator.po.ts b/e2e/calculator.po.ts index e73d117a9..f5dcd07e9 100644 --- a/e2e/calculator.po.ts +++ b/e2e/calculator.po.ts @@ -1,4 +1,4 @@ -import { by, element, ElementFinder, browser, protractor, ElementArrayFinder } from "protractor"; +import { by, element, ElementFinder, browser, protractor, ElementArrayFinder, Key } from "protractor"; import { scrollPageToTop, scrollToElement } from "./util.po"; export class CalculatorPage { @@ -458,4 +458,15 @@ export class CalculatorPage { getCalculatorHelpButton() { return element(by.css("#help-calc")); } + + /** + * reliable input clearing + */ + async clearInput(inp: ElementFinder) { + const txt = await inp.getAttribute('value'); + const len = txt.length; + for (let n = 0; n < len; n++) { + await inp.sendKeys(Key.BACK_SPACE); + } + } } -- GitLab