Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

By Title

get_by_title, query_by_title, get_all_by_title, query_all_by_title, find_by_title, find_all_by_title

API

use testing_library_dom::{Matcher, QueryError};
use web_sys::HtmlElement;

fn get_by_title<M: Into<Matcher>>(
    // If you're using `screen`, then skip the container argument:
    container: &HtmlElement,
    matcher: M,
    options: MatcherOptions,
) -> Result<HtmlElement, QueryError>;

struct MatcherOptions {
    exact: Option<bool>,
    normalizer: Option<Rc<NormalizerFn>>,
}

type NormalizerFn = dyn Fn(String) -> String;

Returns the element that has the matching title attribute.

Will also find a title element within an SVG.

<span title="Delete" id="2"></span>
<svg>
    <title>Close</title>
    <g><path /></g>
</svg>
use testing_library_dom::screen;

let screen = screen();
let delete_element = screen.get_by_title("Delete");
let close_element = screen.get_by_title("Close");

Options

Matcher options.