当前位置: 首页>>代码示例>>Java>>正文


Java HtmlTextArea类代码示例

本文整理汇总了Java中com.gargoylesoftware.htmlunit.html.HtmlTextArea的典型用法代码示例。如果您正苦于以下问题:Java HtmlTextArea类的具体用法?Java HtmlTextArea怎么用?Java HtmlTextArea使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


HtmlTextArea类属于com.gargoylesoftware.htmlunit.html包,在下文中一共展示了HtmlTextArea类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testPreviewDiffBug

import com.gargoylesoftware.htmlunit.html.HtmlTextArea; //导入依赖的package包/类
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.getButtonByName("preview").click();
  
  form = editPage.getFormByName(ID_EDIT_FORM);
  contentArea = form.getTextAreaByName("content");
  assertEquals(newContent + NEWLINE_TEXTAREA, contentArea.getText());
}
 
开发者ID:CoreFiling,项目名称:reviki,代码行数:20,代码来源:TestEditing.java

示例2: testPreviewWithChangedAttributes

import com.gargoylesoftware.htmlunit.html.HtmlTextArea; //导入依赖的package包/类
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.getButtonByName("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());
}
 
开发者ID:CoreFiling,项目名称:reviki,代码行数:23,代码来源:TestEditing.java

示例3: testInvalidSessionIdHelper

import com.gargoylesoftware.htmlunit.html.HtmlTextArea; //导入依赖的package包/类
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.getButtonByName(button).click();

  try {
    getAnchorByHrefContains(editPage, expectedContent);
    fail(failMsg);
  }
  catch (NoSuchElementException e) {
  }
}
 
开发者ID:CoreFiling,项目名称:reviki,代码行数:22,代码来源:TestEditing.java

示例4: testCreateTasks

import com.gargoylesoftware.htmlunit.html.HtmlTextArea; //导入依赖的package包/类
@Test
	public void testCreateTasks() throws Exception {

		HtmlPage createTaskPage = webClient.getPage("http://localhost:8080/tasks/new");

		HtmlForm form = createTaskPage.getHtmlElementById("form");
		HtmlTextInput nameInput = createTaskPage.getHtmlElementById("name");
		nameInput.setValueAttribute("My first task");
		HtmlTextArea descriptionInput = createTaskPage.getHtmlElementById("description");
		descriptionInput.setText("Description of my first task");
		HtmlButton submit = form.getOneHtmlElementByAttribute("button", "type", "submit");
		HtmlPage taskListPage = submit.click();

		Assertions.assertThat(taskListPage.getUrl().toString()).endsWith("/tasks");
//		String id = taskListPage.getHtmlElementById("todolist").getTextContent();
//		assertThat(id).isEqualTo("123");
//		String summary = newMessagePage.getHtmlElementById("summary").getTextContent();
//		assertThat(summary).isEqualTo("Spring Rocks");
//		String text = newMessagePage.getHtmlElementById("text").getTextContent();
//		assertThat(text).isEqualTo("In case you didn't know, Spring Rocks!");

	}
 
开发者ID:hantsy,项目名称:spring4-sandbox,代码行数:23,代码来源:MockMvcWebClientCreateTaskTests.java

示例5: testCreateNewObjectAndSetProperties

import com.gargoylesoftware.htmlunit.html.HtmlTextArea; //导入依赖的package包/类
@Test
@Ignore
public void testCreateNewObjectAndSetProperties() throws IOException {
    final String pid = createNewObject();

    final HtmlPage page = javascriptlessWebClient.getPage(serverAddress + pid);
    final HtmlForm form = (HtmlForm)page.getElementById("action_sparql_update");
    final HtmlTextArea sparql_update_query = (HtmlTextArea)page.getElementById("sparql_update_query");
    sparql_update_query.setText("INSERT { <> <info:some-predicate> 'asdf' } WHERE { }");

    final HtmlButton button = form.getFirstByXPath("button");
    button.click();

    final HtmlPage page1 = javascriptlessWebClient.getPage(serverAddress + pid);
    assertTrue(page1.getElementById("metadata").asText().contains("some-predicate"));
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:17,代码来源:FedoraHtmlResponsesIT.java

示例6: post

import com.gargoylesoftware.htmlunit.html.HtmlTextArea; //导入依赖的package包/类
private String post(){
	String postedUrl = null;
	String domain = Globals.paths.RemoteAdminUrl.substring(0,Globals.paths.RemoteAdminUrl.lastIndexOf("wp-admin")-1)+"/";
			
	webPageManipulation = new WebPageManipulation(connection.getStartPage());
	
	DomElement titleElement = webPageManipulation.getElementById("title");
	HtmlTextArea contentElement =(HtmlTextArea) webPageManipulation.getElementById("content");
	HtmlSubmitInput publishButton = (HtmlSubmitInput)webPageManipulation.getElementById("publish");
	
	webPageManipulation.setElement(titleElement, InputObject.getTitle());
	contentElement.setText(AdCode+"\n"+EmbedCode.replaceFirst("#", InputObject.getVideoUrl().replace("watch?v=", "/embed/"))+
			"\n"+EmbedCode.replaceFirst("#", InputObject.getVideoUrl().replace("watch?v=", "/embed/"))+"\n"+InputObject.getDescription());
	
	try {
		HtmlPage nxt = publishButton.click();
		webPageManipulation.setPage(nxt);
		
		DomElement url_posted = webPageManipulation.getElementById("editable-post-name-full");
		
		String postUrl = domain+url_posted.getTextContent();
		
		JOptionPane.showMessageDialog(null, postUrl);
		StringSelection selection = new StringSelection(postUrl);
	    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
	    clipboard.setContents(selection, selection);
	} catch (IOException e) {
		//Get Default Dialog used for exceptions, & add exception
		//Show Dialog
	}
	
	return postedUrl;
}
 
开发者ID:klevinism,项目名称:Ads-Attacher,代码行数:34,代码来源:MainViewController.java

示例7: testPreview

import com.gargoylesoftware.htmlunit.html.HtmlTextArea; //导入依赖的package包/类
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.getButtonByName("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));
}
 
开发者ID:CoreFiling,项目名称:reviki,代码行数:28,代码来源:TestEditing.java

示例8: loseLockHelper

import com.gargoylesoftware.htmlunit.html.HtmlTextArea; //导入依赖的package包/类
private HtmlPage loseLockHelper(final String buttonName) throws Exception, IOException, JaxenException {
  final String name = uniqueWikiPageName("LoseLockPreviewTest");
  // User 1 make page
  editWikiPage(name, "content", "", "", true);
  // User 1 edit
  HtmlPage pageUser1 = clickEditLink(getWikiPage(name));
  // Set the content to "user1"
  ((HtmlTextArea) pageUser1.getByXPath("id('contentArea')").iterator().next()).setText(USER1_EDIT_CONTENT);
  // User 2 unlock and edit
  switchUser();
  HtmlPage pageUser2 = getWikiPage(name);
  pageUser2 = (HtmlPage) ((HtmlSubmitInput) pageUser2.getByXPath("//input[@value='Unlock']").iterator().next()).click();
  pageUser2 = clickEditLink(pageUser2);
  // Set the content to "user2"
  ((HtmlTextArea) pageUser2.getByXPath("id('contentArea')").iterator().next()).setText(USER2_EDIT_CONTENT);
  // User 1 Save/Preview
  switchUser();
  pageUser1 = (HtmlPage) ((HtmlButton) pageUser1.getByXPath("//button[@name='" + buttonName + "']").iterator().next()).click();
  // Should be a Save button
  assertEquals(1, pageUser1.getByXPath("//button[@name='save']").size());
  // Should be a flash with "lock" in the message
  assertTrue(getErrorMessage(pageUser1).toLowerCase().contains("lock"));
  // Should be a diff
  assertTrue(pageUser1.getByXPath("//*[@class='diff']").size() > 0);
  // User 2 Save
  switchUser();
  pageUser2 = (HtmlPage) ((HtmlButton) pageUser2.getByXPath("//button[@name='save']").iterator().next()).click();
  // Should NOT be a Save button
  assertEquals(0, pageUser2.getByXPath("//button[@name='save']").size());
  // Return User 1 page
  switchUser();
  return pageUser1;
}
 
开发者ID:CoreFiling,项目名称:reviki,代码行数:34,代码来源:TestEditing.java

示例9: whenQuarantiningTestOnPage

import com.gargoylesoftware.htmlunit.html.HtmlTextArea; //导入依赖的package包/类
private void whenQuarantiningTestOnPage(HtmlPage page) throws Exception {
   ((HtmlAnchor) page.getElementById("quarantine")).click();
   HtmlForm form = page.getFormByName("quarantine");
   HtmlTextArea textArea = (HtmlTextArea) last(form.selectNodes(".//textarea"));
   textArea.setText(quarantineText);

   form.submit((HtmlButton) last(form.selectNodes(".//button")));
}
 
开发者ID:samsta,项目名称:quarantine,代码行数:9,代码来源:QuarantineUiTest.java

示例10: testSparqlSearch

import com.gargoylesoftware.htmlunit.html.HtmlTextArea; //导入依赖的package包/类
@Test
@Ignore("htmlunit can't see links in the HTML5 <nav> element..")
public void testSparqlSearch() throws IOException {
    final HtmlPage page = webClient.getPage(serverAddress);

    logger.error(page.toString());
    page.getAnchorByText("Search").click();

    final HtmlForm form = (HtmlForm)page.getElementById("action_sparql_select");
    final HtmlTextArea q = form.getTextAreaByName("q");
    q.setText("SELECT ?subject WHERE { ?subject a <" + REPOSITORY_NAMESPACE + "Resource> }");
    final HtmlButton button = form.getFirstByXPath("button");
    button.click();
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:15,代码来源:FedoraHtmlResponsesIT.java

示例11: putObservation

import com.gargoylesoftware.htmlunit.html.HtmlTextArea; //导入依赖的package包/类
public void putObservation(String observation, String observationURL) throws IOException {
    HtmlPage pagina = conn.getPage(observationURL);

    if (pagina.getTitleText().equals(SuapConnection.SUAP_LOGIN_PAGE_TITLE)) {
        pagina = login(observationURL);
    }

    HtmlForm formulario = pagina.getHtmlElementById("observacao_form");

    HtmlTextArea whereToInsertObs = formulario.getTextAreaByName("descricao");
    HtmlSubmitInput sendBtn = formulario.getInputByName("observacao_form");

    whereToInsertObs.setText(observation);

    sendBtn.click();
}
 
开发者ID:marcocspc,项目名称:SUAPPasswordResetter,代码行数:17,代码来源:SuapConnection.java

示例12: deleteAd

import com.gargoylesoftware.htmlunit.html.HtmlTextArea; //导入依赖的package包/类
public boolean deleteAd(PostObject post){
	
	PostObject Post = post;
	String PostEditUrl = Post.getUrl();
	String postDescriptionNoAd = "";
	conn = new WebConnection();
	
	try {
		conn.connect(PostEditUrl);
		if(conn.login()){
			conn.connect(PostEditUrl);
			pageManipulation = new WebPageManipulation(conn.getStartPage());
			HtmlTextArea txtAreaDescription = (HtmlTextArea)pageManipulation.getElementById("content");
			HtmlSubmitInput publish = (HtmlSubmitInput)pageManipulation.getElementById("publish");
			
			List<DomElement> listDescription = (List<DomElement>)pageManipulation.getByXPath("//textarea[@class='wp-editor-area']");
			
			String wpDescription = listDescription.get(0).asText();
			
			if(wpDescription.toLowerCase().contains(Globals.AdCode.toLowerCase())){				
				postDescriptionNoAd = wpDescription.replace(Globals.AdCode,"");
				
				txtAreaDescription.setText(postDescriptionNoAd);
				HtmlPage landingPage = publish.click();
				
				
				JOptionPane.showMessageDialog(null, "Ad removed");
				return true;

			}else{
				JOptionPane.showMessageDialog(null, "Sorry no ad code found inside this post");
				return false;
				/*TODO
				 * 1- Notify that post doesn't have an ad
				 */
			}				
		}
		
		System.out.print(postDescriptionNoAd);
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	return false;
}
 
开发者ID:klevinism,项目名称:Ads-Attacher,代码行数:46,代码来源:AsyncTasks.java

示例13: setFieldValue

import com.gargoylesoftware.htmlunit.html.HtmlTextArea; //导入依赖的package包/类
public final static void setFieldValue(HtmlPage page, String fieldId, String fieldValue) {
    HtmlElement element = page.getHtmlElementById(fieldId);
    Assert.assertTrue("element " + fieldId + " is null, page: " + page.asText(), element != null);

    if (element instanceof HtmlTextInput) {
        HtmlTextInput textField = (HtmlTextInput) element;
        textField.setValueAttribute(fieldValue);
    } else if (element instanceof HtmlTextArea) {
        HtmlTextArea textAreaField = (HtmlTextArea) element;
        textAreaField.setText(fieldValue);
    } else if (element instanceof HtmlHiddenInput) {
        HtmlHiddenInput hiddenField = (HtmlHiddenInput) element;
        hiddenField.setValueAttribute(fieldValue);
    } else if (element instanceof HtmlSelect) {
        HtmlSelect selectField = (HtmlSelect) element;
        try {
            selectField.setSelectedAttribute(fieldValue, true);
        } catch (IllegalArgumentException e) {
            Assert.fail("select element [" + element.asText() + "] " + e.getMessage());
        }
    } else if (element instanceof HtmlCheckBoxInput) {
        HtmlCheckBoxInput checkboxField = (HtmlCheckBoxInput) element;
        if (fieldValue.equals("on")) {
            checkboxField.setChecked(true);
        } else if (fieldValue.equals("off")) {
            checkboxField.setChecked(false);
        } else {
        	Assert.assertTrue("Invalid checkbox value", false);
        }
    } else if (element instanceof HtmlFileInput) {
        HtmlFileInput fileInputField = (HtmlFileInput) element;
        fileInputField.setValueAttribute(fieldValue);
    } else if (element instanceof HtmlRadioButtonInput) {
    	HtmlRadioButtonInput radioButton = (HtmlRadioButtonInput) element;
    	if (fieldValue.equals("on")) {
    		radioButton.setChecked(true);
    	} else if (fieldValue.equals("off")) {
    		radioButton.setChecked(false);
    	}
    } else {
    	Assert.fail("Unknown control field: " + fieldId);
    }
}
 
开发者ID:kuali-mirror,项目名称:kpme,代码行数:44,代码来源:HtmlUnitUtil.java

示例14: setHtmlTextArea

import com.gargoylesoftware.htmlunit.html.HtmlTextArea; //导入依赖的package包/类
/**
 * Sets a text area on a page.
 * 
 * @param page
 *            The page.
 * @param fieldId
 *            The field ID.
 * @param value
 *            The value to set.
 */
protected final void setHtmlTextArea(HtmlPage page, String fieldId, String value) {
	page.<HtmlTextArea>getHtmlElementById(fieldId).setText(value);
}
 
开发者ID:The4thLaw,项目名称:demyo,代码行数:14,代码来源:AbstractMvcTest.java


注:本文中的com.gargoylesoftware.htmlunit.html.HtmlTextArea类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。