public void deleteObject(String space, String page, String className, int objectNumber) {
    StringBuilder queryString = new StringBuilder();

    queryString.append("classname=");
    queryString.append(escapeURL(className));
    queryString.append('&');
    queryString.append("classid=");
    queryString.append(objectNumber);

    gotoPage(space, page, "objectremove", queryString.toString());
  }
 /**
  * (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 {@link #getSecretToken()} is called and
  * after each re-login.
  *
  * @see #getSecretToken()
  */
 public void recacheSecretToken() {
   // Save the current URL to be able to get back after we cache the secret token. We're not using
   // the browser's
   // Back button because if the current page is the result of a POST request then by going back we
   // are re-sending
   // the POST data which can have unexpected results. Moreover, some browsers pop up a modal
   // confirmation box
   // which blocks the test.
   String previousURL = getDriver().getCurrentUrl();
   // Go to the registration page because the registration form uses secret token.
   gotoPage("XWiki", "Register", "register");
   try {
     WebElement tokenInput = getDriver().findElement(By.xpath("//input[@name='form_token']"));
     this.secretToken = tokenInput.getAttribute("value");
   } catch (NoSuchElementException exception) {
     // Something is really wrong if this happens.
     System.out.println("Warning: Failed to cache anti-CSRF secret token, some tests might fail!");
     exception.printStackTrace();
   }
   // Return to the previous page.
   getDriver().get(previousURL);
 }
 public ViewPage createPage(
     String space,
     String page,
     String content,
     String title,
     String syntaxId,
     String parentFullPageName) {
   Map<String, String> queryMap = new HashMap<String, String>();
   if (content != null) {
     queryMap.put("content", content);
   }
   if (title != null) {
     queryMap.put("title", title);
   }
   if (syntaxId != null) {
     queryMap.put("syntaxId", syntaxId);
   }
   if (parentFullPageName != null) {
     queryMap.put("parent", parentFullPageName);
   }
   gotoPage(space, page, "save", queryMap);
   return new ViewPage();
 }
 public ClassEditPage editClass(String space, String page) {
   gotoPage(space, page, "edit", "editor=class");
   return new ClassEditPage();
 }
 public ObjectEditPage editObjects(String space, String page) {
   gotoPage(space, page, "edit", "editor=object");
   return new ObjectEditPage();
 }
 public ClassEditPage addClassProperty(
     String space, String page, String propertyName, String propertyType) {
   gotoPage(space, page, "propadd", "propname", propertyName, "proptype", propertyType);
   return new ClassEditPage();
 }
 public void updateObject(
     String space, String page, String className, int objectNumber, Object... properties) {
   // TODO: would be even quicker using REST
   gotoPage(space, page, "save", toQueryParameters(className, objectNumber, properties));
 }
 public void updateObject(
     String space, String page, String className, int objectNumber, Map<String, ?> properties) {
   gotoPage(space, page, "save", toQueryParameters(className, objectNumber, properties));
 }
 public void addObject(String space, String page, String className, Map<String, ?> properties) {
   gotoPage(space, page, "objectadd", toQueryParameters(className, null, properties));
 }
Exemple #10
0
 public void gotoPage(String space, String page, String action, Map<String, ?> queryParameters) {
   gotoPage(space, page, action, toQueryString(queryParameters));
 }
Exemple #11
0
 /** @since 3.5M1 */
 public void gotoPage(String space, String page, String action, Object... queryParameters) {
   gotoPage(space, page, action, toQueryString(queryParameters));
 }
Exemple #12
0
 public void gotoPage(String space, String page, String action) {
   gotoPage(space, page, action, "");
 }
Exemple #13
0
 public ViewPage gotoPage(String space, String page) {
   gotoPage(space, page, "view");
   return new ViewPage();
 }
  @Test
  @IgnoreBrowser(
      value = "internet.*",
      version = "8\\.*",
      reason = "See http://jira.xwiki.org/browse/XE-1146")
  public void testKeyboardShortcuts() {
    ViewPage vp = util.gotoPage("Sandbox", "WebHome");

    // Test default edit mode (WYSIWYG for sandbox webhome) key
    vp.sendKeys("e");
    vp.waitUntilPageIsLoaded();
    Assert.assertTrue(util.isInWYSIWYGEditMode());

    // Test Cancel key
    vp.sendKeys(Keys.ALT, "c");
    vp.waitUntilPageIsLoaded();
    Assert.assertTrue(util.isInViewMode());

    // Test Wiki edit key
    vp.sendKeys("k");
    vp.waitUntilPageIsLoaded();
    Assert.assertTrue(util.isInWikiEditMode());

    // Test WYSIWYG edit mode key
    vp = this.util.gotoPage("Sandbox", "WebHome");
    vp.sendKeys("e");
    vp.waitUntilPageIsLoaded();
    Assert.assertTrue(util.isInWYSIWYGEditMode());

    // Test Inline edit mode key
    vp = this.util.gotoPage("Sandbox", "WebHome");
    vp.sendKeys("f");
    vp.waitUntilPageIsLoaded();
    Assert.assertTrue(util.isInInlineEditMode());

    // Test Rights edit mode key
    vp = this.util.gotoPage("Sandbox", "WebHome");
    vp.sendKeys("r");
    vp.waitUntilPageIsLoaded();
    Assert.assertTrue(util.isInRightsEditMode());

    // Test Object edit mode key
    vp = this.util.gotoPage("Sandbox", "WebHome");
    vp.sendKeys("o");
    vp.waitUntilPageIsLoaded();
    Assert.assertTrue(util.isInObjectEditMode());

    // Test Class edit mode key
    vp = this.util.gotoPage("Sandbox", "WebHome");
    vp.sendKeys("s");
    vp.waitUntilPageIsLoaded();
    Assert.assertTrue(util.isInClassEditMode());

    // Test Delete key
    vp = this.util.gotoPage("Sandbox", "WebHome");
    vp.sendKeys(Keys.DELETE);
    Assert.assertTrue(util.isInDeleteMode());

    // Test Rename key
    vp = this.util.gotoPage("Sandbox", "WebHome");
    vp.sendKeys(Keys.F2);
    Assert.assertTrue(util.isInRenameMode());
  }