Skip to content

Commit 2e48a95

Browse files
committed
to stabilize TestConnectorsResultImportUrls, catch StaleElementReferenceException;
when this exception is thrown, catch it and return null for the table entry looked for; this is intended to cause the waitUntil method to try again instead of failing with the exception
1 parent 8e80c6e commit 2e48a95

2 files changed

Lines changed: 19 additions & 13 deletions

File tree

java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/connectors/ResultImportUrlsPanelPO.java

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import static org.junit.jupiter.api.Assertions.assertNotNull;
44

5+
import java.util.logging.Logger;
6+
57
import org.openqa.selenium.StaleElementReferenceException;
68
import org.openqa.selenium.WebDriver;
79
import org.openqa.selenium.WebElement;
@@ -16,6 +18,7 @@
1618
import com.sap.sailing.selenium.pages.gwt.ListBoxPO;
1719

1820
public class ResultImportUrlsPanelPO extends PageArea {
21+
private static final Logger logger = Logger.getLogger(ResultImportUrlsPanelPO.class.getName());
1922

2023
@FindBy(how = BySeleniumId.class, using = "urlProviderListBox")
2124
private WebElement urlProviderListBox;
@@ -71,23 +74,27 @@ public void removeWithInlineButton(String url) {
7174
waitUntil(() -> findUrl(url) == null);
7275
}
7376

74-
private CellTablePO<DataEntryPO> getUserTable() {
77+
private CellTablePO<DataEntryPO> getUrlTable() {
7578
return new GenericCellTablePO<>(this.driver, this.urlTable, DataEntryPO.class);
7679
}
7780

7881
public DataEntryPO findUrl(final String url) {
79-
final CellTablePO<DataEntryPO> table = getUserTable();
80-
for (DataEntryPO entry : table.getEntries()) {
81-
String name;
82-
try {
83-
name = entry.getColumnContent("URL");
84-
} catch (StaleElementReferenceException e) {
85-
// entry is not existing any more but must not break iteration
86-
name = null;
87-
}
88-
if (url.equals(name)) {
89-
return entry;
82+
try {
83+
final CellTablePO<DataEntryPO> table = getUrlTable();
84+
for (DataEntryPO entry : table.getEntries()) {
85+
String name;
86+
try {
87+
name = entry.getColumnContent("URL");
88+
} catch (StaleElementReferenceException e) {
89+
// entry is not existing any more but must not break iteration
90+
name = null;
91+
}
92+
if (url.equals(name)) {
93+
return entry;
94+
}
9095
}
96+
} catch (StaleElementReferenceException e) {
97+
logger.warning("Stale element when trying to find URL in result import source table: "+e.getMessage());
9198
}
9299
return null;
93100
}

java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/adminconsole/TestConnectorsResultImportUrls.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ public void testUrlInlineDeletion() throws InterruptedException {
4040
resultImportUrlsPanel.selectUrlProviderByLabel(TEST_URL_PROVIDER_LABEL);
4141
// add
4242
resultImportUrlsPanel.addUrl(TEST_URL);
43-
Thread.sleep(1000); // give event loop time to render table
4443
resultImportUrlsPanel.removeWithInlineButton(TEST_URL);
4544
}
4645
}

0 commit comments

Comments
 (0)