Skip to main content
Version: 22.9.0

Locator 类

¥Locator class

定位器描述了定位对象并对其执行操作的策略。如果由于对象尚未准备好执行操作而导致操作失败,则会重试整个操作。自动检查成功操作的各种先决条件。

¥Locators describe a strategy of locating objects and performing an action on them. If the action fails because the object is not ready for the action, the whole operation is retried. Various preconditions for a successful action are checked automatically.

签名:

¥Signature:

export declare abstract class Locator<T> extends EventEmitter<LocatorEvents>

Extends: EventEmitter<LocatorEvents>

属性

¥Properties

属性

修饰符

类型

描述

_

optional

T

用于名义上键入 定位器

timeout

readonly

数字

方法

¥Methods

方法

修饰符

描述

click(this, options)
clone()

克隆定位器。

fill(this, value, options)

使用提供的值填写定位器标识的输入。输入的类型在运行时确定,并根据类型选择适当的填充方法。支持内容编辑、选择器、输入。

filter(predicate)

创建根据定位值进行评估的期望。

如果期望不匹配,则定位器将重试。

hover(this, options)
map(mapper)

使用提供的映射器映射定位器。

race(locators)

static

在多个定位器之间创建竞争,但确保只有一个定位器起作用。

scroll(this, options)
setEnsureElementIsInTheViewport(this, value)
setTimeout(timeout)
setVisibility(this, visibility)
setWaitForEnabled(this, value)
setWaitForStableBoundingBox(this, value)
wait(options)

等待定位器从页面获取序列化值。

请注意,这要求该值是 JSON 可序列化的。

waitHandle(options)

等待定位器从页面获取句柄。