예제 #1
0
  public void testPreviewDiffBug() throws Exception {
    // https://bugs.corefiling.com/show_bug.cgi?id=13510
    // Old versions of the diff_match_patch package have a bug in the diff_cleanupSemantic method
    // The two comparison strings need to be well crafted to trigger the bug.
    String name = uniqueWikiPageName("PreviewPageTest");
    String content =
        "="
            + NEWLINE_TEXTAREA
            + "This is a lis of things that someone be doing if"
            + NEWLINE_TEXTAREA
            + "===Wiki"
            + NEWLINE_TEXTAREA;
    String newContent = "||" + NEWLINE_TEXTAREA + "==";

    HtmlPage edited = editWikiPage(name, content, "", "", true);
    HtmlPage editPage = clickEditLink(edited);
    HtmlForm form = editPage.getFormByName(ID_EDIT_FORM);
    HtmlTextArea contentArea = form.getTextAreaByName("content");
    contentArea.setText(newContent);
    editPage = (HtmlPage) form.getInputByValue("Preview").click();

    form = editPage.getFormByName(ID_EDIT_FORM);
    contentArea = form.getTextAreaByName("content");
    assertEquals(newContent + NEWLINE_TEXTAREA, contentArea.getText());
  }
예제 #2
0
  private void testInvalidSessionIdHelper(
      final String button,
      final String name,
      final String failMsg,
      final boolean fakeAppendedSessionId)
      throws IOException, JaxenException {
    HtmlPage editPage = clickEditLink(getWikiPage(name));
    final HtmlForm form = editPage.getFormByName(ID_EDIT_FORM);
    final HtmlInput sessionId = form.getInputByName("sessionId");
    sessionId.setValueAttribute(FAKE_SESSION_ID);
    if (fakeAppendedSessionId) {
      form.setActionAttribute(name + ";jsessionid=" + FAKE_SESSION_ID);
    }
    final HtmlTextArea content = form.getTextAreaByName("content");
    final String expectedContent = "http://www.example.com";
    content.setText(expectedContent);

    editPage = (HtmlPage) form.getInputByValue(button).click();

    try {
      getAnchorByHrefContains(editPage, expectedContent);
      fail(failMsg);
    } catch (NoSuchElementException e) {
    }
  }
예제 #3
0
  public void testPreview() throws Exception {
    String name = uniqueWikiPageName("PreviewPageTest");
    HtmlPage editPage = clickEditLink(getWikiPage(name));
    HtmlForm form = editPage.getFormByName(ID_EDIT_FORM);
    HtmlInput minorEdit = form.getInputByName("minorEdit");
    assertFalse(minorEdit.isChecked());
    minorEdit.setChecked(true);
    HtmlInput description = form.getInputByName("description");
    String expectedDescription = "My test change";
    description.setValueAttribute(expectedDescription);
    HtmlTextArea content = form.getTextAreaByName("content");
    String expectedContent = "http://www.example.com";
    content.setText(expectedContent);

    // Now if we preview we should get the previewed text rendered, and in
    // the edit area.  The other options should be preserved too.
    editPage = (HtmlPage) form.getInputByValue("Preview").click();
    form = editPage.getFormByName(ID_EDIT_FORM);
    minorEdit = form.getInputByName("minorEdit");
    description = form.getInputByName("description");
    content = form.getTextAreaByName("content");
    assertEquals(expectedDescription, description.getValueAttribute());
    assertTrue(minorEdit.isChecked());
    assertEquals(expectedContent + NEWLINE_TEXTAREA, content.getText());
    // This checks for the rendering...
    assertNotNull(editPage.getAnchorByHref(expectedContent));
  }
예제 #4
0
파일: Main.java 프로젝트: 9316/IdeaProjects
  public static void main(String[] args) {
    WebClient client = new WebClient(BrowserVersion.CHROME);
    HtmlPage page = null;

    try {
      page = client.getPage("http://www.facebook.com");

      System.out.println(page.getTitleText());

      HtmlForm form = (HtmlForm) page.getElementById("login_form");
      form.getInputByName("email").setValueAttribute("*****@*****.**");
      form.getInputByName("pass").setValueAttribute("saburtalo16");
      page = form.getInputByValue("Log In").click();
      System.out.println(page.getTitleText());

      HtmlTextArea statusText = (HtmlTextArea) page.getElementByName("xhpc_message_text");
      statusText.click();
      statusText.setText("I'm a robot");
      HtmlButton post =
          (HtmlButton)
              page.getFirstByXPath("//button[@id=\"u_jsonp_3_4\"]/div/div[4]/div/ul/li[2]/button");
      post.click();

    } catch (Exception e) {
      e
          .printStackTrace(); // To change body of catch statement use File | Settings | File
                              // Templates.
    }
  }
 private static List<String> getSimulatedProperties(final BrowserVersion browserVersion)
     throws Exception {
   final URL url = PropertiesTest.class.getClassLoader().getResource("objects/properties.html");
   final WebClient webClient = new WebClient(browserVersion);
   final HtmlPage page = webClient.getPage(url);
   final HtmlTextArea textarea = page.getHtmlElementById("myTextarea");
   return Arrays.asList(textarea.getText().split("\r\n|\n"));
 }
예제 #6
0
  public void testPreviewWithChangedAttributes() throws Exception {
    String name = uniqueWikiPageName("PreviewPageTest");
    HtmlPage editPage = clickEditLink(getWikiPage(name));
    HtmlForm form = editPage.getFormByName(ID_EDIT_FORM);
    HtmlTextArea attributes = form.getTextAreaByName("attributes");
    String expectedContent = "SomeContent";
    String expectedAttributes = "\"text\" = \"" + expectedContent + "\"";
    attributes.setText(expectedAttributes);
    HtmlTextArea content = form.getTextAreaByName("content");
    String expectedContentSource = "<<attr:text>>";
    content.setText(expectedContentSource);

    // Now if we preview we should get the previewed text rendered, and in
    // the edit area.
    editPage = (HtmlPage) form.getInputByValue("Preview").click();
    editPage.asText().contains(expectedContent);
    form = editPage.getFormByName(ID_EDIT_FORM);
    attributes = form.getTextAreaByName("attributes");
    assertEquals(expectedAttributes + NEWLINE_TEXTAREA, attributes.getText());
    content = form.getTextAreaByName("content");
    assertEquals(expectedContentSource + NEWLINE_TEXTAREA, content.getText());
  }