Java Code Examples for com.gargoylesoftware.htmlunit.html.HtmlPage#getTitleText()

The following examples show how to use com.gargoylesoftware.htmlunit.html.HtmlPage#getTitleText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PageFunctionTest.java    From tool.accelerate.core with Apache License 2.0 6 votes vote down vote up
@Test
public void headingTest() {
    final WebClient webClient = new WebClient();
    webClient.getOptions().setJavaScriptEnabled(false);
    HtmlPage page;
    String port = System.getProperty("liberty.test.port");
    try {
        page = webClient.getPage("http://localhost:" + port + "/start/");
        String title = page.getTitleText();
        assertTrue("Title is " + title, title.equals("Liberty app accelerator"));
    } catch (Exception e){
        org.junit.Assert.fail("Caught exception: " + e);
    } finally {
        webClient.close();
    }
}
 
Example 2
Source File: WebAssert.java    From htmlunit with Apache License 2.0 5 votes vote down vote up
/**
 * Verifies that the specified page's title equals the specified expected title.
 *
 * @param page the page to check
 * @param title the expected title
 */
public static void assertTitleEquals(final HtmlPage page, final String title) {
    final String s = page.getTitleText();
    if (!s.equals(title)) {
        final String msg = "Actual page title '" + s + "' does not match expected page title '" + title + "'.";
        throw new AssertionError(msg);
    }
}
 
Example 3
Source File: WebAssert.java    From htmlunit with Apache License 2.0 5 votes vote down vote up
/**
 * Verifies that the specified page's title contains the specified substring.
 *
 * @param page the page to check
 * @param titlePortion the substring which the page title is expected to contain
 */
public static void assertTitleContains(final HtmlPage page, final String titlePortion) {
    final String s = page.getTitleText();
    if (s.indexOf(titlePortion) == -1) {
        final String msg = "Page title '" + s + "' does not contain the substring '" + titlePortion + "'.";
        throw new AssertionError(msg);
    }
}
 
Example 4
Source File: WebAssert.java    From htmlunit with Apache License 2.0 5 votes vote down vote up
/**
 * Verifies that the specified page's title matches the specified regular expression.
 *
 * @param page the page to check
 * @param regex the regular expression that the page title is expected to match
 */
public static void assertTitleMatches(final HtmlPage page, final String regex) {
    final String s = page.getTitleText();
    if (!s.matches(regex)) {
        final String msg = "Page title '" + s + "' does not match the regular expression '" + regex + "'.";
        throw new AssertionError(msg);
    }
}
 
Example 5
Source File: WebAssert.java    From HtmlUnit-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Verifies that the specified page's title equals the specified expected title.
 *
 * @param page the page to check
 * @param title the expected title
 */
public static void assertTitleEquals(final HtmlPage page, final String title) {
    final String s = page.getTitleText();
    if (!s.equals(title)) {
        final String msg = "Actual page title '" + s + "' does not match expected page title '" + title + "'.";
        throw new AssertionError(msg);
    }
}
 
Example 6
Source File: WebAssert.java    From HtmlUnit-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Verifies that the specified page's title contains the specified substring.
 *
 * @param page the page to check
 * @param titlePortion the substring which the page title is expected to contain
 */
public static void assertTitleContains(final HtmlPage page, final String titlePortion) {
    final String s = page.getTitleText();
    if (s.indexOf(titlePortion) == -1) {
        final String msg = "Page title '" + s + "' does not contain the substring '" + titlePortion + "'.";
        throw new AssertionError(msg);
    }
}
 
Example 7
Source File: WebAssert.java    From HtmlUnit-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Verifies that the specified page's title matches the specified regular expression.
 *
 * @param page the page to check
 * @param regex the regular expression that the page title is expected to match
 */
public static void assertTitleMatches(final HtmlPage page, final String regex) {
    final String s = page.getTitleText();
    if (!s.matches(regex)) {
        final String msg = "Page title '" + s + "' does not match the regular expression '" + regex + "'.";
        throw new AssertionError(msg);
    }
}