|
8 | 8 | import org.openqa.selenium.Keys; |
9 | 9 | import org.openqa.selenium.WebDriver; |
10 | 10 | import org.openqa.selenium.WebElement; |
| 11 | +import org.openqa.selenium.support.ui.ExpectedConditions; |
| 12 | +import org.openqa.selenium.support.ui.WebDriverWait; |
| 13 | + |
| 14 | +import java.time.Duration; |
11 | 15 |
|
12 | 16 | public class PanoramaPublicSearchWebPart extends BodyWebPart<PanoramaPublicSearchWebPart.ElementCache> |
13 | 17 | { |
14 | 18 | private static String title = "Panorama Public Search"; |
15 | 19 |
|
| 20 | + private final WebDriverWait tabWait = new WebDriverWait(getDriver(), Duration.ofSeconds(1)); |
| 21 | + |
16 | 22 | public PanoramaPublicSearchWebPart(WebDriver driver, String title) |
17 | 23 | { |
18 | 24 | super(driver, title); |
@@ -121,41 +127,49 @@ public PanoramaPublicSearchWebPart setSmallMoleculeExactMatch(boolean value) |
121 | 127 | public PanoramaPublicSearchWebPart gotoExperimentSearch() |
122 | 128 | { |
123 | 129 | elementCache().experimentSearchTab.click(); |
| 130 | + tabWait.until(ExpectedConditions.visibilityOf(elementCache().author.getComponentElement())); |
124 | 131 | return this; |
125 | 132 | } |
126 | 133 |
|
127 | 134 | public PanoramaPublicSearchWebPart gotoProteinSearch() |
128 | 135 | { |
129 | 136 | elementCache().proteinTab.click(); |
| 137 | + tabWait.until(ExpectedConditions.visibilityOf(elementCache().protein.getComponentElement())); |
130 | 138 | return this; |
131 | 139 | } |
132 | 140 |
|
133 | 141 | public PanoramaPublicSearchWebPart gotoPeptideSearch() |
134 | 142 | { |
135 | 143 | elementCache().peptideTab.click(); |
| 144 | + tabWait.until(ExpectedConditions.visibilityOf(elementCache().peptide.getComponentElement())); |
136 | 145 | return this; |
137 | 146 | } |
138 | 147 |
|
139 | 148 | public PanoramaPublicSearchWebPart gotoSmallMoleculeSearch() |
140 | 149 | { |
141 | 150 | elementCache().smallMoleculeTab.click(); |
| 151 | + tabWait.until(ExpectedConditions.visibilityOf(elementCache().smallMolecule.getComponentElement())); |
142 | 152 | return this; |
143 | 153 | } |
144 | 154 |
|
145 | 155 | public DataRegionTable search() |
146 | 156 | { |
147 | | - elementCache().search.click(); |
148 | | - getWrapper().sleep(500); // for dataregion table to load after every search |
149 | | - return new DataRegionTable.DataRegionFinder(getDriver()).refindWhenNeeded(this); |
| 157 | + return doAndWaitForUpdate(() -> elementCache().search.click()); |
150 | 158 | } |
151 | 159 |
|
152 | 160 | public DataRegionTable clearAll() |
153 | 161 | { |
154 | | - elementCache().clearAll.click(); |
| 162 | + return doAndWaitForUpdate(() -> elementCache().clearAll.click()); |
| 163 | + } |
| 164 | + |
| 165 | + private DataRegionTable doAndWaitForUpdate(Runnable runnable) |
| 166 | + { |
| 167 | + // Can't use `DataRegionTable.doAndWaitForUpdate`. Doesn't reuse the same data region. |
| 168 | + getWrapper().doAndWaitForPageSignal(runnable, DataRegionTable.UPDATE_SIGNAL); |
155 | 169 | return new DataRegionTable.DataRegionFinder(getDriver()).refindWhenNeeded(this); |
156 | 170 | } |
157 | 171 |
|
158 | | - protected class ElementCache extends BodyWebPart.ElementCache |
| 172 | + protected class ElementCache extends BodyWebPart<?>.ElementCache |
159 | 173 | { |
160 | 174 | //Experiment search |
161 | 175 | final WebElement experimentSearchTab = Locator.tagWithText("label", "Experiment Search").findWhenNeeded(this); |
|
0 commit comments