Skip to content

Commit

Permalink
POSHI-30 Add retry logic to 'type' method if value doesn't match
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjiheigel authored and brianchandotcom committed Mar 13, 2020
1 parent 5d95d3a commit 0161d8d
Showing 1 changed file with 27 additions and 0 deletions.
Expand Up @@ -2849,6 +2849,33 @@ public void type(String locator, String value) {
webElement.clear();

typeKeys(locator, value);

int maxRetries = 5;
int retryCount = 0;
String typedValue = webElement.getAttribute("value");

while (!typedValue.equals(value) && (retryCount < maxRetries)) {
retryCount++;

if (retryCount < maxRetries) {
System.out.println(
"Actual typed value: '" + typedValue +
"' did not match expected typed value: '" + value +
"'. Retrying LiferaySelenium.type() attempt #" +
retryCount + ".");

webElement.clear();

typeKeys(locator, value);

typedValue = webElement.getAttribute("value");
}
else {
throw new RuntimeException(
"Actual typed value: '" + typedValue +
"' did not match expected typed value: '" + value);
}
}
}

@Override
Expand Down

0 comments on commit 0161d8d

Please sign in to comment.