0

此方法检查具有作为参数传递的字符串的链接。我怀疑它是否区分大小写匹配。

示例:我在锚标记中有一个链接,其中“sample123”作为锚标记内的文本。如果我将此方法用作 assertLinkPresentWithText("Sample");

这会匹配作为小写文本示例的链接吗?

4

1 回答 1

0

根据源代码

/**
 * Verifies that the specified page contains a link with the specified text. The specified text
 * may be a substring of the entire text contained by the link.
 *
 * @param page the page to check
 * @param text the text which a link in the specified page is expected to contain
 */
public static void assertLinkPresentWithText(final HtmlPage page, final String text) {
    boolean found = false;
    for (final HtmlAnchor a : page.getAnchors()) {
        if (a.asText().contains(text)) {
            found = true;
            break;
        }
    }
    if (!found) {
        final String msg = "The page does not contain a link with text '" + text + "'.";
        throw new AssertionError(msg);
    }
}

我会说不

于 2012-08-21T09:23:54.883 回答