当前位置: 首页>>代码示例>>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;未经允许,请勿转载。