junit方法assertLinkPresentWithText

junit方法assertLinkPresentWithText,junit,htmlunit,case-sensitive,Junit,Htmlunit,Case Sensitive,此方法检查具有作为参数传递的字符串的链接。我怀疑这是否是区分大小写的匹配 Exmaple: 我在锚定标记中有一个链接,锚定标记中的文本是“sample123”。 如果我将此方法用作assertLinkPresentWithText(“示例”) 这是否与作为文本样本的链接匹配(小写?根据: 我会说不。不,链接匹配区分大小写。 /** * Verifies that the specified page contains a link with the specified text. The sp

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

Exmaple: 我在锚定标记中有一个链接,锚定标记中的文本是“sample123”。 如果我将此方法用作assertLinkPresentWithText(“示例”)

这是否与作为文本样本的链接匹配(小写?

根据:


我会说不。

不,链接匹配区分大小写。
/**
 * 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);
    }
}