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


Java HtmlPage.asText方法代碼示例

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


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

示例1: shouldShowPetIndexPage

import com.gargoylesoftware.htmlunit.html.HtmlPage; //導入方法依賴的package包/類
@Test
public void shouldShowPetIndexPage() throws Exception {
  HtmlPage ownerIndexPage = getPage("/pets");
  assertEquals(13.0, ownerIndexPage.getByXPath("count(//div[@class='card'])").get(0));

  String content = ownerIndexPage.asText();
  assertTrue(content.contains("Leo"));
  assertTrue(content.contains("Owned by: George Franklin"));
  assertTrue(content.contains("Birthday: 2010-09-07"));
  assertTrue(content.contains("Type: cat"));


  List viewEditDeleteLinks = ownerIndexPage.getByXPath("//div[@class='card'][1]//@href");
  assertEquals("/owners/1", ((DomAttr) viewEditDeleteLinks.get(0)).getValue());
  assertEquals("/pets/1", ((DomAttr) viewEditDeleteLinks.get(1)).getValue());
  assertEquals("/pets/1/edit", ((DomAttr) viewEditDeleteLinks.get(2)).getValue());
  assertEquals("/pets/1/delete", ((DomAttr) viewEditDeleteLinks.get(3)).getValue());
}
 
開發者ID:puncha,項目名稱:petclinic,代碼行數:19,代碼來源:PetControllerTests.java

示例2: shouldShowPetDetailPage

import com.gargoylesoftware.htmlunit.html.HtmlPage; //導入方法依賴的package包/類
@Test
public void shouldShowPetDetailPage() throws Exception {
  HtmlPage page = getPage("/pets/7");
  String content = page.asText();

  // Pet
  assertTrue(content.contains("Samantha"));
  assertTrue(content.contains("cat"));
  assertTrue(content.contains("2012-09-04"));

  // Owner
  assertTrue(content.contains("Jean"));

  // Visits
  assertTrue(content.contains("2013-01-04 spayed"));
  assertTrue(content.contains("2013-01-01 rabies shot"));
}
 
開發者ID:puncha,項目名稱:petclinic,代碼行數:18,代碼來源:PetControllerTests.java

示例3: testUnauthenticatedRequest

import com.gargoylesoftware.htmlunit.html.HtmlPage; //導入方法依賴的package包/類
@Test
public void testUnauthenticatedRequest() throws IOException, SAXException {
	logger.info("start unauthenticated request");
	HtmlPage page = webClient.getPage(base + "LoginServlet");
	String responseText = page.asText();
	assertTrue("Is User in Role", responseText.contains("isUserInRole?false"));
	assertTrue("Get Remote User", responseText.contains("getRemoteUser?null"));
	assertTrue("Get User Principal", responseText.contains("getUserPrincipal?null"));
	assertTrue("Get Auth Type", responseText.contains("getAuthType?null"));
}
 
開發者ID:PacktPublishing,項目名稱:Mastering-Java-EE-Development-with-WildFly,代碼行數:11,代碼來源:SecureServletTestCase.java

示例4: shouldCreateVisit

import com.gargoylesoftware.htmlunit.html.HtmlPage; //導入方法依賴的package包/類
@Test
public void shouldCreateVisit() throws Exception {
  HtmlPage page = getPage("/pets/1/visits/new");
  setInput(page, "description", "Hello, world!");
  setDateInput(page, "visitDate", "2000-02-02");
  HtmlPage petDetailPage = clickButton(page, "//button[@type='submit']");
  assertTrue(petDetailPage.getUrl().toString().matches(".*/pets/1$"));
  String content =petDetailPage.asText();
  assertTrue(content.contains("Hello, world!"));
  assertTrue(content.contains("2000-02-02"));
}
 
開發者ID:puncha,項目名稱:petclinic,代碼行數:12,代碼來源:PetAndVisitCreationTests.java

示例5: shouldShowOwnerDetailPage

import com.gargoylesoftware.htmlunit.html.HtmlPage; //導入方法依賴的package包/類
@Test
public void shouldShowOwnerDetailPage() throws Exception {
  HtmlPage page = getPage("/owners/1");
  String content = page.asText();

  // Owner
  assertTrue(content.contains("George"));
  assertTrue(content.contains("Franklin"));
  assertTrue(content.contains("110 W. Liberty St."));
  assertTrue(content.contains("Madison"));
  assertTrue(content.contains("6085551023"));

  // Pet
  assertTrue(content.contains("Leo"));
}
 
開發者ID:puncha,項目名稱:petclinic,代碼行數:16,代碼來源:OwnerControllerTests.java

示例6: testConfigElements

import com.gargoylesoftware.htmlunit.html.HtmlPage; //導入方法依賴的package包/類
@Test
public void testConfigElements() throws Exception {
    HtmlPage page = jenkinsRule.createWebClient().goTo("configure");
    String pageText = page.asText();
    Assert.assertTrue("Missing: BrowserStack Global Config", pageText.contains("BrowserStack"));
}
 
開發者ID:jenkinsci,項目名稱:browserstack-integration-plugin,代碼行數:7,代碼來源:GlobalConfigTest.java


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