Created
March 13, 2012 09:15
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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