Locator
Playwright\Locator\LocatorInterface
Methods
click()
voidfunction click(array|ClickOptions $options = []): void
fill()
voidfunction fill(string $value, array|FillOptions $options = []): void
type()
voidfunction type(string $value, array|TypeOptions $options = []): void
pressSequentially()
voidPress keys sequentially to type the provided text.
function pressSequentially(string $text, array|TypeOptions $options = []): void
press()
voidfunction press(string $key, array|PressOptions $options = []): void
check()
voidfunction check(array|CheckOptions $options = []): void
uncheck()
voidfunction uncheck(array|UncheckOptions $options = []): void
hover()
voidfunction hover(array|HoverOptions $options = []): void
dragTo()
voidDrag this element to target element.
function dragTo(LocatorInterface $target, array|DragToOptions $options = []): void
drop()
voidDrop files or clipboard-like data onto this element, as an external application would. The target must accept the drop by calling preventDefault() in its dragover handler, otherwise the drop is rejected and this method throws.
function drop(array|DropPayload $payload, array|DropOptions $options = []): void
dblclick()
voidfunction dblclick(array|DblClickOptions $options = []): void
clear()
voidfunction clear(array|ClearOptions $options = []): void
focus()
voidfunction focus(): void
blur()
voidfunction blur(): void
ariaSnapshot()
stringfunction ariaSnapshot(array|AriaSnapshotOptions $options = []): string
boundingBox()
?arrayfunction boundingBox(array|BoundingBoxOptions $options = []): ?array
dispatchEvent()
voidfunction dispatchEvent(string $type, mixed $eventInit = [], array|DispatchEventOptions $options = []): void
scrollIntoViewIfNeeded()
voidfunction scrollIntoViewIfNeeded(array|ScrollIntoViewIfNeededOptions $options = []): void
screenshot()
?stringfunction screenshot(?string $path = null, array|LocatorScreenshotOptions $options = []): ?string
allInnerTexts()
arrayfunction allInnerTexts(): array
allTextContents()
arrayfunction allTextContents(): array
innerHTML()
stringfunction innerHTML(): string
innerText()
stringfunction innerText(): string
inputValue()
stringfunction inputValue(): string
isAttached()
boolfunction isAttached(): bool
isChecked()
boolfunction isChecked(): bool
isDisabled()
boolfunction isDisabled(): bool
isEditable()
boolfunction isEditable(): bool
isEmpty()
boolfunction isEmpty(): bool
isEnabled()
boolfunction isEnabled(): bool
isHidden()
boolfunction isHidden(): bool
isVisible()
boolfunction isVisible(): bool
locator()
selffunction locator(string $selector): self
getByAltText()
selffunction getByAltText(string $text, array|GetByOptions $options = []): self
getByLabel()
selffunction getByLabel(string $text, array|GetByOptions $options = []): self
getByPlaceholder()
selffunction getByPlaceholder(string $text, array|GetByOptions $options = []): self
getByRole()
selffunction getByRole(string $role, array|GetByRoleOptions $options = []): self
getByTestId()
selffunction getByTestId(string $testId): self
getByText()
selffunction getByText(string $text, array|GetByOptions $options = []): self
getByTitle()
selffunction getByTitle(string $text, array|GetByOptions $options = []): self
waitFor()
voidfunction waitFor(array|WaitForOptions $options = []): void
selectOption()
arrayfunction selectOption(string|array $values, array|SelectOptionOptions $options = []): array
setInputFiles()
voidfunction setInputFiles(string|array $files, array|SetInputFilesOptions $options = []): void
textContent()
?stringfunction textContent(array|TextContentOptions $options = []): ?string
getAttribute()
?stringfunction getAttribute(string $name, array|GetAttributeOptions $options = []): ?string
count()
intfunction count(): int
all()
arrayfunction all(): array
first()
selffunction first(): self
last()
selffunction last(): self
nth()
selffunction nth(int $index): self
evaluate()
mixedfunction evaluate(string $expression, mixed $arg = null): mixed
evaluateHandle()
JSHandleInterfaceReturns a handle to the result instead of a serialized copy, so a DOM node or a live object survives the round trip. Strict: the selector has to resolve to exactly one element. Dispose the handle once done with it, otherwise it pins its target until the page closes.
function evaluateHandle(string $expression, mixed $arg = null): JSHandleInterface
waitForFunction()
selfRe-runs the expression, with the matched element as its first argument, until it returns a truthy value.
function waitForFunction(string $pageFunction, mixed $arg = null, array|WaitForFunctionOptions $options = []): self
page()
PageInterfaceThe page this locator resolves against.
function page(): PageInterface
evaluateAll()
mixedRuns the expression once over every matching element, passing them as an array. Unlike evaluate(), which targets the first match, and it does not wait for elements to appear: an empty match evaluates against an empty array.
function evaluateAll(string $expression, mixed $arg = null): mixed
highlight()
voidPaints a highlight over the matching elements until the next action. A debugging aid, visible in headed mode only; it changes nothing in the page.
function highlight(): void
hideHighlight()
voidRemoves the highlight painted by highlight().
function hideHighlight(): void
selectText()
voidfunction selectText(array|SelectTextOptions $options = []): void
setChecked()
voidfunction setChecked(bool $checked, array|SetCheckedOptions $options = []): void
tap()
voidfunction tap(array|TapOptions $options = []): void
frameLocator()
FrameLocatorInterfacefunction frameLocator(string $selector): FrameLocatorInterface
getSelector()
stringfunction getSelector(): string
filter()
selffunction filter(array|FilterOptions $options = []): self
and()
selffunction and(LocatorInterface $locator): self
or()
selffunction or(LocatorInterface $locator): self
describe()
selffunction describe(string $description): self
normalize()
selfResolves the current match into a locator built from test ids and aria roles. Turns an implementation-detail selector into a user-facing one, so it needs a live match and hits the browser.
function normalize(): self
contentFrame()
FrameLocatorInterfacefunction contentFrame(): FrameLocatorInterface