Skip to content

Instantly share code, notes, and snippets.

@vmassol
Created March 13, 2012 09:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vmassol/2027780 to your computer and use it in GitHub Desktop.
Save vmassol/2027780 to your computer and use it in GitHub Desktop.
Add ability to execute server side code from a client side UI test
To be added to TestUtil:
/**
* Sometimes it's useful to execute some script on the server to get information back to the client side. We do
* this by using the preview action on a temporary wiki page, passing the specified content.
*
* @param content the content to execute in a page
* @return the result of the page execution with the page rendered in plain mode
*/
public String executeContent(String content)
{
try {
gotoPage("temporary", "temporary", "preview", "xpage=plain&outputSyntax=plain&content="
+ URLEncoder.encode(content, "UTF-8"));
} catch (UnsupportedEncodingException e) {
// That should not happen since UTF8 encoding should always be present!
throw new RuntimeException(String.format("Failed to execute content [%s]", content), e);
}
return getDriver().findElement(By.tagName("body")).getText();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment