Skip to content

Commit 170ccf9

Browse files
authored
Unrevert change to LabModuleHelper (#88)
1 parent 148eb64 commit 170ccf9

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

LDK/test/src/org/labkey/test/util/external/labModules/LabModuleHelper.java

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,24 @@
1717

1818
import org.apache.commons.lang3.StringUtils;
1919
import org.jetbrains.annotations.Nullable;
20+
import org.junit.Assert;
2021
import org.labkey.test.BaseWebDriverTest;
2122
import org.labkey.test.Locator;
23+
import org.labkey.test.WebDriverWrapper;
2224
import org.labkey.test.util.DataRegionTable;
2325
import org.labkey.test.util.Ext4Helper;
2426
import org.labkey.test.util.UIAssayHelper;
2527
import org.labkey.test.util.ext4cmp.Ext4CmpRef;
2628
import org.labkey.test.util.ext4cmp.Ext4ComboRef;
2729
import org.labkey.test.util.ext4cmp.Ext4FieldRef;
2830
import org.labkey.test.util.ext4cmp.Ext4GridRef;
31+
import org.openqa.selenium.TimeoutException;
2932

3033
import java.io.File;
3134
import java.text.SimpleDateFormat;
3235
import java.util.List;
3336
import java.util.Random;
37+
import java.util.Set;
3438

3539
import static org.junit.Assert.assertEquals;
3640
import static org.junit.Assert.assertTrue;
@@ -248,8 +252,33 @@ public void goToAssayResultImport(String assayName, boolean supportsTemplates)
248252
_test.waitForText("Data Import");
249253
}
250254

255+
public String clickAndGetExampleData()
256+
{
257+
Locator btn = Locator.linkContainingText("Download Example Data");
258+
_test.waitForElement(btn);
259+
_test.waitAndClick(btn);
260+
261+
int iterations = 0;
262+
while (_test.getDriver().getWindowHandles().size() < 2)
263+
{
264+
iterations++;
265+
WebDriverWrapper.sleep(100);
266+
267+
if (iterations > 20)
268+
{
269+
throw new TimeoutException("Timed out waiting for second browser window");
270+
}
271+
}
272+
273+
return getExampleData();
274+
}
275+
251276
public String getExampleData()
252277
{
278+
String ret = null;
279+
280+
Set<String> handles = _test.getDriver().getWindowHandles();
281+
Assert.assertTrue("Expected more than one open window, was: " + handles.size(), handles.size() > 1);
253282
String currentWindow = _test.getDriver().getWindowHandle();
254283
for (String handle : _test.getDriver().getWindowHandles())
255284
{
@@ -259,10 +288,13 @@ public String getExampleData()
259288
String text = getPageText();
260289
_test.getDriver().close();
261290
_test.getDriver().switchTo().window(currentWindow);
262-
return text;
291+
ret = StringUtils.trimToNull(text);
263292
}
264293
}
265-
return null;
294+
295+
Assert.assertNotNull("Unable to retrieve example data", StringUtils.trimToNull(ret));
296+
297+
return ret;
266298
}
267299

268300
public Locator toolIcon(String name)

0 commit comments

Comments
 (0)