當前位置: 首頁>>代碼示例>>Java>>正文


Java HtmlForm.getOneHtmlElementByAttribute方法代碼示例

本文整理匯總了Java中com.gargoylesoftware.htmlunit.html.HtmlForm.getOneHtmlElementByAttribute方法的典型用法代碼示例。如果您正苦於以下問題:Java HtmlForm.getOneHtmlElementByAttribute方法的具體用法?Java HtmlForm.getOneHtmlElementByAttribute怎麽用?Java HtmlForm.getOneHtmlElementByAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.gargoylesoftware.htmlunit.html.HtmlForm的用法示例。


在下文中一共展示了HtmlForm.getOneHtmlElementByAttribute方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testCreateTasks

import com.gargoylesoftware.htmlunit.html.HtmlForm; //導入方法依賴的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

示例2: submitForm

import com.gargoylesoftware.htmlunit.html.HtmlForm; //導入方法依賴的package包/類
/**
 * Submits a form.
 * 
 * @param form
 *            The form to submit.
 * @return The page to which the form redirects.
 * @throws IOException
 *             If an IO error occurs
 */
protected final HtmlPage submitForm(HtmlForm form) throws IOException {
	HtmlSubmitInput submit = form.<HtmlSubmitInput>getOneHtmlElementByAttribute("input", "type", "submit");
	return submit.click();
}
 
開發者ID:The4thLaw,項目名稱:demyo,代碼行數:14,代碼來源:AbstractMvcTest.java


注:本文中的com.gargoylesoftware.htmlunit.html.HtmlForm.getOneHtmlElementByAttribute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。