Skip to content

Commit

Permalink
wait for the scritp console
Browse files Browse the repository at this point in the history
The script console is added by Javascript and not completely ready with
the page load.
Therefore we need to wait for the parts we want to manipulate to be
ready.

Fixes a flaky test observed when using master.runStript() with the following failure:

```
org.openqa.selenium.NoSuchElementException:
Unable to locate element: //*[@path='/script']

```
  • Loading branch information
jtnord committed Nov 4, 2020
1 parent 20bc092 commit baddcdf
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
package org.jenkinsci.test.acceptance.po;

import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.NoSuchElementException;

/**
* Encapsulate CodeMirror wizardry.
Expand All @@ -47,7 +48,8 @@ public void set(String content) {
}

// can't use find() because it wants a visible element
driver.findElement(by.xpath("//*[@path='%s']", getPath())); // wait until the element in question appears in DOM
// wait until the element in question appears in DOM as it is added by JavaScript
waitFor().ignoring(NoSuchElementException.class).until(() -> driver.findElement(by.xpath("//*[@path='%s']", getPath())));

executeScript(scriptSet, String.format("//*[@path='%s']/following-sibling::div", getPath()), content);
}
Expand Down

0 comments on commit baddcdf

Please # to comment.