本文整理匯總了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"));
}