Skip to content

Commit

Permalink
test now waits for json update to complete
Browse files Browse the repository at this point in the history
  • Loading branch information
mstevetodd committed Dec 5, 2019
1 parent c16c42d commit 3c55c23
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public WebServerAcceptanceSteps(jmri.InstanceManager instance) {
WebElement webTable = webDriver.findElement(By.xpath("//div[@id='wrap']//div[@class='container']//table"));

// find the table body.

WebElement tableBody = webTable.findElement(By.tagName("tbody"));
List<WebElement> rows = tableBody.findElements(By.tagName("tr"));
// we make an assumption that the first column is the systemName and
Expand Down Expand Up @@ -109,6 +110,7 @@ public WebServerAcceptanceSteps(jmri.InstanceManager instance) {

String tablePath = "//table[@id='jmri-data']";
String cellPath = tablePath + "//tr[@data-name='" + row + "']//td[@class='" + column +"']";
String cellAfterPath = cellPath + "[text()='" + after +"']";

wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(tablePath)));

Expand All @@ -121,11 +123,11 @@ public WebServerAcceptanceSteps(jmri.InstanceManager instance) {
assertThat(cells.get(0).getText()).isEqualTo(text);
//click on the target cell
cells.get(0).click();
//give page a chance to catch up
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(cellPath)));
//refresh the reference since the update replaced the cell
//wait for cell to be updated with the "after" value
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(cellAfterPath)));
//refresh the reference since the json update replaced the cell
cells = webDriver.findElements(By.xpath(cellPath));
//check that new value is correct
//check that "after" value is correct
assertThat(cells.get(0).getText()).isEqualTo(after);

});
Expand Down

0 comments on commit 3c55c23

Please sign in to comment.