Class TestUtils


  • public class TestUtils
    extends Object
    Helper methods for testing, not related to a specific Page Object. Also made available to tests classes.
    Since:
    3.2M3
    Version:
    $Id: 0b7a1dd4faeb80b8a9282c1780bc0f6ec1ea9c13 $
    • Field Detail

      • ADMIN_CREDENTIALS

        public static final org.apache.commons.httpclient.UsernamePasswordCredentials ADMIN_CREDENTIALS
        Since:
        5.0M2
      • SUPER_ADMIN_CREDENTIALS

        public static final org.apache.commons.httpclient.UsernamePasswordCredentials SUPER_ADMIN_CREDENTIALS
        Since:
        5.1M1
      • STATUS_OK_NOT_FOUND

        public static final int[] STATUS_OK_NOT_FOUND
        Since:
        7.3M1
      • STATUS_OK

        public static final int[] STATUS_OK
        Since:
        7.3M1
      • STATUS_NO_CONTENT

        public static final int[] STATUS_NO_CONTENT
        Since:
        7.3M1
      • STATUS_NO_CONTENT_NOT_FOUND

        public static final int[] STATUS_NO_CONTENT_NOT_FOUND
        Since:
        8.3RC1
      • STATUS_CREATED_ACCEPTED

        public static final int[] STATUS_CREATED_ACCEPTED
        Since:
        7.3M1
      • STATUS_CREATED

        public static final int[] STATUS_CREATED
        Since:
        7.3M1
      • STATUS_ACCEPTED

        public static final int[] STATUS_ACCEPTED
        Since:
        9.5RC1
    • Constructor Detail

      • TestUtils

        public TestUtils()
    • Method Detail

      • getCurrentExecutor

        public XWikiExecutor getCurrentExecutor()
        Since:
        8.0M1
      • switchExecutor

        public void switchExecutor​(int index)
        Since:
        8.0M1
      • setExecutors

        public void setExecutors​(List<XWikiExecutor> executors)
        Since:
        8.0M1
      • setContext

        public static void setContext​(PersistentTestContext context)
        Used so that AllTests can set the persistent test context.
      • initializeComponent

        public static void initializeComponent​(org.xwiki.component.manager.ComponentManager componentManager)
                                        throws Exception
        Throws:
        Exception
      • getWCAGUtils

        public WCAGUtils getWCAGUtils()
        Returns:
        the utils concerning wcag.
        Since:
        15.2RC1
      • setDefaultCredentials

        public void setDefaultCredentials​(String username,
                                          String password)
        Since:
        7.0RC1
      • setDefaultCredentials

        public org.apache.commons.httpclient.UsernamePasswordCredentials setDefaultCredentials​(org.apache.commons.httpclient.UsernamePasswordCredentials defaultCredentials)
        Since:
        7.0RC1
      • getDefaultCredentials

        public org.apache.commons.httpclient.UsernamePasswordCredentials getDefaultCredentials()
      • loginAsSuperAdmin

        public void loginAsSuperAdmin()
      • loginAsSuperAdminAndGotoPage

        public void loginAsSuperAdminAndGotoPage​(String pageURL)
      • loginAsAdmin

        public void loginAsAdmin()
      • loginAsAdminAndGotoPage

        public void loginAsAdminAndGotoPage​(String pageURL)
      • login

        public void login​(String username,
                          String password)
      • loginAndGotoPage

        public void loginAndGotoPage​(String username,
                                     String password,
                                     String pageURL)
      • loginAndGotoPage

        public void loginAndGotoPage​(String username,
                                     String password,
                                     String pageURL,
                                     boolean checkLoginSuccess)
        Since:
        11.6RC1
      • getURLToLogout

        public String getURLToLogout()
        Consider using setSession(null) because it will drop the cookies which is faster than invoking a logout action.
      • getURLToLoginAsAdmin

        public String getURLToLoginAsAdmin()
      • getURLToLoginAsSuperAdmin

        public String getURLToLoginAsSuperAdmin()
      • getURLToLoginAsAdminAndGotoPage

        public String getURLToLoginAsAdminAndGotoPage​(String pageURL)
        Parameters:
        pageURL - the URL of the page to go to after logging in.
        Returns:
        URL to accomplish login and goto.
      • getURLToLoginAsSuperAdminAndGotoPage

        public String getURLToLoginAsSuperAdminAndGotoPage​(String pageURL)
        Parameters:
        pageURL - the URL of the page to go to after logging in.
        Returns:
        URL to accomplish login and goto.
      • getURLToLoginAndGotoPage

        public String getURLToLoginAndGotoPage​(String username,
                                               String password,
                                               String pageURL)
        Parameters:
        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.
        Returns:
        URL to accomplish login and goto.
      • getURLToNonExistentPage

        public String getURLToNonExistentPage()
        Returns:
        URL to a non existent page that loads very fast (we are using plain mode so that we don't even have to display the skin ;))
      • assertOnPage

        public 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.
      • getLoggedInUserName

        public String getLoggedInUserName()
      • createUserAndLogin

        public void createUserAndLogin​(String username,
                                       String password,
                                       Object... properties)
      • createUserAndLoginWithRedirect

        public void createUserAndLoginWithRedirect​(String username,
                                                   String password,
                                                   String url,
                                                   Object... properties)
      • createUser

        public void createUser​(String username,
                               String password,
                               String redirectURL,
                               Object... properties)
      • createAdminUser

        public void createAdminUser()
        Creates the Admin user, add it to the XWikiAdminGroup and login. Note that this method requires to be superadmin to be effective.
        Since:
        12.2
      • createAdminUser

        public void createAdminUser​(boolean programming)
        Creates the Admin user, add it to the XWikiAdminGroup and login. Note that this method requires to be superadmin to be effective.
        Parameters:
        programming - true of the user should also be given programming right
        Since:
        15.1RC1, 14.10.5
      • setGlobalRights

        public void setGlobalRights​(String groups,
                                    String users,
                                    String rights,
                                    boolean enabled)
        Add or update a XWikiGlobalRights xobject to the current wiki's XWikiPreferences document.
        Parameters:
        groups - the comma-separated list of groups that will have the rights (e.g. XWiki.XWikiAdminGroup. Can be empty or null
        users - the comma-separated list of users that will have the rights (e.g. XWiki.Admin. Can be empty of null
        rights - the comma-separated list of rights to give (e.g. edit,admin)
        enabled - true if the rights should be allowed, false if they should be disabled
        Since:
        12.2
      • setRights

        public void setRights​(org.xwiki.model.reference.EntityReference entityReference,
                              String groups,
                              String users,
                              String rights,
                              boolean enabled)
        Add or update a XWikiRights xobject to the document specified in the passed entity reference.
        Parameters:
        entityReference - the reference to the document for which to set rights for
        groups - the comma-separated list of groups that will have the rights (e.g. XWiki.XWikiAdminGroup. Can be empty or null
        users - the comma-separated list of users that will have the rights (e.g. XWiki.Admin. Can be empty of null
        rights - the comma-separated list of rights to give (e.g. edit,admin)
        enabled - true if the rights should be allowed, false if they should be denied
        Since:
        12.2
      • setRightsOnSpace

        public void setRightsOnSpace​(org.xwiki.model.reference.SpaceReference space,
                                     String groups,
                                     String users,
                                     String rights,
                                     boolean enabled)
        Add or update a XWikiRights xobject to the specified space reference.
        Parameters:
        space - the reference to the space for which to set rights for
        groups - the comma-separated list of groups that will have the rights (e.g. XWiki.XWikiAdminGroup. Can be empty or null
        users - the comma-separated list of users that will have the rights (e.g. XWiki.Admin. Can be empty of null
        rights - the comma-separated list of rights to give (e.g. edit,admin)
        enabled - true if the rights should be allowed, false if they should be denied
        Since:
        14.10
      • gotoPage

        public ViewPage gotoPage​(org.xwiki.model.reference.EntityReference reference)
        Since:
        7.2M2
      • gotoPage

        public void gotoPage​(org.xwiki.model.reference.EntityReference reference,
                             String action)
        Since:
        7.2M2
      • gotoPage

        public void gotoPage​(String space,
                             String page,
                             String action,
                             Object... queryParameters)
        Since:
        3.5M1
      • gotoPage

        public void gotoPage​(org.xwiki.model.reference.EntityReference reference,
                             String action,
                             Object... queryParameters)
        Since:
        11.3RC1
      • gotoPage

        public void gotoPage​(org.xwiki.model.reference.EntityReference reference,
                             String action,
                             Map<String,​?> queryParameters)
        Since:
        7.2M2
      • gotoPage

        public void gotoPage​(org.xwiki.model.reference.EntityReference reference,
                             String action,
                             String queryString)
        Since:
        7.2M2
      • gotoPage

        public void gotoPage​(org.xwiki.model.reference.EntityReference reference,
                             String action,
                             String queryString,
                             String fragment)
        Since:
        10.9
      • gotoPage

        public void gotoPage​(String url)
      • getURLToDeletePage

        public String getURLToDeletePage​(org.xwiki.model.reference.EntityReference reference)
        Since:
        7.2M2
      • getURLToDeletePage

        public String getURLToDeletePage​(org.xwiki.model.reference.EntityReference reference,
                                         boolean affectChildren)
        Since:
        12.9RC1
      • getURLToDeleteSpace

        public String getURLToDeleteSpace​(String space)
        Parameters:
        space - the name of the space to delete
        Returns:
        the URL that can be used to delete the specified pace
        Since:
        4.5
      • getURLToDeleteSpace

        public String getURLToDeleteSpace​(org.xwiki.model.reference.EntityReference space)
        Parameters:
        space - the reference of the space to delete
        Returns:
        the URL that can be used to delete the specified pace
        Since:
        14.1RC1
      • createPage

        public ViewPage createPage​(org.xwiki.model.reference.EntityReference reference,
                                   String content)
        Since:
        11.5RC1, 11.3.1
      • createPage

        public ViewPage createPage​(org.xwiki.model.reference.EntityReference reference,
                                   String content,
                                   String title)
        Since:
        7.2M2
      • createPage

        public ViewPage createPage​(org.xwiki.model.reference.EntityReference reference,
                                   String content,
                                   String title,
                                   String syntaxId)
        Since:
        7.2M2
      • createPage

        public ViewPage createPage​(org.xwiki.model.reference.EntityReference reference,
                                   String content,
                                   String title,
                                   String syntaxId,
                                   String parentFullPageName)
        Since:
        7.2M2
      • createPageWithAttachment

        public ViewPage createPageWithAttachment​(org.xwiki.model.reference.EntityReference reference,
                                                 String content,
                                                 String title,
                                                 String attachmentName,
                                                 InputStream attachmentData,
                                                 org.apache.commons.httpclient.UsernamePasswordCredentials credentials)
                                          throws Exception
        Throws:
        Exception
        Since:
        12.2
      • deletePage

        public void deletePage​(String space,
                               String page)
      • deletePage

        public void deletePage​(org.xwiki.model.reference.EntityReference reference)
        Since:
        7.2M2
      • deletePage

        public void deletePage​(org.xwiki.model.reference.EntityReference reference,
                               boolean affectChildren)
        Since:
        12.9RC1
      • resolveDocumentReference

        public org.xwiki.model.reference.EntityReference resolveDocumentReference​(String referenceAsString)
        Since:
        7.2M2
      • resolveSpaceReference

        public org.xwiki.model.reference.EntityReference resolveSpaceReference​(String referenceAsString)
        Since:
        7.2M3
      • serializeReference

        public String serializeReference​(org.xwiki.model.reference.EntityReference reference)
        Since:
        7.2RC1
      • deleteSpace

        public void deleteSpace​(String space)
        Accesses the URL to delete the specified space.
        Parameters:
        space - the name of the space to delete
        Since:
        4.5
      • deleteSpace

        public void deleteSpace​(org.xwiki.model.reference.EntityReference space)
        Accesses the URL to delete the specified space.
        Parameters:
        space - the reference of the space to delete
        Since:
        14.1RC1
      • getURL

        public String getURL​(String space,
                             String page)
        Get the URL to view a page.
        Parameters:
        space - the space in which the page resides.
        page - the name of the page.
      • getURL

        public String getURL​(String space,
                             String page,
                             String action)
        Get the URL of an action on a page.
        Parameters:
        space - the space in which the page resides.
        page - the name of the page.
        action - the action to do on the page.
      • getURL

        public String getURL​(String space,
                             String page,
                             String action,
                             String queryString)
        Get the URL of an action on a page with a specified query string.
        Parameters:
        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.
      • getURL

        public String getURL​(org.xwiki.model.reference.EntityReference reference)
        Since:
        12.2
      • getURL

        public String getURL​(org.xwiki.model.reference.EntityReference reference,
                             String action,
                             String queryString)
        Since:
        7.2M2
      • getURL

        public String getURL​(org.xwiki.model.reference.EntityReference reference,
                             String action,
                             String queryString,
                             String fragment)
        Since:
        10.9
      • executeAndGetBodyAsString

        public String executeAndGetBodyAsString​(org.xwiki.model.reference.EntityReference reference,
                                                Map<String,​?> queryParameters)
                                         throws Exception
        Throws:
        Exception
        Since:
        9.7RC1
      • executeWiki

        public String executeWiki​(String wikiContent,
                                  org.xwiki.rendering.syntax.Syntax wikiSyntax)
                           throws Exception
        Throws:
        Exception
        Since:
        15.1RC1, 14.10.5
      • executeWikiPlain

        public String executeWikiPlain​(String wikiContent,
                                       org.xwiki.rendering.syntax.Syntax wikiSyntax)
                                throws Exception
        Throws:
        Exception
        Since:
        16.4.0RC1, 15.10.11, 14.10.22
      • getURLFragment

        public String getURLFragment​(org.xwiki.model.reference.EntityReference reference)
        Since:
        7.2M2
      • getCurrentWiki

        public String getCurrentWiki()
        Since:
        7.3M1
      • setCurrentWiki

        public void setCurrentWiki​(String currentWiki)
        Since:
        14.5
      • getBaseURL

        public String getBaseURL()
        Since:
        7.3M1
      • setURLPrefix

        public static void setURLPrefix​(String urlPrefix)
        Since:
        10.6RC1
      • getBaseBinURL

        public String getBaseBinURL()
        Since:
        7.3M1
      • getBaseBinURL

        public String getBaseBinURL​(String wiki)
        Since:
        11.2RC1
      • getURL

        public String getURL​(String space,
                             String page,
                             String action,
                             Map<String,​?> queryParameters)
        Get the URL of an action on a page with specified parameters. If you need to pass multiple parameters with the same key, this function will not work.
        Parameters:
        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.
      • getAttachmentURL

        public String getAttachmentURL​(String space,
                                       String page,
                                       String attachment,
                                       String action,
                                       String queryString)
        Parameters:
        space - the name of the space that contains the page with the specified attachment
        page - the name of the page that holds the attachment
        attachment - the attachment name
        action - the action to perform on the attachment
        queryString - the URL query string
        Returns:
        the URL that performs the specified action on the specified attachment
      • getAttachmentURL

        public String getAttachmentURL​(String space,
                                       String page,
                                       String attachment,
                                       String action)
        Parameters:
        space - the name of the space that contains the page with the specified attachment
        page - the name of the page that holds the attachment
        attachment - the attachment name
        action - the action to perform on the attachment
        Returns:
        the URL that performs the specified action on the specified attachment
      • getAttachmentURL

        public String getAttachmentURL​(String space,
                                       String page,
                                       String attachment)
        Parameters:
        space - the name of the space that contains the page with the specified attachment
        page - the name of the page that holds the attachment
        attachment - the attachment name
        Returns:
        the URL to download the specified attachment
      • recacheSecretToken

        public void recacheSecretToken()
        (Re)-cache the secret token used for CSRF protection. A user with edit rights on Main.WebHome must be logged in. This method must be called before getSecretToken() is called and after each re-login.
        See Also:
        getSecretToken()
      • getSecretToken

        public String getSecretToken()
        Get the secret token used for CSRF protection. Remember to call recacheSecretToken() first.
        Returns:
        anti-CSRF secret token, or empty string if the token was not cached
        See Also:
        recacheSecretToken()
      • setSecretToken

        public void setSecretToken​(String secretToken)
        Sets the secret token used for CSRF protection. Use this method to restore a token that was previously saved. If you want to cache the current token you should use recacheSecretToken() instead.
        Parameters:
        secretToken - the new secret token to use
        Since:
        15.10.12, 16.4.1, 16.6.0RC1
      • isInWYSIWYGEditMode

        public boolean isInWYSIWYGEditMode()
      • isInWikiEditMode

        public boolean isInWikiEditMode()
      • isInViewMode

        public boolean isInViewMode()
      • isInSourceViewMode

        public boolean isInSourceViewMode()
      • isInInlineEditMode

        public boolean isInInlineEditMode()
      • isInRightsEditMode

        public boolean isInRightsEditMode()
      • isInObjectEditMode

        public boolean isInObjectEditMode()
      • isInClassEditMode

        public boolean isInClassEditMode()
      • isInDeleteMode

        public boolean isInDeleteMode()
      • isInRenameMode

        public boolean isInRenameMode()
      • isInCreateMode

        public boolean isInCreateMode()
      • isInAdminMode

        public boolean isInAdminMode()
      • assertOnPage

        public void assertOnPage​(org.xwiki.model.reference.EntityReference reference)
        Verify if the passed reference corresponds to the current page, independently of the wiki. Throws an AssertionFailedError if it's not the case.
        Parameters:
        reference - the reference to the document to check
        Since:
        12.2
      • forceGuestUser

        public void forceGuestUser()
        Forces the current user to be the Guest user by clearing all coookies.
      • addObject

        public void addObject​(org.xwiki.model.reference.EntityReference reference,
                              String className,
                              Object... properties)
        Since:
        7.2RC1
      • addObject

        public void addObject​(org.xwiki.model.reference.EntityReference reference,
                              String className,
                              Map<String,​?> properties)
        Since:
        7.3M2
      • updateObject

        public void updateObject​(String space,
                                 String page,
                                 String className,
                                 int objectNumber,
                                 Map<String,​?> properties)
      • updateObject

        public void updateObject​(String space,
                                 String page,
                                 String className,
                                 int objectNumber,
                                 Object... properties)
      • updateObject

        public void updateObject​(org.xwiki.model.reference.EntityReference entityReference,
                                 String className,
                                 int objectNumber,
                                 Object... properties)
        Since:
        11.5RC1, 11.3.1
      • updateObject

        public void updateObject​(List<String> spaces,
                                 String page,
                                 String className,
                                 int objectNumber,
                                 Object... properties)
        Since:
        8.3RC1
      • addClassProperty

        public void addClassProperty​(org.xwiki.model.reference.EntityReference reference,
                                     String propertyName,
                                     String propertyType)
        Since:
        11.3RC1
      • updateClassProperty

        public void updateClassProperty​(org.xwiki.model.reference.EntityReference reference,
                                        Object... queryParameters)
        Since:
        11.3RC1
      • addClassProperty

        public void addClassProperty​(String space,
                                     String page,
                                     String propertyName,
                                     String propertyType)
      • toQueryString

        public String toQueryString​(Object... queryParameters)
        Since:
        3.5M1
      • toQueryString

        public String toQueryString​(Map<String,​?> queryParameters)
        Since:
        3.5M1
      • toQueryParameters

        public Map<String,​?> toQueryParameters​(Object... properties)
        Since:
        3.5M1
      • editClass

        public ClassEditPage editClass​(org.xwiki.model.reference.DocumentReference reference)
        Goes to a page in edit class mode.
        Parameters:
        reference - a document reference
        Returns:
        the ClassEditPage Page Object for the page
        Since:
        14.0RC1
      • attachFile

        public void attachFile​(String space,
                               String page,
                               String name,
                               InputStream is,
                               boolean failIfExists,
                               org.apache.commons.httpclient.UsernamePasswordCredentials credentials)
                        throws Exception
        Throws:
        Exception
        Since:
        5.1M2
      • attachFile

        public void attachFile​(org.xwiki.model.reference.EntityReference pageReference,
                               String name,
                               InputStream is,
                               boolean failIfExists)
                        throws Exception
        Throws:
        Exception
        Since:
        7.3M1
      • attachFile

        public void attachFile​(org.xwiki.model.reference.EntityReference reference,
                               Object is,
                               boolean failIfExists)
                        throws Exception
        Throws:
        Exception
        Since:
        7.3M1
      • attachFile

        public void attachFile​(org.xwiki.model.reference.EntityReference pageReference,
                               String name,
                               InputStream is,
                               boolean failIfExists,
                               org.apache.commons.httpclient.UsernamePasswordCredentials credentials)
                        throws Exception
        Throws:
        Exception
        Since:
        12.2
      • deleteAttachement

        public void deleteAttachement​(org.xwiki.model.reference.EntityReference pageReference,
                                      String filename)
                               throws Exception
        Throws:
        Exception
      • deleteAttachement

        public void deleteAttachement​(org.xwiki.model.reference.EntityReference reference)
                               throws Exception
        Throws:
        Exception
      • deleteLatestVersion

        public void deleteLatestVersion​(String space,
                                        String page)
        Delete the latest version from the history of a page, using the /deleteversions/ action.
        Parameters:
        space - the space name of the page
        page - the name of the page
        Since:
        7.0M2
      • deleteVersion

        public void deleteVersion​(String space,
                                  String page,
                                  String version)
        Delete a specific version from the history of a page, using the /deleteversions/ action.
        Parameters:
        space - the space name of the page
        page - the name of the page
        version - the version to delete
        Since:
        7.0M2
      • deleteVersions

        public void deleteVersions​(String space,
                                   String page,
                                   String v1,
                                   String v2)
        Delete an interval of versions from the history of a page, using the /deleteversions/ action.
        Parameters:
        space - the space name of the page
        page - the name of the page
        v1 - the starting version to delete
        v2 - the ending version to delete
        Since:
        7.0M2
      • rollbackToPreviousVersion

        public void rollbackToPreviousVersion​(String space,
                                              String page)
        Roll back a page to the previous version, using the /rollback/ action.
        Parameters:
        space - the space name of the page
        page - the name of the page
        Since:
        7.0M2
      • rollBackTo

        public void rollBackTo​(String space,
                               String page,
                               String version)
        Roll back a page to the specified version, using the /rollback/ action.
        Parameters:
        space - the space name of the page
        page - the name of the page
        version - the version to rollback to
        Since:
        7.0M2
      • setHierarchyMode

        public void setHierarchyMode​(String mode)
        Set the hierarchy mode used in the wiki
        Parameters:
        mode - the mode to use ("reference" or "parentchild")
        Since:
        7.2M2
      • setPropertyInXWikiPreferences

        public void setPropertyInXWikiPreferences​(String propertyName,
                                                  String propertyType,
                                                  Object value)
        Add and set a property into XWiki.XWikiPreferences. Create XWiki.XWikiPreferences if it does not exist.
        Parameters:
        propertyName - name of the property to set
        propertyType - the type of the property to add
        value - value to set to the property
        Since:
        7.2M2
      • setPropertyInXWikiCfg

        public void setPropertyInXWikiCfg​(String configuration)
                                   throws IOException
        Set global xwiki configuration options (as if the xwiki.cfg file had been modified). This is useful for testing configuration options. This requires the Test.XWikiConfigurationPageForTest page to have Programming Rights (if the PR checker is enabled, you'll need to exclude this reference so that it can have PR).
        Parameters:
        configuration - the configuration in Properties format. For example "param1=value2\nparam2=value2"
        Throws:
        IOException - if an error occurs while parsing the configuration
      • setWikiPreference

        public String setWikiPreference​(String propertyName,
                                        String value)
                                 throws Exception
        Sets the value of an existing property of XWiki.XWikiPreferences.
        Parameters:
        propertyName - name of the property to set
        value - value to set to the property
        Returns:
        the previous value, if the property was set, null otherwise
        Throws:
        Exception
        Since:
        9.7RC1
      • assertStatuses

        public static void assertStatuses​(int actualCode,
                                          int... expectedCodes)
        Since:
        7.3M1
      • assertStatusCodes

        public static <M extends org.apache.commons.httpclient.HttpMethod> M assertStatusCodes​(M method,
                                                                                               boolean release,
                                                                                               int... expectedCodes)
                                                                                        throws Exception
        Throws:
        Exception
        Since:
        7.3M1
      • escapeURL

        public String escapeURL​(String url)
        Encodes a given string so that it may be used as a URL component. Compatible with javascript decodeURIComponent, though more strict than encodeURIComponent: all characters except [a-zA-Z0-9], '.', '-', '*', '_' are encoded. Uses the same algorithm than the one used to generate URLs as otherwise tests won't find the proper matches... See XWikiServletURLFactory#encodeWithinPath() and #encodeWithinQuery().
        Parameters:
        url - the url to encode
      • escapeXPath

        public String escapeXPath​(String value)
        Usage example:
         
         By.xpath("//a[. = " + escapeXPath(value) + "]")
         
         
        Parameters:
        value - the value to escape
        Returns:
        the escaped value
      • getString

        public String getString​(String baseURL,
                                String path,
                                Map<String,​?> queryParams)
                         throws Exception
        Extended version to work in a docker context.
        Parameters:
        baseURL - the base url
        path - an additional path added after the base url
        queryParams - additional query parameter added to the computed url
        Returns:
        the context of the computed url
        Throws:
        Exception - in case of error when executing the request
      • executeGet

        protected org.apache.commons.httpclient.methods.GetMethod executeGet​(String uri)
                                                                      throws Exception
        Throws:
        Exception
      • executeGet

        protected org.apache.commons.httpclient.methods.GetMethod executeGet​(String uri,
                                                                             int... expectedCodes)
                                                                      throws Exception
        Throws:
        Exception
      • executeGet

        protected org.apache.commons.httpclient.methods.GetMethod executeGet​(String uri,
                                                                             boolean release,
                                                                             int... expectedCodes)
                                                                      throws Exception
        Throws:
        Exception
        Since:
        7.3M1
      • executePost

        protected org.apache.commons.httpclient.methods.PostMethod executePost​(String uri,
                                                                               InputStream content,
                                                                               String mediaType,
                                                                               boolean release,
                                                                               int... expectedCodes)
                                                                        throws Exception
        Throws:
        Exception
        Since:
        7.3M1
      • executeDelete

        protected org.apache.commons.httpclient.methods.DeleteMethod executeDelete​(String uri)
                                                                            throws Exception
        Throws:
        Exception
        Since:
        7.3M1
      • executeDelete

        protected void executeDelete​(String uri,
                                     int... expectedCodes)
                              throws Exception
        Throws:
        Exception
        Since:
        7.3M1
      • executePut

        protected org.apache.commons.httpclient.methods.PutMethod executePut​(String uri,
                                                                             InputStream content,
                                                                             String mediaType,
                                                                             boolean release,
                                                                             int... expectedCodes)
                                                                      throws Exception
        Throws:
        Exception
      • disableSyntaxHighlighting

        public void disableSyntaxHighlighting()
                                       throws Exception
        Disable Syntax Highlighting.
        Throws:
        Exception
        Since:
        9.7RC1
      • switchTab

        public void switchTab​(String tabHandle)
        Since:
        11.5RC1
      • getCurrentTabHandle

        public String getCurrentTabHandle()
        Since:
        11.5RC1
      • openLinkInTab

        public String openLinkInTab​(org.openqa.selenium.By by,
                                    String... existingTabHandles)
        Since:
        11.5RC1
      • closeTab

        public void closeTab​(String secondTabHandle)
        Since:
        11.5, 11.6RC1