/** * Verifies that the specified page does not contain the specified text. * * @param page the page to check * @param text the text to check for */ public static void assertTextNotPresent(final HtmlPage page, final String text) { if (page.asText().contains(text)) { final String msg = "The page contains the text '" + text + "'."; throw new AssertionError(msg); } }
/** * Verifies that the specified page contains the specified text. * * @param page the page to check * @param text the text to check for */ public static void assertTextPresent(final HtmlPage page, final String text) { if (page.asText().indexOf(text) == -1) { final String msg = "The page does not contain the text '" + text + "'."; throw new AssertionError(msg); } }
/** * Verifies that the specified page contains the specified text. * * @param page the page to check * @param text the text to check for */ public static void assertTextPresent(final HtmlPage page, final String text) { if (page.asText().indexOf(text) == -1) { final String msg = "The page does not contain the text '" + text + "'."; throw new AssertionError(msg); } }
/** * Verifies that the specified page does not contain the specified text. * * @param page the page to check * @param text the text to check for */ public static void assertTextNotPresent(final HtmlPage page, final String text) { if (page.asText().contains(text)) { final String msg = "The page contains the text '" + text + "'."; throw new AssertionError(msg); } }
/** * Verifies that the specified page does not contain the specified text. * * @param page the page to check * @param text the text to check for */ public static void assertTextNotPresent(final HtmlPage page, final String text) { if (page.asText().contains(text)) { final String msg = "The page contains the text '" + text + "'."; throw new AssertionError(msg); } }
/** * Verifies that the specified page contains the specified text. * * @param page the page to check * @param text the text to check for */ public static void assertTextPresent(final HtmlPage page, final String text) { if (page.asText().indexOf(text) == -1) { final String msg = "The page does not contain the text '" + text + "'."; throw new AssertionError(msg); } }
/** * Verifies that the specified page contains the specified text. * * @param page the page to check * @param text the text to check for */ public static void assertTextPresent(final HtmlPage page, final String text) { if (page.asText().indexOf(text) == -1) { final String msg = "The page does not contain the text '" + text + "'."; throw new AssertionError(msg); } }
/** * Verifies that the specified page does not contain the specified text. * * @param page the page to check * @param text the text to check for */ public static void assertTextNotPresent(final HtmlPage page, final String text) { if (page.asText().contains(text)) { final String msg = "The page contains the text '" + text + "'."; throw new AssertionError(msg); } }
/** * Verifies that the specified page does not contain the specified text. * * @param page the page to check * @param text the text to check for */ public static void assertTextNotPresent(final HtmlPage page, final String text) { if (page.asText().contains(text)) { final String msg = "The page contains the text '" + text + "'."; throw new AssertionError(msg); } }
/** * Verifies that the specified page contains the specified text. * * @param page the page to check * @param text the text to check for */ public static void assertTextPresent(final HtmlPage page, final String text) { if (page.asText().indexOf(text) == -1) { final String msg = "The page does not contain the text '" + text + "'."; throw new AssertionError(msg); } }
DomElement button = (DomElement) form.getFirstByXPath("//button[@id='logincontrol_submitbutton']"); text.setValueAttribute("Ziplok Java"); HtmlPage resultPage = (HtmlPage) button.click(); System.out.println(resultPage.asText());
@Test @SpecAssertion(section = PROCESS_INJECTION_TARGET_EE, id = "ed") public void testWrappedInjectionTargetUsedForTagHandler() throws Exception { HtmlPage page = invokeContextPath("index.jsp", HtmlPage.class); assertTrue(page.asText().contains("true")); }
LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog"); java.util.logging.Logger.getLogger("com.gargoylesoftware").setLevel(Level.OFF); java.util.logging.Logger.getLogger("org.apache.commons.httpclient").setLevel(Level.OFF); WebClient client = new WebClient(BrowserVersion.CHROME); client.getOptions().setJavaScriptEnabled(true); client.getOptions().setThrowExceptionOnScriptError(false); client.getOptions().setThrowExceptionOnFailingStatusCode(false); String url = "https://accounts.google.com/login"; final HtmlPage page = client.getPage(url); System.out.println(page.asText());
public static void main(String[] args) { String pageURL = args[1]; WebClient webClient = new WebClient(); HtmlPage page = webClient.getPage(pageURL); String pageContents = page.asText(); // Save the resulting page to a file }
try (WebClient webClient = new WebClient(BrowserVersion.CHROME)) { webClient.getOptions().setThrowExceptionOnScriptError(false); final HtmlPage page = webClient.getPage("http://www.reuters.com/article/2015/07/08/us-alibaba-singapore-post-idUSKCN0PI03J20150708"); webClient.waitForBackgroundJavaScript(10000); System.out.println(page.asText()); }
@Test public void homePage() throws Exception { final WebClient webClient = new WebClient(); final HtmlPage page = webClient.getPage("http://htmlunit.sourceforge.net"); assertEquals("HtmlUnit - Welcome to HtmlUnit", page.getTitleText()); final String pageAsXml = page.asXml(); assertTrue(pageAsXml.contains("<body class=\"composite\">")); final String pageAsText = page.asText(); assertTrue(pageAsText.contains("Support for the HTTP and HTTPS protocols")); }
try (final WebClient webClient = new WebClient(BrowserVersion.CHROME)) { final HtmlPage page = webClient.getPage("http://www.aastocks.com/en/stock/DetailQuote.aspx?&symbol1"); HtmlInput input = page.getHtmlElementById("PY_txt"); input.type("328"); final HtmlPage page2 = page.getHtmlElementById("imgHKStockSubmit").click(); System.out.println(page2.getUrl()); System.out.println(page2.asText()); }
HtmlPage page = (HtmlPage) webClient.getPage("https:website name.com/loginpage"); HtmlForm form = page.getFormBy("login_form"); HtmlForm formm= page.getForms().get(0); formm.getInputByName("SignInEmailAddress").setValueAttribute("your emailid"); formm.getInputByName("SignInPassword").setValueAttribute("password"); page = (HtmlPage) formm.getInputByValue("Login").click(); System.out.println(page); System.out.println(page.asText());
/** * Overridden to strip extraneous whitespace from the page text to easier string matching. */ @Override public String getPageText() { Page page = getCurrentWindow().getEnclosedPage(); if (page instanceof HtmlPage) { return normalizeSpace(((HtmlPage) page).asText()); } else { return super.getPageText(); } }
try (WebClient webClient = new WebClient()) { HtmlPage page = (HtmlPage) webClient.getPage("https://ma-andover.myfollett.com/aspen/logon.do"); HtmlForm form = page.getFormByName("logonForm"); form.getInputByName("username").type("myUsername"); form.getInputByName("password").type("myPassword"); page = form.getInputByValue("Log On").click(); System.out.println(page.asText()); }