Skip to content

Commit

Permalink
test: DialogShortcutIT Wait for child element presence before perform…
Browse files Browse the repository at this point in the history
…ing assertions (#12830)

Sometimes findElements(By.tagNvame("div")) seems to return results
before server roundtrips are completed, so list of elements is missing
elements. Performing a direct searching for child element by xpath
(findElement(By.xpath("div[N]")))) seem always to work.
To be noted that xpath position is 1 based

Fixes #10481, #10487, #10491
  • Loading branch information
mcollovati authored and vaadin-bot committed Jan 26, 2022
1 parent 70eade8 commit a67fe8e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package com.vaadin.flow.uitest.ui;

import org.junit.Ignore;
import org.junit.Test;
import org.openqa.selenium.By;

import static com.vaadin.flow.uitest.ui.DialogShortcutView.REUSABLE_DIALOG_ID;

@Ignore("Flaky test #10481, #10487, #10491")
public class ComplexDialogShortcutIT extends DialogShortcutIT {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@
import com.vaadin.testbench.TestBenchElement;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

import static com.vaadin.flow.uitest.ui.DialogShortcutView.REUSABLE_DIALOG_ID;

@Ignore("Flaky test #10481, #10487, #10491")
public class DialogShortcutIT extends ChromeBrowserTest {

private TestBenchElement eventLog;
Expand Down Expand Up @@ -202,8 +200,8 @@ protected void validateLatestShortcutEvent(int eventCounter,

private void validateShortcutEvent(int indexFromTop, int eventCounter,
String eventSourceId) {
final WebElement latestEvent = eventLog.findElements(By.tagName("div"))
.get(indexFromTop);
final WebElement latestEvent = waitUntil(driver -> eventLog.findElement(
By.xpath(String.format("div[%d]", indexFromTop + 1))));
Assert.assertEquals(
"Invalid latest event with " + indexFromTop + ":" + ":"
+ eventSourceId,
Expand Down

0 comments on commit a67fe8e

Please sign in to comment.