@@ -255,6 +255,7 @@ public void goToAssayResultImport(String assayName, boolean supportsTemplates)
255255 public String clickAndGetExampleData ()
256256 {
257257 Locator btn = Locator .linkContainingText ("Download Example Data" );
258+ String currentWindow = _test .getDriver ().getWindowHandle ();
258259 _test .waitForElement (btn );
259260 _test .waitAndClick (btn );
260261
@@ -270,25 +271,36 @@ public String clickAndGetExampleData()
270271 }
271272 }
272273
273- return getExampleData ();
274+ return getExampleData (currentWindow );
274275 }
275276
276277 public String getExampleData ()
278+ {
279+ return getExampleData (_test .getDriver ().getWindowHandle ());
280+ }
281+
282+ private String getExampleData (String currentWindow )
277283 {
278284 String ret = null ;
279285
280286 Set <String > handles = _test .getDriver ().getWindowHandles ();
281287 Assert .assertTrue ("Expected more than one open window, was: " + handles .size (), handles .size () > 1 );
282- String currentWindow = _test .getDriver ().getWindowHandle ();
283288 for (String handle : _test .getDriver ().getWindowHandles ())
284289 {
285290 if (!currentWindow .equals (handle ))
286291 {
287292 _test .getDriver ().switchTo ().window (handle );
288- String text = getPageText ();
293+ ret = StringUtils .trimToNull (getPageText ());
294+ if (ret == null )
295+ {
296+ // NOTE: this fails intermittently. Perhaps due to loading timing?
297+ BaseWebDriverTest .sleep (1000 );
298+ ret = StringUtils .trimToNull (getPageText ());
299+ }
300+ Assert .assertNotNull ("Unable to retrieve example data" , StringUtils .trimToNull (ret ));
301+
289302 _test .getDriver ().close ();
290303 _test .getDriver ().switchTo ().window (currentWindow );
291- ret = StringUtils .trimToNull (text );
292304 }
293305 }
294306
0 commit comments