本文整理汇总了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());
}
示例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"));
}
示例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"));
}
示例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"));
}
示例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"));
}