TWaitforParams:
参数 | 类型 | 必须 | 默认值 | 说明 |
---|---|---|---|---|
container | HTMLElement | window.document | ||
timeout | number | 1000 | 失效时间 | |
interval | number | 50 | 查询间隔 | |
mutationObserverOptions | MutationObserverInit | {subtree: true, childList: true, attributes: true, characterData: true } | 监听器参数 |
function querySelector(selectors: string): HTMLElement;
参数:
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
selectors | string | 是 | 选择器,同 docuemt.querySelector 一致 |
用法:
const btns = testUtils.querySelectorAll(".btns");
function querySelectorAll(selectors: string): HTMLElement[];
参数:
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
selectors | string | 是 | 选择器,同 docuemt.querySelectorAll 一致 |
用法:
const btns = testUtils.querySelectorAll(".btns");
async function waitForQuerySelector(
selectors: string,
params?: TParams
): Promise<HTMLElement>;
参数:
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
selectors | string | 是 | 选择器,同 docuemt.querySelector 一致 |
params | TWaitforParams | 参数:见 TWaitforParams 说明 |
用法:
const btn = await testUtils.waitForQuerySelector(".async-btn");
async function waitForQuerySelectorAll(
selectors: string,
params?: TParams
): Promise<HTMLElement[]>;
参数:
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
selectors | string | 是 | 选择器,同 docuemt.querySelectorAll 一致 |
params | TWaitforParams | 参数:见 TWaitforParams 说明 |
用法:
const btns = await testUtils.waitForQuerySelectorAll(".async-btns");
function queryByText(text: string, selector?: string): HTMLElement;
参数:
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
text | string | 是 | 文本内容,部分匹配即可 |
selector | string | 选择器,同 docuemt.querySelector 一致 |
用法:
// <Text>Hello World!!!</Text>
const textView = testUtils.queryByText("Hello World");
function queryAllByText(text: string, selector?: string): HTMLElement[];
参数:
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
text | string | 是 | 文本内容,部分匹配即可 |
selector | string | 选择器,同 docuemt.querySelector 一致 |
用法:
// <Text>Hello World!!</Text>
// <View>Hello World!!!</View>
const textViews = testUtils.queryAllByText("Hello World");
async function waitForQueryByText(
text: string,
selector?: string,
params?: TWaitforParams
): HTMLElement;
参数:
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
text | string | 是 | 文本内容,部分匹配即可 |
selector | string | 选择器,同 docuemt.querySelector 一致 | |
params | TWaitforParams | 参数:见 TWaitforParams 说明 |
用法:
// <Text>Hello World!!!</Text>
const textView = async testUtils.waitForQueryByText("Hello World");
async function waitForQueryAllByText(
text: string,
selector?: string,
params?: TWaitforParams
): HTMLElement[];
参数:
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
text | string | 是 | 文本内容,部分匹配即可 |
selector | string | 选择器,同 docuemt.querySelector 一致 | |
params | TWaitforParams | 参数:见 TWaitforParams 说明 |
用法:
// <Text>Hello World!!</Text>
// <View>Hello World!!!</View>
const textViews = async testUtils.waitForQueryAllByText("Hello World");
function queryByPlaceholder(text: string): HTMLElement;
参数:
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
text | string | 是 | placeholder 内容 |
用法:
// <input placeholder="hello" />
const input = testUtils.queryByPlaceholder("hello");
function queryAllByPlaceholder(text: string): HTMLElement[];
参数:
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
text | string | 是 | placeholder 内容 |
用法:
// <input placeholder="hello" />
// <input placeholder="hello" />
const inputs = testUtils.queryAllByPlaceholder("hello");
async function waitForQueryByPlaceholder(
text: string,
params?: TParams
): Promise<HTMLElement>;
参数:
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
text | string | 是 | placeholder 内容 |
params | TWaitforParams | 参数:见 TWaitforParams 说明 |
用法:
// <input placeholder="async-placeholde" />
const input = await testUtils.waitForQueryByPlaceholder("async-placeholder");
async function waitForQueryAllByPlaceholder(
text: string,
params?: TParams
): Promise<HTMLElement[]>;
参数:
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
text | string | 是 | placeholder 内容 |
params | TWaitforParams | 参数:见 TWaitforParams 说明 |
用法:
// <input placeholder="async-placeholde" />
// <input placeholder="async-placeholde" />
const inputs = await testUtils.waitForQueryAllByPlaceholder(
"async-placeholder"
);
function queryByAttribute(attr: string, value: any): HTMLElement;
参数:
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
attr | string | 是 | 属性 key |
value | any | 是 | 属性 value |
用法:
// <div key="value" />
const view = testUtils.queryByAttribute("key", "value");
function queryAllByAttribute(attr: string, value: any): HTMLElement[];
参数:
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
attr | string | 是 | 属性 key |
value | any | 是 | 属性 value |
用法:
// <div key="value" />
// <div key="value" />
const view = testUtils.queryAllByAttribute("key", "value");
async function waitForQueryByAttribute(
attr: string,
value: string,
params?: TParams
): Promise<HTMLElement>;
参数:
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
attr | string | 是 | 属性 key |
value | any | 是 | 属性 value |
params | TWaitforParams | 参数:见 TWaitforParams 说明 |
用法:
// <div key="value" />
const view = await testUtils.waitForQueryByAttribute("key", "value");
async function waitForQueryAllByAttribute(
attr: string,
value: string,
params?: TParams
): Promise<HTMLElement[]>;
参数:
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
attr | string | 是 | 属性 key |
value | any | 是 | 属性 value |
params | TWaitforParams | 参数:见 TWaitforParams 说明 |
用法:
// <div key="value" />
// <div key="value" />
const inputs = await testUtils.waitForQueryAllByAttribute("key", "value");