|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xwiki.test.ui.TestUtils
public class TestUtils
Helper methods for testing, not related to a specific Page Object. Also made available to tests classes.
| Nested Class Summary | |
|---|---|
class |
TestUtils.Session
This class represents all cookies stored in the browser. |
| Field Summary | |
|---|---|
static org.apache.commons.httpclient.UsernamePasswordCredentials |
ADMIN_CREDENTIALS
|
static String |
BASE_BIN_URL
|
static String |
BASE_REST_URL
|
static String |
BASE_URL
|
static org.apache.commons.httpclient.UsernamePasswordCredentials |
SUPER_ADMIN_CREDENTIALS
|
| Constructor Summary | |
|---|---|
TestUtils()
|
|
| Method Summary | ||
|---|---|---|
ClassEditPage |
addClassProperty(String space,
String page,
String propertyName,
String propertyType)
|
|
void |
addObject(String space,
String page,
String className,
Map<String,?> properties)
|
|
void |
addObject(String space,
String page,
String className,
Object... properties)
|
|
void |
addQueryStringEntry(StringBuilder builder,
String key,
Object value)
|
|
void |
addQueryStringEntry(StringBuilder builder,
String key,
String value)
|
|
void |
assertOnPage(String pageURL)
After successful completion of this function, you are guaranteed to be logged in as the given user and on the page passed in pageURL. |
|
void |
attachFile(String space,
String page,
String name,
File file,
boolean failIfExists)
|
|
void |
attachFile(String space,
String page,
String name,
InputStream is,
boolean failIfExists)
|
|
void |
attachFile(String space,
String page,
String name,
InputStream is,
boolean failIfExists,
org.apache.commons.httpclient.UsernamePasswordCredentials credentials)
|
|
ViewPage |
createPage(String space,
String page,
String content,
String title)
|
|
ViewPage |
createPage(String space,
String page,
String content,
String title,
String syntaxId)
|
|
ViewPage |
createPage(String space,
String page,
String content,
String title,
String syntaxId,
String parentFullPageName)
|
|
ViewPage |
createPageWithAttachment(String space,
String page,
String content,
String title,
String attachmentName,
InputStream attachmentData)
|
|
ViewPage |
createPageWithAttachment(String space,
String page,
String content,
String title,
String attachmentName,
InputStream attachmentData,
org.apache.commons.httpclient.UsernamePasswordCredentials credentials)
|
|
ViewPage |
createPageWithAttachment(String space,
String page,
String content,
String title,
String syntaxId,
String parentFullPageName,
String attachmentName,
InputStream attachmentData)
|
|
ViewPage |
createPageWithAttachment(String space,
String page,
String content,
String title,
String syntaxId,
String parentFullPageName,
String attachmentName,
InputStream attachmentData,
org.apache.commons.httpclient.UsernamePasswordCredentials credentials)
|
|
void |
createUser(String username,
String password,
Object... properties)
|
|
void |
deleteObject(String space,
String page,
String className,
int objectNumber)
|
|
void |
deletePage(String space,
String page)
|
|
void |
deleteSpace(String space)
Accesses the URL to delete the specified space. |
|
ClassEditPage |
editClass(String space,
String page)
|
|
ObjectEditPage |
editObjects(String space,
String page)
|
|
String |
escapeURL(String s)
Encodes a given string so that it may be used as a URL component. |
|
protected org.apache.commons.httpclient.methods.GetMethod |
executeGet(String uri,
int expectedCode)
|
|
protected org.apache.commons.httpclient.methods.PutMethod |
executePut(String uri,
InputStream content,
String mediaType,
int... expectedCodes)
|
|
List<org.openqa.selenium.WebElement> |
findElementsWithoutWaiting(org.openqa.selenium.WebDriver driver,
org.openqa.selenium.By by)
|
|
List<org.openqa.selenium.WebElement> |
findElementsWithoutWaiting(org.openqa.selenium.WebDriver driver,
org.openqa.selenium.WebElement element,
org.openqa.selenium.By by)
|
|
org.openqa.selenium.WebElement |
findElementWithoutWaiting(org.openqa.selenium.WebDriver driver,
org.openqa.selenium.By by)
|
|
org.openqa.selenium.WebElement |
findElementWithoutWaiting(org.openqa.selenium.WebDriver driver,
org.openqa.selenium.WebElement element,
org.openqa.selenium.By by)
|
|
void |
forceGuestUser()
Forces the current user to be the Guest user by clearing all coookies. |
|
String |
getAttachmentURL(String space,
String page,
String attachment)
|
|
String |
getAttachmentURL(String space,
String page,
String attachment,
String action)
|
|
String |
getAttachmentURL(String space,
String page,
String attachment,
String action,
String queryString)
|
|
protected org.openqa.selenium.WebDriver |
getDriver()
|
|
String |
getLoggedInUserName()
|
|
String |
getMavenVersion()
|
|
byte[] |
getRESTBuffer(String resourceUri,
Map<String,Object[]> queryParams,
Object... elements)
|
|
InputStream |
getRESTInputStream(String resourceUri,
Map<String,Object[]> queryParams,
Object... elements)
|
|
|
getRESTResource(String resourceUri,
Map<String,Object[]> queryParams,
Object... elements)
|
|
String |
getSecretToken()
Get the secret token used for CSRF protection. |
|
TestUtils.Session |
getSession()
|
|
int |
getTimeout()
|
|
String |
getURL(String space,
String page)
Get the URL to view a page. |
|
String |
getURL(String space,
String page,
String action)
Get the URL of an action on a page. |
|
String |
getURL(String space,
String page,
String action,
Map<String,?> queryParameters)
Get the URL of an action on a page with specified parameters. |
|
String |
getURL(String space,
String page,
String action,
String queryString)
Get the URL of an action on a page with a specified query string. |
|
String |
getURLToDeletePage(String space,
String page)
|
|
String |
getURLToDeleteSpace(String space)
|
|
String |
getURLToLoginAndGotoPage(String username,
String password,
String pageURL)
|
|
String |
getURLToLoginAs(String username,
String password)
|
|
String |
getURLToLoginAsAdmin()
|
|
String |
getURLToLoginAsAdminAndGotoPage(String pageURL)
|
|
String |
getURLToLoginAsSuperAdmin()
|
|
String |
getURLToLoginAsSuperAdminAndGotoPage(String pageURL)
|
|
String |
getURLToLogout()
Consider using setSession(null) because it will drop the cookies which is faster than invoking a logout action. |
|
String |
getURLToNonExistentPage()
|
|
String |
getVersion()
|
|
ViewPage |
gotoPage(String space,
String page)
|
|
void |
gotoPage(String space,
String page,
String action)
|
|
void |
gotoPage(String space,
String page,
String action,
Map<String,?> queryParameters)
|
|
void |
gotoPage(String space,
String page,
String action,
Object... queryParameters)
|
|
void |
gotoPage(String space,
String page,
String action,
String queryString)
|
|
boolean |
hasElement(org.openqa.selenium.By by)
Should be used when the result is supposed to be true (otherwise you'll incur the timeout). |
|
boolean |
hasElement(org.openqa.selenium.WebElement element,
org.openqa.selenium.By by)
Should be used when the result is supposed to be true (otherwise you'll incur the timeout). |
|
void |
importXar(File file)
|
|
boolean |
isInClassEditMode()
|
|
boolean |
isInCreateMode()
|
|
boolean |
isInDeleteMode()
|
|
boolean |
isInInlineEditMode()
|
|
boolean |
isInObjectEditMode()
|
|
boolean |
isInRenameMode()
|
|
boolean |
isInRightsEditMode()
|
|
boolean |
isInViewMode()
|
|
boolean |
isInWikiEditMode()
|
|
boolean |
isInWYSIWYGEditMode()
|
|
boolean |
pageExists(String space,
String page)
|
|
void |
recacheSecretToken()
(Re)-cache the secret token used for CSRF protection. |
|
void |
registerLoginAndGotoPage(String username,
String password,
String pageURL)
Deprecated. starting with 5.0M2 use createUser(String, String, Object...) instead |
|
static void |
setContext(PersistentTestContext context)
Used so that AllTests can set the persistent test context. |
|
void |
setDriverImplicitWait(org.openqa.selenium.WebDriver driver)
Forces the passed driver to wait for a getTimeout() number of seconds when looking up page elements
before declaring that it cannot find them. |
|
void |
setSession(TestUtils.Session session)
|
|
void |
setTimeout(int timeout)
|
|
String |
toQueryParameterKey(String className,
Integer objectNumber,
String key)
|
|
Map<String,?> |
toQueryParameters(Object... properties)
|
|
Map<String,?> |
toQueryParameters(String className,
Integer objectNumber,
Map<String,?> properties)
|
|
Map<String,?> |
toQueryParameters(String className,
Integer objectNumber,
Object... properties)
|
|
String |
toQueryString(Map<String,?> queryParameters)
|
|
String |
toQueryString(Object... queryParameters)
|
|
void |
updateObject(String space,
String page,
String className,
int objectNumber,
Map<String,?> properties)
|
|
void |
updateObject(String space,
String page,
String className,
int objectNumber,
Object... properties)
|
|
|
waitUntilCondition(org.openqa.selenium.support.ui.ExpectedCondition<T> condition)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final org.apache.commons.httpclient.UsernamePasswordCredentials ADMIN_CREDENTIALS
public static final org.apache.commons.httpclient.UsernamePasswordCredentials SUPER_ADMIN_CREDENTIALS
public static final String BASE_URL
public static final String BASE_BIN_URL
public static final String BASE_REST_URL
| Constructor Detail |
|---|
public TestUtils()
| Method Detail |
|---|
public static void setContext(PersistentTestContext context)
protected org.openqa.selenium.WebDriver getDriver()
public TestUtils.Session getSession()
public void setSession(TestUtils.Session session)
public String getURLToLogout()
public String getURLToLoginAsAdmin()
public String getURLToLoginAsSuperAdmin()
public String getURLToLoginAs(String username,
String password)
public String getURLToLoginAsAdminAndGotoPage(String pageURL)
pageURL - the URL of the page to go to after logging in.
public String getURLToLoginAsSuperAdminAndGotoPage(String pageURL)
pageURL - the URL of the page to go to after logging in.
public String getURLToLoginAndGotoPage(String username,
String password,
String pageURL)
username - the name of the user to log in as.password - the password for the user to log in.pageURL - the URL of the page to go to after logging in.
public String getURLToNonExistentPage()
public void assertOnPage(String pageURL)
pageURL - public <T> void waitUntilCondition(org.openqa.selenium.support.ui.ExpectedCondition<T> condition)
public String getLoggedInUserName()
public void createUser(String username,
String password,
Object... properties)
@Deprecated
public void registerLoginAndGotoPage(String username,
String password,
String pageURL)
createUser(String, String, Object...) instead
public ViewPage gotoPage(String space,
String page)
public void gotoPage(String space,
String page,
String action)
public void gotoPage(String space,
String page,
String action,
Object... queryParameters)
public void gotoPage(String space,
String page,
String action,
Map<String,?> queryParameters)
public void gotoPage(String space,
String page,
String action,
String queryString)
public String getURLToDeletePage(String space,
String page)
public String getURLToDeleteSpace(String space)
space - the name of the space to delete
public ViewPage createPage(String space,
String page,
String content,
String title)
public ViewPage createPage(String space,
String page,
String content,
String title,
String syntaxId)
public ViewPage createPage(String space,
String page,
String content,
String title,
String syntaxId,
String parentFullPageName)
public ViewPage createPageWithAttachment(String space,
String page,
String content,
String title,
String syntaxId,
String parentFullPageName,
String attachmentName,
InputStream attachmentData)
throws Exception
Exception
public ViewPage createPageWithAttachment(String space,
String page,
String content,
String title,
String syntaxId,
String parentFullPageName,
String attachmentName,
InputStream attachmentData,
org.apache.commons.httpclient.UsernamePasswordCredentials credentials)
throws Exception
Exception
public ViewPage createPageWithAttachment(String space,
String page,
String content,
String title,
String attachmentName,
InputStream attachmentData)
throws Exception
Exception
public ViewPage createPageWithAttachment(String space,
String page,
String content,
String title,
String attachmentName,
InputStream attachmentData,
org.apache.commons.httpclient.UsernamePasswordCredentials credentials)
throws Exception
Exception
public void deletePage(String space,
String page)
public void deleteSpace(String space)
space - the name of the space to delete
public boolean pageExists(String space,
String page)
public String getURL(String space,
String page)
space - the space in which the page resides.page - the name of the page.
public String getURL(String space,
String page,
String action)
space - the space in which the page resides.page - the name of the page.action - the action to do on the page.
public String getURL(String space,
String page,
String action,
String queryString)
space - the space in which the page resides.page - the name of the page.action - the action to do on the page.queryString - the query string to pass in the URL.
public String getURL(String space,
String page,
String action,
Map<String,?> queryParameters)
space - the space in which the page resides.page - the name of the page.action - the action to do on the page.queryParameters - the parameters to pass in the URL, these will be automatically URL encoded.
public String getAttachmentURL(String space,
String page,
String attachment,
String action,
String queryString)
space - the name of the space that contains the page with the specified attachmentpage - the name of the page that holds the attachmentattachment - the attachment nameaction - the action to perform on the attachmentqueryString - the URL query string
public String getAttachmentURL(String space,
String page,
String attachment,
String action)
space - the name of the space that contains the page with the specified attachmentpage - the name of the page that holds the attachmentattachment - the attachment nameaction - the action to perform on the attachment
public String getAttachmentURL(String space,
String page,
String attachment)
space - the name of the space that contains the page with the specified attachmentpage - the name of the page that holds the attachmentattachment - the attachment name
public void recacheSecretToken()
getSecretToken() is called and after each re-login.
getSecretToken()public String getSecretToken()
recacheSecretToken() first.
recacheSecretToken()public String escapeURL(String s)
s - public int getTimeout()
public void setTimeout(int timeout)
timeout - the number of seconds after which we consider the action to have failedpublic void setDriverImplicitWait(org.openqa.selenium.WebDriver driver)
getTimeout() number of seconds when looking up page elements
before declaring that it cannot find them.
public boolean isInWYSIWYGEditMode()
public boolean isInWikiEditMode()
public boolean isInViewMode()
public boolean isInInlineEditMode()
public boolean isInRightsEditMode()
public boolean isInObjectEditMode()
public boolean isInClassEditMode()
public boolean isInDeleteMode()
public boolean isInRenameMode()
public boolean isInCreateMode()
public void forceGuestUser()
public void addObject(String space,
String page,
String className,
Object... properties)
public void addObject(String space,
String page,
String className,
Map<String,?> properties)
public void deleteObject(String space,
String page,
String className,
int objectNumber)
public void updateObject(String space,
String page,
String className,
int objectNumber,
Map<String,?> properties)
public void updateObject(String space,
String page,
String className,
int objectNumber,
Object... properties)
public ClassEditPage addClassProperty(String space,
String page,
String propertyName,
String propertyType)
public String toQueryString(Object... queryParameters)
public String toQueryString(Map<String,?> queryParameters)
public void addQueryStringEntry(StringBuilder builder,
String key,
Object value)
public void addQueryStringEntry(StringBuilder builder,
String key,
String value)
public Map<String,?> toQueryParameters(Object... properties)
public Map<String,?> toQueryParameters(String className,
Integer objectNumber,
Object... properties)
public Map<String,?> toQueryParameters(String className,
Integer objectNumber,
Map<String,?> properties)
public String toQueryParameterKey(String className,
Integer objectNumber,
String key)
public org.openqa.selenium.WebElement findElementWithoutWaiting(org.openqa.selenium.WebDriver driver,
org.openqa.selenium.By by)
public List<org.openqa.selenium.WebElement> findElementsWithoutWaiting(org.openqa.selenium.WebDriver driver,
org.openqa.selenium.By by)
public org.openqa.selenium.WebElement findElementWithoutWaiting(org.openqa.selenium.WebDriver driver,
org.openqa.selenium.WebElement element,
org.openqa.selenium.By by)
public List<org.openqa.selenium.WebElement> findElementsWithoutWaiting(org.openqa.selenium.WebDriver driver,
org.openqa.selenium.WebElement element,
org.openqa.selenium.By by)
public boolean hasElement(org.openqa.selenium.By by)
public boolean hasElement(org.openqa.selenium.WebElement element,
org.openqa.selenium.By by)
public ObjectEditPage editObjects(String space,
String page)
public ClassEditPage editClass(String space,
String page)
public String getVersion()
throws Exception
Exception
public String getMavenVersion()
throws Exception
Exception
public void attachFile(String space,
String page,
String name,
File file,
boolean failIfExists)
throws Exception
Exception
public void attachFile(String space,
String page,
String name,
InputStream is,
boolean failIfExists,
org.apache.commons.httpclient.UsernamePasswordCredentials credentials)
throws Exception
Exception
public void attachFile(String space,
String page,
String name,
InputStream is,
boolean failIfExists)
throws Exception
Exception
public void importXar(File file)
throws Exception
Exception
public InputStream getRESTInputStream(String resourceUri,
Map<String,Object[]> queryParams,
Object... elements)
throws Exception
Exception
public byte[] getRESTBuffer(String resourceUri,
Map<String,Object[]> queryParams,
Object... elements)
throws Exception
Exception
public <T> T getRESTResource(String resourceUri,
Map<String,Object[]> queryParams,
Object... elements)
throws Exception
Exception
protected org.apache.commons.httpclient.methods.GetMethod executeGet(String uri,
int expectedCode)
throws Exception
Exception
protected org.apache.commons.httpclient.methods.PutMethod executePut(String uri,
InputStream content,
String mediaType,
int... expectedCodes)
throws Exception
Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||