playwright package - github.com/playwright-community/playwright-go - Go Packages (original) (raw)
Package playwright is a library to automate Chromium, Firefox and WebKit with a single API. Playwright is built to enable cross-browser web automation that is ever-green, capable, reliable and fast.
- Variables
- func Bool(v bool) *bool
- func Float(v float64) *float64
- func Install(options ...*RunOptions) error
- func Int(v int) *int
- func IntSlice(v ...int) *[]int
- func Null() interface{}
- func String(v string) *string
- func StringSlice(v ...string) *[]string
- type APIRequest
- type APIRequestContext
- type APIRequestContextDeleteOptions
- type APIRequestContextDisposeOptions
- type APIRequestContextFetchOptions
- type APIRequestContextGetOptions
- type APIRequestContextHeadOptions
- type APIRequestContextPatchOptions
- type APIRequestContextPostOptions
- type APIRequestContextPutOptions
- type APIRequestNewContextOptions
- type APIResponse
- type APIResponseAssertions
- type AriaRole
- type BindingCall
- type BindingCallFunction
- type BindingSource
- type Browser
- type BrowserCloseOptions
- type BrowserContext
- type BrowserContextClearCookiesOptions
- type BrowserContextCloseOptions
- type BrowserContextExpectConsoleMessageOptions
- type BrowserContextExpectEventOptions
- type BrowserContextExpectPageOptions
- type BrowserContextGrantPermissionsOptions
- type BrowserContextRouteFromHAROptions
- type BrowserContextUnrouteAllOptions
- type BrowserContextWaitForEventOptions
- type BrowserNewContextOptions
- type BrowserNewPageOptions
- type BrowserStartTracingOptions
- type BrowserType
- type BrowserTypeConnectOptions
- type BrowserTypeConnectOverCDPOptions
- type BrowserTypeLaunchOptions
- type BrowserTypeLaunchPersistentContextOptions
- type CDPSession
- type ClientCertificate
- type Clock
- type ClockInstallOptions
- type ColorScheme
- type ConsoleMessage
- type ConsoleMessageLocation
- type Contrast
- type Cookie
- type DeviceDescriptor
- type Dialog
- type Download
- type ElementHandle
- type ElementHandleCheckOptions
- type ElementHandleClickOptions
- type ElementHandleDblclickOptions
- type ElementHandleFillOptions
- type ElementHandleHoverOptions
- type ElementHandleInputValueOptions
- type ElementHandlePressOptions
- type ElementHandleScreenshotOptions
- type ElementHandleScrollIntoViewIfNeededOptions
- type ElementHandleSelectOptionOptions
- type ElementHandleSelectTextOptions
- type ElementHandleSetCheckedOptions
- type ElementHandleSetInputFilesOptions
- type ElementHandleTapOptions
- type ElementHandleTypeOptions
- type ElementHandleUncheckOptions
- type ElementHandleWaitForElementStateOptions
- type ElementHandleWaitForSelectorOptions
- type ElementState
- type Error
- type EventEmitter
- type ExposedFunction
- type FileChooser
- type FileChooserSetFilesOptions
- type ForcedColors
- type Frame
- type FrameAddScriptTagOptions
- type FrameAddStyleTagOptions
- type FrameCheckOptions
- type FrameClickOptions
- type FrameDblclickOptions
- type FrameDispatchEventOptions
- type FrameDragAndDropOptions
- type FrameEvalOnSelectorOptions
- type FrameExpectNavigationOptions
- type FrameFillOptions
- type FrameFocusOptions
- type FrameGetAttributeOptions
- type FrameGetByAltTextOptions
- type FrameGetByLabelOptions
- type FrameGetByPlaceholderOptions
- type FrameGetByRoleOptions
- type FrameGetByTextOptions
- type FrameGetByTitleOptions
- type FrameGotoOptions
- type FrameHoverOptions
- type FrameInnerHTMLOptions
- type FrameInnerTextOptions
- type FrameInputValueOptions
- type FrameIsCheckedOptions
- type FrameIsDisabledOptions
- type FrameIsEditableOptions
- type FrameIsEnabledOptions
- type FrameIsHiddenOptions
- type FrameIsVisibleOptions
- type FrameLocator
- type FrameLocatorGetByAltTextOptions
- type FrameLocatorGetByLabelOptions
- type FrameLocatorGetByPlaceholderOptions
- type FrameLocatorGetByRoleOptions
- type FrameLocatorGetByTextOptions
- type FrameLocatorGetByTitleOptions
- type FrameLocatorLocatorOptions
- type FrameLocatorOptions
- type FramePressOptions
- type FrameQuerySelectorOptions
- type FrameSelectOptionOptions
- type FrameSetCheckedOptions
- type FrameSetContentOptions
- type FrameSetInputFilesOptions
- type FrameTapOptions
- type FrameTextContentOptions
- type FrameTypeOptions
- type FrameUncheckOptions
- type FrameWaitForFunctionOptions
- type FrameWaitForLoadStateOptions
- type FrameWaitForSelectorOptions
- type FrameWaitForURLOptions
- type Geolocation
- type HarContentPolicy
- type HarMode
- type HarNotFound
- type HttpCredentials
- type HttpCredentialsSend
- type InputFile
- type JSHandle
- type Keyboard
- type KeyboardModifier
- type KeyboardPressOptions
- type KeyboardTypeOptions
- type LoadState
- type Locator
- type LocatorAriaSnapshotOptions
- type LocatorAssertions
- type LocatorAssertionsToBeAttachedOptions
- type LocatorAssertionsToBeCheckedOptions
- type LocatorAssertionsToBeDisabledOptions
- type LocatorAssertionsToBeEditableOptions
- type LocatorAssertionsToBeEmptyOptions
- type LocatorAssertionsToBeEnabledOptions
- type LocatorAssertionsToBeFocusedOptions
- type LocatorAssertionsToBeHiddenOptions
- type LocatorAssertionsToBeInViewportOptions
- type LocatorAssertionsToBeVisibleOptions
- type LocatorAssertionsToContainClassOptions
- type LocatorAssertionsToContainTextOptions
- type LocatorAssertionsToHaveAccessibleDescriptionOptions
- type LocatorAssertionsToHaveAccessibleErrorMessageOptions
- type LocatorAssertionsToHaveAccessibleNameOptions
- type LocatorAssertionsToHaveAttributeOptions
- type LocatorAssertionsToHaveCSSOptions
- type LocatorAssertionsToHaveClassOptions
- type LocatorAssertionsToHaveCountOptions
- type LocatorAssertionsToHaveIdOptions
- type LocatorAssertionsToHaveJSPropertyOptions
- type LocatorAssertionsToHaveRoleOptions
- type LocatorAssertionsToHaveTextOptions
- type LocatorAssertionsToHaveValueOptions
- type LocatorAssertionsToHaveValuesOptions
- type LocatorAssertionsToMatchAriaSnapshotOptions
- type LocatorBlurOptions
- type LocatorBoundingBoxOptions
- type LocatorCheckOptions
- type LocatorClearOptions
- type LocatorClickOptions
- type LocatorDblclickOptions
- type LocatorDispatchEventOptions
- type LocatorDragToOptions
- type LocatorElementHandleOptions
- type LocatorEvaluateHandleOptions
- type LocatorEvaluateOptions
- type LocatorFillOptions
- type LocatorFilterOptions
- type LocatorFocusOptions
- type LocatorGetAttributeOptions
- type LocatorGetByAltTextOptions
- type LocatorGetByLabelOptions
- type LocatorGetByPlaceholderOptions
- type LocatorGetByRoleOptions
- type LocatorGetByTextOptions
- type LocatorGetByTitleOptions
- type LocatorHoverOptions
- type LocatorInnerHTMLOptions
- type LocatorInnerTextOptions
- type LocatorInputValueOptions
- type LocatorIsCheckedOptions
- type LocatorIsDisabledOptions
- type LocatorIsEditableOptions
- type LocatorIsEnabledOptions
- type LocatorIsHiddenOptions
- type LocatorIsVisibleOptions
- type LocatorLocatorOptions
- type LocatorOptions
- type LocatorPressOptions
- type LocatorPressSequentiallyOptions
- type LocatorScreenshotOptions
- type LocatorScrollIntoViewIfNeededOptions
- type LocatorSelectOptionOptions
- type LocatorSelectTextOptions
- type LocatorSetCheckedOptions
- type LocatorSetInputFilesOptions
- type LocatorTapOptions
- type LocatorTextContentOptions
- type LocatorTypeOptions
- type LocatorUncheckOptions
- type LocatorWaitForOptions
- type Margin
- type Media
- type MixedState
- type Mouse
- type MouseButton
- type MouseClickOptions
- type MouseDblclickOptions
- type MouseDownOptions
- type MouseMoveOptions
- type MouseUpOptions
- type NameValue
- type OptionalCookie
- type OptionalStorageState
- type Origin
- type Page
- type PageAddLocatorHandlerOptions
- type PageAddScriptTagOptions
- type PageAddStyleTagOptions
- type PageAssertions
- type PageAssertionsToHaveTitleOptions
- type PageAssertionsToHaveURLOptions
- type PageCheckOptions
- type PageClickOptions
- type PageCloseOptions
- type PageDblclickOptions
- type PageDispatchEventOptions
- type PageDragAndDropOptions
- type PageEmulateMediaOptions
- type PageEvalOnSelectorOptions
- type PageExpectConsoleMessageOptions
- type PageExpectDownloadOptions
- type PageExpectEventOptions
- type PageExpectFileChooserOptions
- type PageExpectNavigationOptions
- type PageExpectPopupOptions
- type PageExpectRequestFinishedOptions
- type PageExpectRequestOptions
- type PageExpectResponseOptions
- type PageExpectWebSocketOptions
- type PageExpectWorkerOptions
- type PageFillOptions
- type PageFocusOptions
- type PageFrameOptions
- type PageGetAttributeOptions
- type PageGetByAltTextOptions
- type PageGetByLabelOptions
- type PageGetByPlaceholderOptions
- type PageGetByRoleOptions
- type PageGetByTextOptions
- type PageGetByTitleOptions
- type PageGoBackOptions
- type PageGoForwardOptions
- type PageGotoOptions
- type PageHoverOptions
- type PageInnerHTMLOptions
- type PageInnerTextOptions
- type PageInputValueOptions
- type PageIsCheckedOptions
- type PageIsDisabledOptions
- type PageIsEditableOptions
- type PageIsEnabledOptions
- type PageIsHiddenOptions
- type PageIsVisibleOptions
- type PageLocatorOptions
- type PagePdfOptions
- type PagePressOptions
- type PageQuerySelectorOptions
- type PageReloadOptions
- type PageRouteFromHAROptions
- type PageScreenshotOptions
- type PageSelectOptionOptions
- type PageSetCheckedOptions
- type PageSetContentOptions
- type PageSetInputFilesOptions
- type PageTapOptions
- type PageTextContentOptions
- type PageTypeOptions
- type PageUncheckOptions
- type PageUnrouteAllOptions
- type PageWaitForEventOptions
- type PageWaitForFunctionOptions
- type PageWaitForLoadStateOptions
- type PageWaitForSelectorOptions
- type PageWaitForURLOptions
- type Playwright
- type PlaywrightAssertions
- type PlaywrightDriver
- type Position
- type Proxy
- type RecordVideo
- type Rect
- type ReducedMotion
- type Request
- type RequestSizesResult
- type RequestTiming
- type Response
- type ResponseSecurityDetailsResult
- type ResponseServerAddrResult
- type Route
- type RouteContinueOptions
- type RouteFallbackOptions
- type RouteFetchOptions
- type RouteFromHarUpdateContentPolicy
- type RouteFulfillOptions
- type RunOptions
- type SameSiteAttribute
- type ScreenshotAnimations
- type ScreenshotCaret
- type ScreenshotScale
- type ScreenshotType
- type Script
- type SelectOptionValues
- type Selectors
- type SelectorsRegisterOptions
- type ServiceWorkerPolicy
- type Size
- type StorageState
- type Touchscreen
- type Tracing
- type TracingGroupOptions
- type TracingGroupOptionsLocation
- type TracingStartChunkOptions
- type TracingStartOptions
- type UnrouteBehavior
- type Video
- type WaitForSelectorState
- type WaitUntilState
- type WebError
- type WebSocket
- type WebSocketExpectEventOptions
- type WebSocketRoute
- type WebSocketRouteCloseOptions
- type WebSocketWaitForEventOptions
- type Worker
This section is empty.
var ( MixedStateOn *MixedState = getMixedState("On") MixedStateOff = getMixedState("Off") MixedStateMixed = getMixedState("Mixed") )
var ( ElementStateVisible *ElementState = getElementState("visible") ElementStateHidden = getElementState("hidden") ElementStateStable = getElementState("stable") ElementStateEnabled = getElementState("enabled") ElementStateDisabled = getElementState("disabled") ElementStateEditable = getElementState("editable") )
var ( AriaRoleAlert *AriaRole = getAriaRole("alert") AriaRoleAlertdialog = getAriaRole("alertdialog") AriaRoleApplication = getAriaRole("application") AriaRoleArticle = getAriaRole("article") AriaRoleBlockquote = getAriaRole("blockquote") AriaRoleButton = getAriaRole("button") AriaRoleCaption = getAriaRole("caption") AriaRoleCell = getAriaRole("cell") AriaRoleCheckbox = getAriaRole("checkbox") AriaRoleCode = getAriaRole("code") AriaRoleColumnheader = getAriaRole("columnheader") AriaRoleCombobox = getAriaRole("combobox") AriaRoleComplementary = getAriaRole("complementary") AriaRoleContentinfo = getAriaRole("contentinfo") AriaRoleDefinition = getAriaRole("definition") AriaRoleDeletion = getAriaRole("deletion") AriaRoleDialog = getAriaRole("dialog") AriaRoleDirectory = getAriaRole("directory") AriaRoleDocument = getAriaRole("document") AriaRoleEmphasis = getAriaRole("emphasis") AriaRoleFeed = getAriaRole("feed") AriaRoleFigure = getAriaRole("figure") AriaRoleForm = getAriaRole("form") AriaRoleGeneric = getAriaRole("generic") AriaRoleGrid = getAriaRole("grid") AriaRoleGridcell = getAriaRole("gridcell") AriaRoleGroup = getAriaRole("group") AriaRoleHeading = getAriaRole("heading") AriaRoleImg = getAriaRole("img") AriaRoleInsertion = getAriaRole("insertion") AriaRoleLink = getAriaRole("link") AriaRoleList = getAriaRole("list") AriaRoleListbox = getAriaRole("listbox") AriaRoleListitem = getAriaRole("listitem") AriaRoleLog = getAriaRole("log") AriaRoleMain = getAriaRole("main") AriaRoleMarquee = getAriaRole("marquee") AriaRoleMath = getAriaRole("math") AriaRoleMeter = getAriaRole("meter") AriaRoleNavigation = getAriaRole("navigation") AriaRoleNone = getAriaRole("none") AriaRoleNote = getAriaRole("note") AriaRoleOption = getAriaRole("option") AriaRoleParagraph = getAriaRole("paragraph") AriaRolePresentation = getAriaRole("presentation") AriaRoleProgressbar = getAriaRole("progressbar") AriaRoleRadio = getAriaRole("radio") AriaRoleRadiogroup = getAriaRole("radiogroup") AriaRoleRegion = getAriaRole("region") AriaRoleRow = getAriaRole("row") AriaRoleRowgroup = getAriaRole("rowgroup") AriaRoleScrollbar = getAriaRole("scrollbar") AriaRoleSearch = getAriaRole("search") AriaRoleSearchbox = getAriaRole("searchbox") AriaRoleSeparator = getAriaRole("separator") AriaRoleSlider = getAriaRole("slider") AriaRoleSpinbutton = getAriaRole("spinbutton") AriaRoleStatus = getAriaRole("status") AriaRoleStrong = getAriaRole("strong") AriaRoleSubscript = getAriaRole("subscript") AriaRoleSuperscript = getAriaRole("superscript") AriaRoleSwitch = getAriaRole("switch") AriaRoleTab = getAriaRole("tab") AriaRoleTable = getAriaRole("table") AriaRoleTablist = getAriaRole("tablist") AriaRoleTabpanel = getAriaRole("tabpanel") AriaRoleTerm = getAriaRole("term") AriaRoleTextbox = getAriaRole("textbox") AriaRoleTime = getAriaRole("time") AriaRoleTimer = getAriaRole("timer") AriaRoleToolbar = getAriaRole("toolbar") AriaRoleTooltip = getAriaRole("tooltip") AriaRoleTree = getAriaRole("tree") AriaRoleTreegrid = getAriaRole("treegrid") AriaRoleTreeitem = getAriaRole("treeitem") )
var ( ColorSchemeLight *ColorScheme = getColorScheme("light") ColorSchemeDark = getColorScheme("dark") ColorSchemeNoPreference = getColorScheme("no-preference") ColorSchemeNoOverride = getColorScheme("no-override") )
var ( ForcedColorsActive *ForcedColors = getForcedColors("active") ForcedColorsNone = getForcedColors("none") ForcedColorsNoOverride = getForcedColors("no-override") )
var ( HarContentPolicyOmit *HarContentPolicy = getHarContentPolicy("omit") HarContentPolicyEmbed = getHarContentPolicy("embed") HarContentPolicyAttach = getHarContentPolicy("attach") )
var ( ReducedMotionReduce *ReducedMotion = getReducedMotion("reduce") ReducedMotionNoPreference = getReducedMotion("no-preference") ReducedMotionNoOverride = getReducedMotion("no-override") )
var ( SameSiteAttributeStrict *SameSiteAttribute = getSameSiteAttribute("Strict") SameSiteAttributeLax = getSameSiteAttribute("Lax") SameSiteAttributeNone = getSameSiteAttribute("None") )
var ( UnrouteBehaviorWait *UnrouteBehavior = getUnrouteBehavior("wait") UnrouteBehaviorIgnoreErrors = getUnrouteBehavior("ignoreErrors") UnrouteBehaviorDefault = getUnrouteBehavior("default") )
var ( MouseButtonLeft *MouseButton = getMouseButton("left") MouseButtonRight = getMouseButton("right") MouseButtonMiddle = getMouseButton("middle") )
var ( KeyboardModifierAlt *KeyboardModifier = getKeyboardModifier("Alt") KeyboardModifierControl = getKeyboardModifier("Control") KeyboardModifierControlOrMeta = getKeyboardModifier("ControlOrMeta") KeyboardModifierMeta = getKeyboardModifier("Meta") KeyboardModifierShift = getKeyboardModifier("Shift") )
var ( WaitForSelectorStateAttached *WaitForSelectorState = getWaitForSelectorState("attached") WaitForSelectorStateDetached = getWaitForSelectorState("detached") WaitForSelectorStateVisible = getWaitForSelectorState("visible") WaitForSelectorStateHidden = getWaitForSelectorState("hidden") )
var ( WaitUntilStateLoad *WaitUntilState = getWaitUntilState("load") WaitUntilStateDomcontentloaded = getWaitUntilState("domcontentloaded") WaitUntilStateNetworkidle = getWaitUntilState("networkidle") WaitUntilStateCommit = getWaitUntilState("commit") )
var ( LoadStateLoad *LoadState = getLoadState("load") LoadStateDomcontentloaded = getLoadState("domcontentloaded") LoadStateNetworkidle = getLoadState("networkidle") )
var ( ContrastNoPreference *Contrast = getContrast("no-preference") ContrastMore = getContrast("more") ContrastNoOverride = getContrast("no-override") )
var ( MediaScreen *Media = getMedia("screen") MediaPrint = getMedia("print") MediaNoOverride = getMedia("no-override") )
var ErrInputFilesSizeExceeded = errors.New("Cannot set buffer larger than 50Mb, please write it to a file and pass its path instead.")
var ( ErrLocatorNotSameFrame = errors.New("inner 'has' or 'hasNot' locator must belong to the same frame") )
Bool is a helper routine that allocates a new bool value to store v and returns a pointer to it.
Float is a helper routine that allocates a new float64 value to store v and returns a pointer to it.
func Install(options ...*RunOptions) error
Install does download the driver and the browsers.
Use this before playwright.Run() or use playwright cli to install the driver and browsers
Int is a helper routine that allocates a new int32 value to store v and returns a pointer to it.
func IntSlice(v ...int) *[]int
IntSlice is a helper routine that allocates a new IntSlice value to store v and returns a pointer to it.
Null will be used in certain scenarios where a strict nil pointer check is not possible
String is a helper routine that allocates a new string value to store v and returns a pointer to it.
StringSlice is a helper routine that allocates a new StringSlice value to store v and returns a pointer to it.
type APIRequest interface {
NewContext(options ...[APIRequestNewContextOptions](#APIRequestNewContextOptions)) ([APIRequestContext](#APIRequestContext), [error](/builtin#error))}
Exposes API that can be used for the Web API testing. This class is used for creating APIRequestContext instance which in turn can be used for sending web requests. An instance of this class can be obtained via [Playwright.Request]. For more information see APIRequestContext.
type APIRequestContext interface {
Delete(url [string](/builtin#string), options ...[APIRequestContextDeleteOptions](#APIRequestContextDeleteOptions)) ([APIResponse](#APIResponse), [error](/builtin#error))
Dispose(options ...[APIRequestContextDisposeOptions](#APIRequestContextDisposeOptions)) [error](/builtin#error)
Fetch(urlOrRequest interface{}, options ...[APIRequestContextFetchOptions](#APIRequestContextFetchOptions)) ([APIResponse](#APIResponse), [error](/builtin#error))
Get(url [string](/builtin#string), options ...[APIRequestContextGetOptions](#APIRequestContextGetOptions)) ([APIResponse](#APIResponse), [error](/builtin#error))
Head(url [string](/builtin#string), options ...[APIRequestContextHeadOptions](#APIRequestContextHeadOptions)) ([APIResponse](#APIResponse), [error](/builtin#error))
Patch(url [string](/builtin#string), options ...[APIRequestContextPatchOptions](#APIRequestContextPatchOptions)) ([APIResponse](#APIResponse), [error](/builtin#error))
Post(url [string](/builtin#string), options ...[APIRequestContextPostOptions](#APIRequestContextPostOptions)) ([APIResponse](#APIResponse), [error](/builtin#error))
Put(url [string](/builtin#string), options ...[APIRequestContextPutOptions](#APIRequestContextPutOptions)) ([APIResponse](#APIResponse), [error](/builtin#error))
StorageState(path ...[string](/builtin#string)) (*[StorageState](#StorageState), [error](/builtin#error))}
This API is used for the Web API testing. You can use it to trigger API endpoints, configure micro-services, prepare environment or the service to your e2e test. Each Playwright browser context has associated with it APIRequestContext instance which shares cookie storage with the browser context and can be accessed via [BrowserContext.Request] or [Page.Request]. It is also possible to create a new APIRequestContext instance manually by calling [APIRequest.NewContext]. **Cookie management**APIRequestContext returned by [BrowserContext.Request] and [Page.Request] shares cookie storage with the corresponding BrowserContext. Each API request will have `Cookie` header populated with the values from the browser context. If the API response contains `Set-Cookie` header it will automatically update BrowserContextcookies and requests made from the page will pick them up. This means that if you log in using this API, your e2e test will be logged in and vice versa. If you want API requests to not interfere with the browser cookies you should create a new APIRequestContext by calling [APIRequest.NewContext]. Such `APIRequestContext` object will have its own isolated cookie storage.
type APIRequestContextDeleteOptions struct {
Data interface{} `json:"data"`
FailOnStatusCode *[bool](/builtin#bool) `json:"failOnStatusCode"`
Form interface{} `json:"form"`
Headers map[[string](/builtin#string)][string](/builtin#string) `json:"headers"`
IgnoreHttpsErrors *[bool](/builtin#bool) `json:"ignoreHTTPSErrors"`
MaxRedirects *[int](/builtin#int) `json:"maxRedirects"`
MaxRetries *[int](/builtin#int) `json:"maxRetries"`
Multipart interface{} `json:"multipart"`
Params map[[string](/builtin#string)]interface{} `json:"params"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type APIRequestContextDisposeOptions struct {
Reason *[string](/builtin#string) `json:"reason"`}
type APIRequestContextFetchOptions struct {
Data interface{} `json:"data"`
FailOnStatusCode *[bool](/builtin#bool) `json:"failOnStatusCode"`
Form interface{} `json:"form"`
Headers map[[string](/builtin#string)][string](/builtin#string) `json:"headers"`
IgnoreHttpsErrors *[bool](/builtin#bool) `json:"ignoreHTTPSErrors"`
MaxRedirects *[int](/builtin#int) `json:"maxRedirects"`
MaxRetries *[int](/builtin#int) `json:"maxRetries"`
Method *[string](/builtin#string) `json:"method"`
Multipart interface{} `json:"multipart"`
Params map[[string](/builtin#string)]interface{} `json:"params"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type APIRequestContextGetOptions struct {
Data interface{} `json:"data"`
FailOnStatusCode *[bool](/builtin#bool) `json:"failOnStatusCode"`
Form interface{} `json:"form"`
Headers map[[string](/builtin#string)][string](/builtin#string) `json:"headers"`
IgnoreHttpsErrors *[bool](/builtin#bool) `json:"ignoreHTTPSErrors"`
MaxRedirects *[int](/builtin#int) `json:"maxRedirects"`
MaxRetries *[int](/builtin#int) `json:"maxRetries"`
Multipart interface{} `json:"multipart"`
Params map[[string](/builtin#string)]interface{} `json:"params"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type APIRequestContextHeadOptions struct {
Data interface{} `json:"data"`
FailOnStatusCode *[bool](/builtin#bool) `json:"failOnStatusCode"`
Form interface{} `json:"form"`
Headers map[[string](/builtin#string)][string](/builtin#string) `json:"headers"`
IgnoreHttpsErrors *[bool](/builtin#bool) `json:"ignoreHTTPSErrors"`
MaxRedirects *[int](/builtin#int) `json:"maxRedirects"`
MaxRetries *[int](/builtin#int) `json:"maxRetries"`
Multipart interface{} `json:"multipart"`
Params map[[string](/builtin#string)]interface{} `json:"params"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type APIRequestContextPatchOptions struct {
Data interface{} `json:"data"`
FailOnStatusCode *[bool](/builtin#bool) `json:"failOnStatusCode"`
Form interface{} `json:"form"`
Headers map[[string](/builtin#string)][string](/builtin#string) `json:"headers"`
IgnoreHttpsErrors *[bool](/builtin#bool) `json:"ignoreHTTPSErrors"`
MaxRedirects *[int](/builtin#int) `json:"maxRedirects"`
MaxRetries *[int](/builtin#int) `json:"maxRetries"`
Multipart interface{} `json:"multipart"`
Params map[[string](/builtin#string)]interface{} `json:"params"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type APIRequestContextPostOptions struct {
Data interface{} `json:"data"`
FailOnStatusCode *[bool](/builtin#bool) `json:"failOnStatusCode"`
Form interface{} `json:"form"`
Headers map[[string](/builtin#string)][string](/builtin#string) `json:"headers"`
IgnoreHttpsErrors *[bool](/builtin#bool) `json:"ignoreHTTPSErrors"`
MaxRedirects *[int](/builtin#int) `json:"maxRedirects"`
MaxRetries *[int](/builtin#int) `json:"maxRetries"`
Multipart interface{} `json:"multipart"`
Params map[[string](/builtin#string)]interface{} `json:"params"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type APIRequestContextPutOptions struct {
Data interface{} `json:"data"`
FailOnStatusCode *[bool](/builtin#bool) `json:"failOnStatusCode"`
Form interface{} `json:"form"`
Headers map[[string](/builtin#string)][string](/builtin#string) `json:"headers"`
IgnoreHttpsErrors *[bool](/builtin#bool) `json:"ignoreHTTPSErrors"`
MaxRedirects *[int](/builtin#int) `json:"maxRedirects"`
MaxRetries *[int](/builtin#int) `json:"maxRetries"`
Multipart interface{} `json:"multipart"`
Params map[[string](/builtin#string)]interface{} `json:"params"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type APIRequestNewContextOptions struct {
BaseURL *[string](/builtin#string) `json:"baseURL"`
ClientCertificates [][ClientCertificate](#ClientCertificate) `json:"clientCertificates"`
ExtraHttpHeaders map[[string](/builtin#string)][string](/builtin#string) `json:"extraHTTPHeaders"`
FailOnStatusCode *[bool](/builtin#bool) `json:"failOnStatusCode"`
HttpCredentials *[HttpCredentials](#HttpCredentials) `json:"httpCredentials"`
IgnoreHttpsErrors *[bool](/builtin#bool) `json:"ignoreHTTPSErrors"`
MaxRedirects *[int](/builtin#int) `json:"maxRedirects"`
Proxy *[Proxy](#Proxy) `json:"proxy"`
StorageState *[StorageState](#StorageState) `json:"storageState"`
StorageStatePath *[string](/builtin#string) `json:"storageStatePath"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
UserAgent *[string](/builtin#string) `json:"userAgent"`}
APIResponse class represents responses returned by [APIRequestContext.Get] and similar methods.
type APIResponseAssertions interface {
Not() [APIResponseAssertions](#APIResponseAssertions)
ToBeOK() [error](/builtin#error)}
The APIResponseAssertions class provides assertion methods that can be used to make assertions about theAPIResponse in the tests.
type BindingCall interface { Call(f BindingCallFunction) }
type BindingCallFunction func(source *BindingSource, args ...interface{}) interface{}
BindingCallFunction represents the func signature of an exposed binding call func
type BindingSource struct { Context BrowserContext Page Page Frame Frame }
BindingSource is the value passed to a binding call execution
type Browser interface { EventEmitter
OnDisconnected(fn func([Browser](#Browser)))
BrowserType() [BrowserType](#BrowserType)
Close(options ...[BrowserCloseOptions](#BrowserCloseOptions)) [error](/builtin#error)
Contexts() [][BrowserContext](#BrowserContext)
IsConnected() [bool](/builtin#bool)
NewBrowserCDPSession() ([CDPSession](#CDPSession), [error](/builtin#error))
NewContext(options ...[BrowserNewContextOptions](#BrowserNewContextOptions)) ([BrowserContext](#BrowserContext), [error](/builtin#error))
NewPage(options ...[BrowserNewPageOptions](#BrowserNewPageOptions)) ([Page](#Page), [error](/builtin#error))
StartTracing(options ...[BrowserStartTracingOptions](#BrowserStartTracingOptions)) [error](/builtin#error)
StopTracing() ([][byte](/builtin#byte), [error](/builtin#error))
Version() [string](/builtin#string)}
A Browser is created via [BrowserType.Launch]. An example of using a Browser to create a Page:
type BrowserCloseOptions struct {
Reason *[string](/builtin#string) `json:"reason"`}
type BrowserContext interface { EventEmitter
OnBackgroundPage(fn func([Page](#Page)))
Clock() [Clock](#Clock)
OnClose(fn func([BrowserContext](#BrowserContext)))
OnConsole(fn func([ConsoleMessage](#ConsoleMessage)))
OnDialog(fn func([Dialog](#Dialog)))
OnPage(fn func([Page](#Page)))
OnWebError(fn func([WebError](#WebError)))
OnRequest(fn func([Request](#Request)))
OnRequestFailed(fn func([Request](#Request)))
OnRequestFinished(fn func([Request](#Request)))
OnResponse(fn func([Response](#Response)))
AddCookies(cookies [][OptionalCookie](#OptionalCookie)) [error](/builtin#error)
AddInitScript(script [Script](#Script)) [error](/builtin#error)
BackgroundPages() [][Page](#Page)
Browser() [Browser](#Browser)
ClearCookies(options ...[BrowserContextClearCookiesOptions](#BrowserContextClearCookiesOptions)) [error](/builtin#error)
ClearPermissions() [error](/builtin#error)
Close(options ...[BrowserContextCloseOptions](#BrowserContextCloseOptions)) [error](/builtin#error)
Cookies(urls ...[string](/builtin#string)) ([][Cookie](#Cookie), [error](/builtin#error))
ExposeBinding(name [string](/builtin#string), binding [BindingCallFunction](#BindingCallFunction), handle ...[bool](/builtin#bool)) [error](/builtin#error)
ExposeFunction(name [string](/builtin#string), binding [ExposedFunction](#ExposedFunction)) [error](/builtin#error)
GrantPermissions(permissions [][string](/builtin#string), options ...[BrowserContextGrantPermissionsOptions](#BrowserContextGrantPermissionsOptions)) [error](/builtin#error)
NewCDPSession(page interface{}) ([CDPSession](#CDPSession), [error](/builtin#error))
NewPage() ([Page](#Page), [error](/builtin#error))
Pages() [][Page](#Page)
Request() [APIRequestContext](#APIRequestContext)
Route(url interface{}, handler routeHandler, times ...[int](/builtin#int)) [error](/builtin#error)
RouteFromHAR(har [string](/builtin#string), options ...[BrowserContextRouteFromHAROptions](#BrowserContextRouteFromHAROptions)) [error](/builtin#error)
RouteWebSocket(url interface{}, handler func([WebSocketRoute](#WebSocketRoute))) [error](/builtin#error)
ServiceWorkers() [][Worker](#Worker)
SetDefaultNavigationTimeout(timeout [float64](/builtin#float64))
SetDefaultTimeout(timeout [float64](/builtin#float64))
SetExtraHTTPHeaders(headers map[[string](/builtin#string)][string](/builtin#string)) [error](/builtin#error)
SetGeolocation(geolocation *[Geolocation](#Geolocation)) [error](/builtin#error)
SetOffline(offline [bool](/builtin#bool)) [error](/builtin#error)
StorageState(path ...[string](/builtin#string)) (*[StorageState](#StorageState), [error](/builtin#error))
Tracing() [Tracing](#Tracing)
UnrouteAll(options ...[BrowserContextUnrouteAllOptions](#BrowserContextUnrouteAllOptions)) [error](/builtin#error)
Unroute(url interface{}, handler ...routeHandler) [error](/builtin#error)
ExpectConsoleMessage(cb func() [error](/builtin#error), options ...[BrowserContextExpectConsoleMessageOptions](#BrowserContextExpectConsoleMessageOptions)) ([ConsoleMessage](#ConsoleMessage), [error](/builtin#error))
ExpectEvent(event [string](/builtin#string), cb func() [error](/builtin#error), options ...[BrowserContextExpectEventOptions](#BrowserContextExpectEventOptions)) (interface{}, [error](/builtin#error))
ExpectPage(cb func() [error](/builtin#error), options ...[BrowserContextExpectPageOptions](#BrowserContextExpectPageOptions)) ([Page](#Page), [error](/builtin#error))
WaitForEvent(event [string](/builtin#string), options ...[BrowserContextWaitForEventOptions](#BrowserContextWaitForEventOptions)) (interface{}, [error](/builtin#error))}
BrowserContexts provide a way to operate multiple independent browser sessions. If a page opens another page, e.g. with a `window.open` call, the popup will belong to the parent page's browser context. Playwright allows creating isolated non-persistent browser contexts with [Browser.NewContext] method. Non-persistent browser contexts don't write any browsing data to disk.
type BrowserContextClearCookiesOptions struct {
Domain interface{} `json:"domain"`
Name interface{} `json:"name"`
Path interface{} `json:"path"`}
type BrowserContextCloseOptions struct {
Reason *[string](/builtin#string) `json:"reason"`}
type BrowserContextExpectConsoleMessageOptions struct {
Predicate func([ConsoleMessage](#ConsoleMessage)) [bool](/builtin#bool) `json:"predicate"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type BrowserContextExpectEventOptions struct {
Predicate interface{} `json:"predicate"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type BrowserContextExpectPageOptions struct {
Predicate func([Page](#Page)) [bool](/builtin#bool) `json:"predicate"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type BrowserContextGrantPermissionsOptions struct {
Origin *[string](/builtin#string) `json:"origin"`}
type BrowserContextRouteFromHAROptions struct {
NotFound *[HarNotFound](#HarNotFound) `json:"notFound"`
Update *[bool](/builtin#bool) `json:"update"`
UpdateContent *[RouteFromHarUpdateContentPolicy](#RouteFromHarUpdateContentPolicy) `json:"updateContent"`
UpdateMode *[HarMode](#HarMode) `json:"updateMode"`
URL interface{} `json:"url"`}
type BrowserContextUnrouteAllOptions struct {
Behavior *[UnrouteBehavior](#UnrouteBehavior) `json:"behavior"`}
type BrowserContextWaitForEventOptions struct {
Predicate interface{} `json:"predicate"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type BrowserNewContextOptions struct {
AcceptDownloads *[bool](/builtin#bool) `json:"acceptDownloads"`
BaseURL *[string](/builtin#string) `json:"baseURL"`
BypassCSP *[bool](/builtin#bool) `json:"bypassCSP"`
ClientCertificates [][ClientCertificate](#ClientCertificate) `json:"clientCertificates"`
ColorScheme *[ColorScheme](#ColorScheme) `json:"colorScheme"`
DeviceScaleFactor *[float64](/builtin#float64) `json:"deviceScaleFactor"`
ExtraHttpHeaders map[[string](/builtin#string)][string](/builtin#string) `json:"extraHTTPHeaders"`
ForcedColors *[ForcedColors](#ForcedColors) `json:"forcedColors"`
Geolocation *[Geolocation](#Geolocation) `json:"geolocation"`
HasTouch *[bool](/builtin#bool) `json:"hasTouch"`
HttpCredentials *[HttpCredentials](#HttpCredentials) `json:"httpCredentials"`
IgnoreHttpsErrors *[bool](/builtin#bool) `json:"ignoreHTTPSErrors"`
IsMobile *[bool](/builtin#bool) `json:"isMobile"`
JavaScriptEnabled *[bool](/builtin#bool) `json:"javaScriptEnabled"`
Locale *[string](/builtin#string) `json:"locale"`
NoViewport *[bool](/builtin#bool) `json:"noViewport"`
Offline *[bool](/builtin#bool) `json:"offline"`
Permissions [][string](/builtin#string) `json:"permissions"`
Proxy *[Proxy](#Proxy) `json:"proxy"`
RecordHarContent *[HarContentPolicy](#HarContentPolicy) `json:"recordHarContent"`
RecordHarMode *[HarMode](#HarMode) `json:"recordHarMode"`
RecordHarOmitContent *[bool](/builtin#bool) `json:"recordHarOmitContent"`
RecordHarPath *[string](/builtin#string) `json:"recordHarPath"`
RecordHarURLFilter interface{} `json:"recordHarUrlFilter"`
RecordVideo *[RecordVideo](#RecordVideo) `json:"recordVideo"`
ReducedMotion *[ReducedMotion](#ReducedMotion) `json:"reducedMotion"`
Screen *[Size](#Size) `json:"screen"`
ServiceWorkers *[ServiceWorkerPolicy](#ServiceWorkerPolicy) `json:"serviceWorkers"`
StorageState *[OptionalStorageState](#OptionalStorageState) `json:"storageState"`
StorageStatePath *[string](/builtin#string) `json:"storageStatePath"`
StrictSelectors *[bool](/builtin#bool) `json:"strictSelectors"`
TimezoneId *[string](/builtin#string) `json:"timezoneId"`
UserAgent *[string](/builtin#string) `json:"userAgent"`
Viewport *[Size](#Size) `json:"viewport"`}
type BrowserNewPageOptions struct {
AcceptDownloads *[bool](/builtin#bool) `json:"acceptDownloads"`
BaseURL *[string](/builtin#string) `json:"baseURL"`
BypassCSP *[bool](/builtin#bool) `json:"bypassCSP"`
ClientCertificates [][ClientCertificate](#ClientCertificate) `json:"clientCertificates"`
ColorScheme *[ColorScheme](#ColorScheme) `json:"colorScheme"`
DeviceScaleFactor *[float64](/builtin#float64) `json:"deviceScaleFactor"`
ExtraHttpHeaders map[[string](/builtin#string)][string](/builtin#string) `json:"extraHTTPHeaders"`
ForcedColors *[ForcedColors](#ForcedColors) `json:"forcedColors"`
Geolocation *[Geolocation](#Geolocation) `json:"geolocation"`
HasTouch *[bool](/builtin#bool) `json:"hasTouch"`
HttpCredentials *[HttpCredentials](#HttpCredentials) `json:"httpCredentials"`
IgnoreHttpsErrors *[bool](/builtin#bool) `json:"ignoreHTTPSErrors"`
IsMobile *[bool](/builtin#bool) `json:"isMobile"`
JavaScriptEnabled *[bool](/builtin#bool) `json:"javaScriptEnabled"`
Locale *[string](/builtin#string) `json:"locale"`
NoViewport *[bool](/builtin#bool) `json:"noViewport"`
Offline *[bool](/builtin#bool) `json:"offline"`
Permissions [][string](/builtin#string) `json:"permissions"`
Proxy *[Proxy](#Proxy) `json:"proxy"`
RecordHarContent *[HarContentPolicy](#HarContentPolicy) `json:"recordHarContent"`
RecordHarMode *[HarMode](#HarMode) `json:"recordHarMode"`
RecordHarOmitContent *[bool](/builtin#bool) `json:"recordHarOmitContent"`
RecordHarPath *[string](/builtin#string) `json:"recordHarPath"`
RecordHarURLFilter interface{} `json:"recordHarUrlFilter"`
RecordVideo *[RecordVideo](#RecordVideo) `json:"recordVideo"`
ReducedMotion *[ReducedMotion](#ReducedMotion) `json:"reducedMotion"`
Screen *[Size](#Size) `json:"screen"`
ServiceWorkers *[ServiceWorkerPolicy](#ServiceWorkerPolicy) `json:"serviceWorkers"`
StorageState *[OptionalStorageState](#OptionalStorageState) `json:"storageState"`
StorageStatePath *[string](/builtin#string) `json:"storageStatePath"`
StrictSelectors *[bool](/builtin#bool) `json:"strictSelectors"`
TimezoneId *[string](/builtin#string) `json:"timezoneId"`
UserAgent *[string](/builtin#string) `json:"userAgent"`
Viewport *[Size](#Size) `json:"viewport"`}
type BrowserStartTracingOptions struct {
Categories [][string](/builtin#string) `json:"categories"`
Page [Page](#Page) `json:"page"`
Path *[string](/builtin#string) `json:"path"`
Screenshots *[bool](/builtin#bool) `json:"screenshots"`}
BrowserType provides methods to launch a specific browser instance or connect to an existing one. The following is a typical example of using Playwright to drive automation:
type BrowserTypeConnectOptions struct {
ExposeNetwork *[string](/builtin#string) `json:"exposeNetwork"`
Headers map[[string](/builtin#string)][string](/builtin#string) `json:"headers"`
SlowMo *[float64](/builtin#float64) `json:"slowMo"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type BrowserTypeConnectOverCDPOptions struct {
Headers map[string]string json:"headers"
SlowMo *[float64](/builtin#float64) `json:"slowMo"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type BrowserTypeLaunchOptions struct {
Args [][string](/builtin#string) `json:"args"`
Channel *[string](/builtin#string) `json:"channel"`
ChromiumSandbox *[bool](/builtin#bool) `json:"chromiumSandbox"`
Devtools *[bool](/builtin#bool) `json:"devtools"`
DownloadsPath *[string](/builtin#string) `json:"downloadsPath"`
Env map[[string](/builtin#string)][string](/builtin#string) `json:"env"`
ExecutablePath *[string](/builtin#string) `json:"executablePath"`
FirefoxUserPrefs map[[string](/builtin#string)]interface{} `json:"firefoxUserPrefs"`
HandleSIGHUP *[bool](/builtin#bool) `json:"handleSIGHUP"`
HandleSIGINT *[bool](/builtin#bool) `json:"handleSIGINT"`
HandleSIGTERM *[bool](/builtin#bool) `json:"handleSIGTERM"`
Headless *[bool](/builtin#bool) `json:"headless"`
IgnoreAllDefaultArgs *[bool](/builtin#bool) `json:"ignoreAllDefaultArgs"`
IgnoreDefaultArgs [][string](/builtin#string) `json:"ignoreDefaultArgs"`
Proxy *[Proxy](#Proxy) `json:"proxy"`
SlowMo *[float64](/builtin#float64) `json:"slowMo"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
TracesDir *[string](/builtin#string) `json:"tracesDir"`}
type BrowserTypeLaunchPersistentContextOptions struct {
AcceptDownloads *[bool](/builtin#bool) `json:"acceptDownloads"`
Args [][string](/builtin#string) `json:"args"`
BaseURL *[string](/builtin#string) `json:"baseURL"`
BypassCSP *[bool](/builtin#bool) `json:"bypassCSP"`
Channel *[string](/builtin#string) `json:"channel"`
ChromiumSandbox *[bool](/builtin#bool) `json:"chromiumSandbox"`
ClientCertificates [][ClientCertificate](#ClientCertificate) `json:"clientCertificates"`
ColorScheme *[ColorScheme](#ColorScheme) `json:"colorScheme"`
DeviceScaleFactor *[float64](/builtin#float64) `json:"deviceScaleFactor"`
Devtools *[bool](/builtin#bool) `json:"devtools"`
DownloadsPath *[string](/builtin#string) `json:"downloadsPath"`
Env map[[string](/builtin#string)][string](/builtin#string) `json:"env"`
ExecutablePath *[string](/builtin#string) `json:"executablePath"`
ExtraHttpHeaders map[[string](/builtin#string)][string](/builtin#string) `json:"extraHTTPHeaders"`
FirefoxUserPrefs map[[string](/builtin#string)]interface{} `json:"firefoxUserPrefs"`
ForcedColors *[ForcedColors](#ForcedColors) `json:"forcedColors"`
Geolocation *[Geolocation](#Geolocation) `json:"geolocation"`
HandleSIGHUP *[bool](/builtin#bool) `json:"handleSIGHUP"`
HandleSIGINT *[bool](/builtin#bool) `json:"handleSIGINT"`
HandleSIGTERM *[bool](/builtin#bool) `json:"handleSIGTERM"`
HasTouch *[bool](/builtin#bool) `json:"hasTouch"`
Headless *[bool](/builtin#bool) `json:"headless"`
HttpCredentials *[HttpCredentials](#HttpCredentials) `json:"httpCredentials"`
IgnoreAllDefaultArgs *[bool](/builtin#bool) `json:"ignoreAllDefaultArgs"`
IgnoreDefaultArgs [][string](/builtin#string) `json:"ignoreDefaultArgs"`
IgnoreHttpsErrors *[bool](/builtin#bool) `json:"ignoreHTTPSErrors"`
IsMobile *[bool](/builtin#bool) `json:"isMobile"`
JavaScriptEnabled *[bool](/builtin#bool) `json:"javaScriptEnabled"`
Locale *[string](/builtin#string) `json:"locale"`
NoViewport *[bool](/builtin#bool) `json:"noViewport"`
Offline *[bool](/builtin#bool) `json:"offline"`
Permissions [][string](/builtin#string) `json:"permissions"`
Proxy *[Proxy](#Proxy) `json:"proxy"`
RecordHarContent *[HarContentPolicy](#HarContentPolicy) `json:"recordHarContent"`
RecordHarMode *[HarMode](#HarMode) `json:"recordHarMode"`
RecordHarOmitContent *[bool](/builtin#bool) `json:"recordHarOmitContent"`
RecordHarPath *[string](/builtin#string) `json:"recordHarPath"`
RecordHarURLFilter interface{} `json:"recordHarUrlFilter"`
RecordVideo *[RecordVideo](#RecordVideo) `json:"recordVideo"`
ReducedMotion *[ReducedMotion](#ReducedMotion) `json:"reducedMotion"`
Screen *[Size](#Size) `json:"screen"`
ServiceWorkers *[ServiceWorkerPolicy](#ServiceWorkerPolicy) `json:"serviceWorkers"`
SlowMo *[float64](/builtin#float64) `json:"slowMo"`
StrictSelectors *[bool](/builtin#bool) `json:"strictSelectors"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
TimezoneId *[string](/builtin#string) `json:"timezoneId"`
TracesDir *[string](/builtin#string) `json:"tracesDir"`
UserAgent *[string](/builtin#string) `json:"userAgent"`
Viewport *[Size](#Size) `json:"viewport"`}
type ClientCertificate struct {
Origin [string](/builtin#string) `json:"origin"`
CertPath *[string](/builtin#string) `json:"certPath"`
Cert [][byte](/builtin#byte) `json:"cert"`
KeyPath *[string](/builtin#string) `json:"keyPath"`
Key [][byte](/builtin#byte) `json:"key"`
PfxPath *[string](/builtin#string) `json:"pfxPath"`
Pfx [][byte](/builtin#byte) `json:"pfx"`
Passphrase *[string](/builtin#string) `json:"passphrase"`}
type Clock interface {
FastForward(ticks interface{}) [error](/builtin#error)
Install(options ...[ClockInstallOptions](#ClockInstallOptions)) [error](/builtin#error)
RunFor(ticks interface{}) [error](/builtin#error)
PauseAt(time interface{}) [error](/builtin#error)
Resume() [error](/builtin#error)
SetFixedTime(time interface{}) [error](/builtin#error)
SetSystemTime(time interface{}) [error](/builtin#error)}
Accurately simulating time-dependent behavior is essential for verifying the correctness of applications. Learn more about clock emulation. Note that clock is installed for the entire BrowserContext, so the time in all the pages and iframes is controlled by the same clock.
type ClockInstallOptions struct {
Time interface{} `json:"time"`}
type ConsoleMessage interface {
Args() [][JSHandle](#JSHandle)
Location() *[ConsoleMessageLocation](#ConsoleMessageLocation)
Page() [Page](#Page)
Text() [string](/builtin#string)
String() [string](/builtin#string)
Type() [string](/builtin#string)}
ConsoleMessage objects are dispatched by page via the [Page.OnConsole] event. For each console message logged in the page there will be corresponding event in the Playwright context.
type ConsoleMessageLocation struct {
URL [string](/builtin#string) `json:"url"`
LineNumber [int](/builtin#int) `json:"lineNumber"`
ColumnNumber [int](/builtin#int) `json:"columnNumber"`}
type Cookie struct {
Name string json:"name"
Value string json:"value"
Domain string json:"domain"
Path string json:"path"
Expires [float64](/builtin#float64) `json:"expires"`
HttpOnly [bool](/builtin#bool) `json:"httpOnly"`
Secure [bool](/builtin#bool) `json:"secure"`
SameSite *[SameSiteAttribute](#SameSiteAttribute) `json:"sameSite"`}
func (c Cookie) ToOptionalCookie() OptionalCookie
type DeviceDescriptor struct {
UserAgent string json:"userAgent"
Viewport *Size json:"viewport"
Screen *Size json:"screen"
DeviceScaleFactor float64 json:"deviceScaleFactor"
IsMobile bool json:"isMobile"
HasTouch bool json:"hasTouch"
DefaultBrowserType string json:"defaultBrowserType"
}
DeviceDescriptor represents a single device
Dialog objects are dispatched by page via the [Page.OnDialog] event. An example of using `Dialog` class: **NOTE** Dialogs are dismissed automatically, unless there is a [Page.OnDialog] listener. When listener is present, it **must** either [Dialog.Accept] or [Dialog.Dismiss] the dialog - otherwise the page willfreeze waiting for the dialog, and actions like click will never finish.
Download objects are dispatched by page via the [Page.OnDownload] event. All the downloaded files belonging to the browser context are deleted when the browser context is closed. Download event is emitted once the download starts. Download path becomes available once download completes.
type ElementHandle ¶
type ElementHandle interface { JSHandle
BoundingBox() (*[Rect](#Rect), [error](/builtin#error))
Check(options ...[ElementHandleCheckOptions](#ElementHandleCheckOptions)) [error](/builtin#error)
Click(options ...[ElementHandleClickOptions](#ElementHandleClickOptions)) [error](/builtin#error)
ContentFrame() ([Frame](#Frame), [error](/builtin#error))
Dblclick(options ...[ElementHandleDblclickOptions](#ElementHandleDblclickOptions)) [error](/builtin#error)
DispatchEvent(typ [string](/builtin#string), eventInit ...interface{}) [error](/builtin#error)
EvalOnSelector(selector [string](/builtin#string), expression [string](/builtin#string), arg ...interface{}) (interface{}, [error](/builtin#error))
EvalOnSelectorAll(selector [string](/builtin#string), expression [string](/builtin#string), arg ...interface{}) (interface{}, [error](/builtin#error))
Fill(value [string](/builtin#string), options ...[ElementHandleFillOptions](#ElementHandleFillOptions)) [error](/builtin#error)
Focus() [error](/builtin#error)
GetAttribute(name [string](/builtin#string)) ([string](/builtin#string), [error](/builtin#error))
Hover(options ...[ElementHandleHoverOptions](#ElementHandleHoverOptions)) [error](/builtin#error)
InnerHTML() ([string](/builtin#string), [error](/builtin#error))
InnerText() ([string](/builtin#string), [error](/builtin#error))
InputValue(options ...[ElementHandleInputValueOptions](#ElementHandleInputValueOptions)) ([string](/builtin#string), [error](/builtin#error))
IsChecked() ([bool](/builtin#bool), [error](/builtin#error))
IsDisabled() ([bool](/builtin#bool), [error](/builtin#error))
IsEditable() ([bool](/builtin#bool), [error](/builtin#error))
IsEnabled() ([bool](/builtin#bool), [error](/builtin#error))
IsHidden() ([bool](/builtin#bool), [error](/builtin#error))
IsVisible() ([bool](/builtin#bool), [error](/builtin#error))
OwnerFrame() ([Frame](#Frame), [error](/builtin#error))
Press(key [string](/builtin#string), options ...[ElementHandlePressOptions](#ElementHandlePressOptions)) [error](/builtin#error)
QuerySelector(selector [string](/builtin#string)) ([ElementHandle](#ElementHandle), [error](/builtin#error))
QuerySelectorAll(selector [string](/builtin#string)) ([][ElementHandle](#ElementHandle), [error](/builtin#error))
Screenshot(options ...[ElementHandleScreenshotOptions](#ElementHandleScreenshotOptions)) ([][byte](/builtin#byte), [error](/builtin#error))
ScrollIntoViewIfNeeded(options ...[ElementHandleScrollIntoViewIfNeededOptions](#ElementHandleScrollIntoViewIfNeededOptions)) [error](/builtin#error)
SelectOption(values [SelectOptionValues](#SelectOptionValues), options ...[ElementHandleSelectOptionOptions](#ElementHandleSelectOptionOptions)) ([][string](/builtin#string), [error](/builtin#error))
SelectText(options ...[ElementHandleSelectTextOptions](#ElementHandleSelectTextOptions)) [error](/builtin#error)
SetChecked(checked [bool](/builtin#bool), options ...[ElementHandleSetCheckedOptions](#ElementHandleSetCheckedOptions)) [error](/builtin#error)
SetInputFiles(files interface{}, options ...[ElementHandleSetInputFilesOptions](#ElementHandleSetInputFilesOptions)) [error](/builtin#error)
Tap(options ...[ElementHandleTapOptions](#ElementHandleTapOptions)) [error](/builtin#error)
TextContent() ([string](/builtin#string), [error](/builtin#error))
Type(text [string](/builtin#string), options ...[ElementHandleTypeOptions](#ElementHandleTypeOptions)) [error](/builtin#error)
Uncheck(options ...[ElementHandleUncheckOptions](#ElementHandleUncheckOptions)) [error](/builtin#error)
WaitForElementState(state [ElementState](#ElementState), options ...[ElementHandleWaitForElementStateOptions](#ElementHandleWaitForElementStateOptions)) [error](/builtin#error)
WaitForSelector(selector [string](/builtin#string), options ...[ElementHandleWaitForSelectorOptions](#ElementHandleWaitForSelectorOptions)) ([ElementHandle](#ElementHandle), [error](/builtin#error))}
ElementHandle represents an in-page DOM element. ElementHandles can be created with the [Page.QuerySelector]
method. **NOTE** The use of ElementHandle is discouraged, use Locator objects and web-first assertions instead. ElementHandle prevents DOM element from garbage collection unless the handle is disposed with [JSHandle.Dispose]. ElementHandles are auto-disposed when their origin frame gets navigated. ElementHandle instances can be used as an argument in [Page.EvalOnSelector] and [Page.Evaluate] methods. The difference between the Locator and ElementHandle is that the ElementHandle points to a particular element, while Locator captures the logic of how to retrieve an element. In the example below, handle points to a particular DOM element on page. If that element changes text or is used by React to render an entirely different component, handle is still pointing to that very DOM element. This can lead to unexpected behaviors. With the locator, every time the `element` is used, up-to-date DOM element is located in the page using the selector. So in the snippet below, underlying DOM element is going to be located twice.
type ElementHandleCheckOptions ¶
type ElementHandleCheckOptions struct {
Force *[bool](/builtin#bool) `json:"force"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Position *[Position](#Position) `json:"position"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
Trial *[bool](/builtin#bool) `json:"trial"`}
type ElementHandleClickOptions ¶
type ElementHandleClickOptions struct {
Button *[MouseButton](#MouseButton) `json:"button"`
ClickCount *[int](/builtin#int) `json:"clickCount"`
Delay *[float64](/builtin#float64) `json:"delay"`
Force *[bool](/builtin#bool) `json:"force"`
Modifiers [][KeyboardModifier](#KeyboardModifier) `json:"modifiers"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Position *[Position](#Position) `json:"position"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
Trial *[bool](/builtin#bool) `json:"trial"`}
type ElementHandleDblclickOptions ¶
type ElementHandleDblclickOptions struct {
Button *[MouseButton](#MouseButton) `json:"button"`
Delay *[float64](/builtin#float64) `json:"delay"`
Force *[bool](/builtin#bool) `json:"force"`
Modifiers [][KeyboardModifier](#KeyboardModifier) `json:"modifiers"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Position *[Position](#Position) `json:"position"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
Trial *[bool](/builtin#bool) `json:"trial"`}
type ElementHandleHoverOptions ¶
type ElementHandleHoverOptions struct {
Force *[bool](/builtin#bool) `json:"force"`
Modifiers [][KeyboardModifier](#KeyboardModifier) `json:"modifiers"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Position *[Position](#Position) `json:"position"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
Trial *[bool](/builtin#bool) `json:"trial"`}
type ElementHandleScreenshotOptions ¶
type ElementHandleScreenshotOptions struct {
Animations *[ScreenshotAnimations](#ScreenshotAnimations) `json:"animations"`
Caret *[ScreenshotCaret](#ScreenshotCaret) `json:"caret"`
Mask [][Locator](#Locator) `json:"mask"`
MaskColor *[string](/builtin#string) `json:"maskColor"`
OmitBackground *[bool](/builtin#bool) `json:"omitBackground"`
Path *[string](/builtin#string) `json:"path"`
Quality *[int](/builtin#int) `json:"quality"`
Scale *[ScreenshotScale](#ScreenshotScale) `json:"scale"`
Style *[string](/builtin#string) `json:"style"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
Type *[ScreenshotType](#ScreenshotType) `json:"type"`}
type ElementHandleTapOptions ¶
type ElementHandleTapOptions struct {
Force *[bool](/builtin#bool) `json:"force"`
Modifiers [][KeyboardModifier](#KeyboardModifier) `json:"modifiers"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Position *[Position](#Position) `json:"position"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
Trial *[bool](/builtin#bool) `json:"trial"`}
type Error struct {
Name string json:"name"
Message string json:"message"
Stack string json:"stack"
}
Error represents a Playwright error
type EventEmitter interface { Emit(name string, payload ...interface{}) bool ListenerCount(name string) int On(name string, handler interface{}) Once(name string, handler interface{}) RemoveListener(name string, handler interface{}) RemoveListeners(name string) }
func NewEventEmitter() EventEmitter
type ExposedFunction = func(args ...interface{}) interface{}
ExposedFunction represents the func signature of an exposed function
type FileChooser interface {
Element() [ElementHandle](#ElementHandle)
IsMultiple() [bool](/builtin#bool)
Page() [Page](#Page)
SetFiles(files interface{}, options ...[FileChooserSetFilesOptions](#FileChooserSetFilesOptions)) [error](/builtin#error)}
FileChooser objects are dispatched by the page in the [Page.OnFileChooser] event.
type FileChooserSetFilesOptions struct {
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type Frame interface {
AddScriptTag(options [FrameAddScriptTagOptions](#FrameAddScriptTagOptions)) ([ElementHandle](#ElementHandle), [error](/builtin#error))
AddStyleTag(options [FrameAddStyleTagOptions](#FrameAddStyleTagOptions)) ([ElementHandle](#ElementHandle), [error](/builtin#error))
Check(selector [string](/builtin#string), options ...[FrameCheckOptions](#FrameCheckOptions)) [error](/builtin#error)
ChildFrames() [][Frame](#Frame)
Click(selector [string](/builtin#string), options ...[FrameClickOptions](#FrameClickOptions)) [error](/builtin#error)
Content() ([string](/builtin#string), [error](/builtin#error))
Dblclick(selector [string](/builtin#string), options ...[FrameDblclickOptions](#FrameDblclickOptions)) [error](/builtin#error)
DispatchEvent(selector [string](/builtin#string), typ [string](/builtin#string), eventInit interface{}, options ...[FrameDispatchEventOptions](#FrameDispatchEventOptions)) [error](/builtin#error)
DragAndDrop(source [string](/builtin#string), target [string](/builtin#string), options ...[FrameDragAndDropOptions](#FrameDragAndDropOptions)) [error](/builtin#error)
EvalOnSelector(selector [string](/builtin#string), expression [string](/builtin#string), arg interface{}, options ...[FrameEvalOnSelectorOptions](#FrameEvalOnSelectorOptions)) (interface{}, [error](/builtin#error))
EvalOnSelectorAll(selector [string](/builtin#string), expression [string](/builtin#string), arg ...interface{}) (interface{}, [error](/builtin#error))
Evaluate(expression [string](/builtin#string), arg ...interface{}) (interface{}, [error](/builtin#error))
EvaluateHandle(expression [string](/builtin#string), arg ...interface{}) ([JSHandle](#JSHandle), [error](/builtin#error))
Fill(selector [string](/builtin#string), value [string](/builtin#string), options ...[FrameFillOptions](#FrameFillOptions)) [error](/builtin#error)
Focus(selector [string](/builtin#string), options ...[FrameFocusOptions](#FrameFocusOptions)) [error](/builtin#error)
FrameElement() ([ElementHandle](#ElementHandle), [error](/builtin#error))
FrameLocator(selector [string](/builtin#string)) [FrameLocator](#FrameLocator)
GetAttribute(selector [string](/builtin#string), name [string](/builtin#string), options ...[FrameGetAttributeOptions](#FrameGetAttributeOptions)) ([string](/builtin#string), [error](/builtin#error))
GetByAltText(text interface{}, options ...[FrameGetByAltTextOptions](#FrameGetByAltTextOptions)) [Locator](#Locator)
GetByLabel(text interface{}, options ...[FrameGetByLabelOptions](#FrameGetByLabelOptions)) [Locator](#Locator)
GetByPlaceholder(text interface{}, options ...[FrameGetByPlaceholderOptions](#FrameGetByPlaceholderOptions)) [Locator](#Locator)
GetByRole(role [AriaRole](#AriaRole), options ...[FrameGetByRoleOptions](#FrameGetByRoleOptions)) [Locator](#Locator)
GetByTestId(testId interface{}) [Locator](#Locator)
GetByText(text interface{}, options ...[FrameGetByTextOptions](#FrameGetByTextOptions)) [Locator](#Locator)
GetByTitle(text interface{}, options ...[FrameGetByTitleOptions](#FrameGetByTitleOptions)) [Locator](#Locator)
Goto(url [string](/builtin#string), options ...[FrameGotoOptions](#FrameGotoOptions)) ([Response](#Response), [error](/builtin#error))
Hover(selector [string](/builtin#string), options ...[FrameHoverOptions](#FrameHoverOptions)) [error](/builtin#error)
InnerHTML(selector [string](/builtin#string), options ...[FrameInnerHTMLOptions](#FrameInnerHTMLOptions)) ([string](/builtin#string), [error](/builtin#error))
InnerText(selector [string](/builtin#string), options ...[FrameInnerTextOptions](#FrameInnerTextOptions)) ([string](/builtin#string), [error](/builtin#error))
InputValue(selector [string](/builtin#string), options ...[FrameInputValueOptions](#FrameInputValueOptions)) ([string](/builtin#string), [error](/builtin#error))
IsChecked(selector [string](/builtin#string), options ...[FrameIsCheckedOptions](#FrameIsCheckedOptions)) ([bool](/builtin#bool), [error](/builtin#error))
IsDetached() [bool](/builtin#bool)
IsDisabled(selector [string](/builtin#string), options ...[FrameIsDisabledOptions](#FrameIsDisabledOptions)) ([bool](/builtin#bool), [error](/builtin#error))
IsEditable(selector [string](/builtin#string), options ...[FrameIsEditableOptions](#FrameIsEditableOptions)) ([bool](/builtin#bool), [error](/builtin#error))
IsEnabled(selector [string](/builtin#string), options ...[FrameIsEnabledOptions](#FrameIsEnabledOptions)) ([bool](/builtin#bool), [error](/builtin#error))
IsHidden(selector [string](/builtin#string), options ...[FrameIsHiddenOptions](#FrameIsHiddenOptions)) ([bool](/builtin#bool), [error](/builtin#error))
IsVisible(selector [string](/builtin#string), options ...[FrameIsVisibleOptions](#FrameIsVisibleOptions)) ([bool](/builtin#bool), [error](/builtin#error))
Locator(selector [string](/builtin#string), options ...[FrameLocatorOptions](#FrameLocatorOptions)) [Locator](#Locator)
Name() [string](/builtin#string)
Page() [Page](#Page)
ParentFrame() [Frame](#Frame)
Press(selector [string](/builtin#string), key [string](/builtin#string), options ...[FramePressOptions](#FramePressOptions)) [error](/builtin#error)
QuerySelector(selector [string](/builtin#string), options ...[FrameQuerySelectorOptions](#FrameQuerySelectorOptions)) ([ElementHandle](#ElementHandle), [error](/builtin#error))
QuerySelectorAll(selector [string](/builtin#string)) ([][ElementHandle](#ElementHandle), [error](/builtin#error))
SelectOption(selector [string](/builtin#string), values [SelectOptionValues](#SelectOptionValues), options ...[FrameSelectOptionOptions](#FrameSelectOptionOptions)) ([][string](/builtin#string), [error](/builtin#error))
SetChecked(selector [string](/builtin#string), checked [bool](/builtin#bool), options ...[FrameSetCheckedOptions](#FrameSetCheckedOptions)) [error](/builtin#error)
SetContent(html [string](/builtin#string), options ...[FrameSetContentOptions](#FrameSetContentOptions)) [error](/builtin#error)
SetInputFiles(selector [string](/builtin#string), files interface{}, options ...[FrameSetInputFilesOptions](#FrameSetInputFilesOptions)) [error](/builtin#error)
Tap(selector [string](/builtin#string), options ...[FrameTapOptions](#FrameTapOptions)) [error](/builtin#error)
TextContent(selector [string](/builtin#string), options ...[FrameTextContentOptions](#FrameTextContentOptions)) ([string](/builtin#string), [error](/builtin#error))
Title() ([string](/builtin#string), [error](/builtin#error))
Type(selector [string](/builtin#string), text [string](/builtin#string), options ...[FrameTypeOptions](#FrameTypeOptions)) [error](/builtin#error)
Uncheck(selector [string](/builtin#string), options ...[FrameUncheckOptions](#FrameUncheckOptions)) [error](/builtin#error)
URL() [string](/builtin#string)
WaitForFunction(expression [string](/builtin#string), arg interface{}, options ...[FrameWaitForFunctionOptions](#FrameWaitForFunctionOptions)) ([JSHandle](#JSHandle), [error](/builtin#error))
WaitForLoadState(options ...[FrameWaitForLoadStateOptions](#FrameWaitForLoadStateOptions)) [error](/builtin#error)
ExpectNavigation(cb func() [error](/builtin#error), options ...[FrameExpectNavigationOptions](#FrameExpectNavigationOptions)) ([Response](#Response), [error](/builtin#error))
WaitForSelector(selector [string](/builtin#string), options ...[FrameWaitForSelectorOptions](#FrameWaitForSelectorOptions)) ([ElementHandle](#ElementHandle), [error](/builtin#error))
WaitForTimeout(timeout [float64](/builtin#float64))
WaitForURL(url interface{}, options ...[FrameWaitForURLOptions](#FrameWaitForURLOptions)) [error](/builtin#error)}
At every point of time, page exposes its current frame tree via the [Page.MainFrame] and [Frame.ChildFrames] methods.Frame object's lifecycle is controlled by three events, dispatched on the page object:
- [Page.OnFrameAttached] - fired when the frame gets attached to the page. A Frame can be attached to the page only once.
- [Page.OnFrameNavigated] - fired when the frame commits navigation to a different URL.
- [Page.OnFrameDetached] - fired when the frame gets detached from the page. A Frame can be detached from the page only once.
An example of dumping frame tree:
type FrameAddScriptTagOptions struct {
Content *[string](/builtin#string) `json:"content"`
Path *[string](/builtin#string) `json:"path"`
Type *[string](/builtin#string) `json:"type"`
URL *[string](/builtin#string) `json:"url"`}
type FrameAddStyleTagOptions struct {
Content *[string](/builtin#string) `json:"content"`
Path *[string](/builtin#string) `json:"path"`
URL *[string](/builtin#string) `json:"url"`}
type FrameCheckOptions struct {
Force *[bool](/builtin#bool) `json:"force"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Position *[Position](#Position) `json:"position"`
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
Trial *[bool](/builtin#bool) `json:"trial"`}
type FrameClickOptions struct {
Button *[MouseButton](#MouseButton) `json:"button"`
ClickCount *[int](/builtin#int) `json:"clickCount"`
Delay *[float64](/builtin#float64) `json:"delay"`
Force *[bool](/builtin#bool) `json:"force"`
Modifiers [][KeyboardModifier](#KeyboardModifier) `json:"modifiers"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Position *[Position](#Position) `json:"position"`
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
Trial *[bool](/builtin#bool) `json:"trial"`}
type FrameDblclickOptions struct {
Button *[MouseButton](#MouseButton) `json:"button"`
Delay *[float64](/builtin#float64) `json:"delay"`
Force *[bool](/builtin#bool) `json:"force"`
Modifiers [][KeyboardModifier](#KeyboardModifier) `json:"modifiers"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Position *[Position](#Position) `json:"position"`
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
Trial *[bool](/builtin#bool) `json:"trial"`}
type FrameDispatchEventOptions struct {
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type FrameDragAndDropOptions ¶
type FrameDragAndDropOptions struct {
Force *[bool](/builtin#bool) `json:"force"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
SourcePosition *[Position](#Position) `json:"sourcePosition"`
Strict *[bool](/builtin#bool) `json:"strict"`
TargetPosition *[Position](#Position) `json:"targetPosition"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
Trial *[bool](/builtin#bool) `json:"trial"`}
type FrameEvalOnSelectorOptions struct {
Strict *[bool](/builtin#bool) `json:"strict"`}
type FrameExpectNavigationOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`
URL interface{} `json:"url"`
WaitUntil *[WaitUntilState](#WaitUntilState) `json:"waitUntil"`}
type FrameFillOptions struct {
Force *[bool](/builtin#bool) `json:"force"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type FrameFocusOptions struct {
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type FrameGetAttributeOptions struct {
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type FrameGetByAltTextOptions struct {
Exact *[bool](/builtin#bool) `json:"exact"`}
type FrameGetByLabelOptions struct {
Exact *[bool](/builtin#bool) `json:"exact"`}
type FrameGetByPlaceholderOptions struct {
Exact *[bool](/builtin#bool) `json:"exact"`}
type FrameGetByRoleOptions struct {
Checked *[bool](/builtin#bool) `json:"checked"`
Disabled *[bool](/builtin#bool) `json:"disabled"`
Exact *[bool](/builtin#bool) `json:"exact"`
Expanded *[bool](/builtin#bool) `json:"expanded"`
IncludeHidden *[bool](/builtin#bool) `json:"includeHidden"`
Level *[int](/builtin#int) `json:"level"`
Name interface{} `json:"name"`
Pressed *[bool](/builtin#bool) `json:"pressed"`
Selected *[bool](/builtin#bool) `json:"selected"`}
type FrameGetByTextOptions struct {
Exact *[bool](/builtin#bool) `json:"exact"`}
type FrameGetByTitleOptions struct {
Exact *[bool](/builtin#bool) `json:"exact"`}
type FrameGotoOptions struct {
Referer *[string](/builtin#string) `json:"referer"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
WaitUntil *[WaitUntilState](#WaitUntilState) `json:"waitUntil"`}
type FrameHoverOptions struct {
Force *[bool](/builtin#bool) `json:"force"`
Modifiers [][KeyboardModifier](#KeyboardModifier) `json:"modifiers"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Position *[Position](#Position) `json:"position"`
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
Trial *[bool](/builtin#bool) `json:"trial"`}
type FrameInnerHTMLOptions struct {
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type FrameInnerTextOptions struct {
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type FrameInputValueOptions struct {
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type FrameIsCheckedOptions struct {
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type FrameIsDisabledOptions struct {
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type FrameIsEditableOptions struct {
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type FrameIsEnabledOptions struct {
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type FrameIsHiddenOptions struct {
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type FrameIsVisibleOptions struct {
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type FrameLocator interface {
First() [FrameLocator](#FrameLocator)
FrameLocator(selector [string](/builtin#string)) [FrameLocator](#FrameLocator)
GetByAltText(text interface{}, options ...[FrameLocatorGetByAltTextOptions](#FrameLocatorGetByAltTextOptions)) [Locator](#Locator)
GetByLabel(text interface{}, options ...[FrameLocatorGetByLabelOptions](#FrameLocatorGetByLabelOptions)) [Locator](#Locator)
GetByPlaceholder(text interface{}, options ...[FrameLocatorGetByPlaceholderOptions](#FrameLocatorGetByPlaceholderOptions)) [Locator](#Locator)
GetByRole(role [AriaRole](#AriaRole), options ...[FrameLocatorGetByRoleOptions](#FrameLocatorGetByRoleOptions)) [Locator](#Locator)
GetByTestId(testId interface{}) [Locator](#Locator)
GetByText(text interface{}, options ...[FrameLocatorGetByTextOptions](#FrameLocatorGetByTextOptions)) [Locator](#Locator)
GetByTitle(text interface{}, options ...[FrameLocatorGetByTitleOptions](#FrameLocatorGetByTitleOptions)) [Locator](#Locator)
Last() [FrameLocator](#FrameLocator)
Locator(selectorOrLocator interface{}, options ...[FrameLocatorLocatorOptions](#FrameLocatorLocatorOptions)) [Locator](#Locator)
Nth(index [int](/builtin#int)) [FrameLocator](#FrameLocator)
Owner() [Locator](#Locator)}
FrameLocator represents a view to the `iframe` on the page. It captures the logic sufficient to retrieve the `iframe` and locate elements in that iframe. FrameLocator can be created with either [Locator.ContentFrame], [Page.FrameLocator] or [Locator.FrameLocator] method. **Strictness** Frame locators are strict. This means that all operations on frame locators will throw if more than one element matches a given selector. **Converting Locator to FrameLocator** If you have a Locator object pointing to an `iframe` it can be converted to FrameLocator using [Locator.ContentFrame]. **Converting FrameLocator to Locator** If you have a FrameLocator object it can be converted to Locator pointing to the same `iframe` using [FrameLocator.Owner].
type FrameLocatorGetByAltTextOptions struct {
Exact *[bool](/builtin#bool) `json:"exact"`}
type FrameLocatorGetByLabelOptions struct {
Exact *[bool](/builtin#bool) `json:"exact"`}
type FrameLocatorGetByPlaceholderOptions struct {
Exact *[bool](/builtin#bool) `json:"exact"`}
type FrameLocatorGetByRoleOptions struct {
Checked *[bool](/builtin#bool) `json:"checked"`
Disabled *[bool](/builtin#bool) `json:"disabled"`
Exact *[bool](/builtin#bool) `json:"exact"`
Expanded *[bool](/builtin#bool) `json:"expanded"`
IncludeHidden *[bool](/builtin#bool) `json:"includeHidden"`
Level *[int](/builtin#int) `json:"level"`
Name interface{} `json:"name"`
Pressed *[bool](/builtin#bool) `json:"pressed"`
Selected *[bool](/builtin#bool) `json:"selected"`}
type FrameLocatorGetByTextOptions struct {
Exact *[bool](/builtin#bool) `json:"exact"`}
type FrameLocatorGetByTitleOptions struct {
Exact *[bool](/builtin#bool) `json:"exact"`}
type FrameLocatorLocatorOptions struct {
Has [Locator](#Locator) `json:"has"`
HasNot [Locator](#Locator) `json:"hasNot"`
HasNotText interface{} `json:"hasNotText"`
HasText interface{} `json:"hasText"`}
type FrameLocatorOptions struct {
Has [Locator](#Locator) `json:"has"`
HasNot [Locator](#Locator) `json:"hasNot"`
HasNotText interface{} `json:"hasNotText"`
HasText interface{} `json:"hasText"`}
type FramePressOptions struct {
Delay *[float64](/builtin#float64) `json:"delay"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type FrameQuerySelectorOptions struct {
Strict *[bool](/builtin#bool) `json:"strict"`}
type FrameSelectOptionOptions struct {
Force *[bool](/builtin#bool) `json:"force"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type FrameSetCheckedOptions struct {
Force *[bool](/builtin#bool) `json:"force"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Position *[Position](#Position) `json:"position"`
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
Trial *[bool](/builtin#bool) `json:"trial"`}
type FrameSetInputFilesOptions struct {
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type FrameTapOptions struct {
Force *[bool](/builtin#bool) `json:"force"`
Modifiers [][KeyboardModifier](#KeyboardModifier) `json:"modifiers"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Position *[Position](#Position) `json:"position"`
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
Trial *[bool](/builtin#bool) `json:"trial"`}
type FrameTypeOptions struct {
Delay *[float64](/builtin#float64) `json:"delay"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type FrameUncheckOptions struct {
Force *[bool](/builtin#bool) `json:"force"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Position *[Position](#Position) `json:"position"`
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
Trial *[bool](/builtin#bool) `json:"trial"`}
type FrameWaitForFunctionOptions struct {
Polling interface{} `json:"polling"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type FrameWaitForLoadStateOptions struct {
State *[LoadState](#LoadState) `json:"state"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type FrameWaitForSelectorOptions struct {
State *[WaitForSelectorState](#WaitForSelectorState) `json:"state"`
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type FrameWaitForURLOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`
WaitUntil *[WaitUntilState](#WaitUntilState) `json:"waitUntil"`}
type Geolocation struct {
Latitude [float64](/builtin#float64) `json:"latitude"`
Longitude [float64](/builtin#float64) `json:"longitude"`
Accuracy *[float64](/builtin#float64) `json:"accuracy"`}
var ( HarModeFull *HarMode = getHarMode("full") HarModeMinimal = getHarMode("minimal") )
var ( HarNotFoundAbort *HarNotFound = getHarNotFound("abort") HarNotFoundFallback = getHarNotFound("fallback") )
type HttpCredentials struct {
Username string json:"username"
Password string json:"password"
Origin *[string](/builtin#string) `json:"origin"`
Send *[HttpCredentialsSend](#HttpCredentialsSend) `json:"send"`}
type HttpCredentialsSend string
var ( HttpCredentialsSendAlways = getHttpCredentialsSend("always") )
type InputFile struct {
Name string json:"name"
MimeType string json:"mimeType,omitempty"
Buffer []byte json:"buffer"
}
InputFile represents the input file for: - FileChooser.SetFiles() - ElementHandle.SetInputFiles() - Page.SetInputFiles()
type JSHandle ¶
JSHandle represents an in-page JavaScript object. JSHandles can be created with the [Page.EvaluateHandle] method. JSHandle prevents the referenced JavaScript object being garbage collected unless the handle is exposed with [JSHandle.Dispose]. JSHandles are auto-disposed when their origin frame gets navigated or the parent context gets destroyed. JSHandle instances can be used as an argument in [Page.EvalOnSelector], [Page.Evaluate] and [Page.EvaluateHandle] methods.
Keyboard provides an api for managing a virtual keyboard. The high level api is [Keyboard.Type], which takes raw characters and generates proper `keydown`, `keypress`/`input`, and `keyup` events on your page. For finer control, you can use [Keyboard.Down], [Keyboard.Up], and [Keyboard.InsertText] to manually fire events as if they were generated from a real keyboard. An example of holding down `Shift` in order to select and delete some text: An example of pressing uppercase `A` An example to trigger select-all with the keyboard
type KeyboardPressOptions struct {
Delay *[float64](/builtin#float64) `json:"delay"`}
type KeyboardTypeOptions struct {
Delay *[float64](/builtin#float64) `json:"delay"`}
type Locator interface {
All() ([][Locator](#Locator), [error](/builtin#error))
AllInnerTexts() ([][string](/builtin#string), [error](/builtin#error))
AllTextContents() ([][string](/builtin#string), [error](/builtin#error))
And(locator [Locator](#Locator)) [Locator](#Locator)
AriaSnapshot(options ...[LocatorAriaSnapshotOptions](#LocatorAriaSnapshotOptions)) ([string](/builtin#string), [error](/builtin#error))
Blur(options ...[LocatorBlurOptions](#LocatorBlurOptions)) [error](/builtin#error)
BoundingBox(options ...[LocatorBoundingBoxOptions](#LocatorBoundingBoxOptions)) (*[Rect](#Rect), [error](/builtin#error))
Check(options ...[LocatorCheckOptions](#LocatorCheckOptions)) [error](/builtin#error)
Clear(options ...[LocatorClearOptions](#LocatorClearOptions)) [error](/builtin#error)
Click(options ...[LocatorClickOptions](#LocatorClickOptions)) [error](/builtin#error)
Count() ([int](/builtin#int), [error](/builtin#error))
Dblclick(options ...[LocatorDblclickOptions](#LocatorDblclickOptions)) [error](/builtin#error)
DispatchEvent(typ [string](/builtin#string), eventInit interface{}, options ...[LocatorDispatchEventOptions](#LocatorDispatchEventOptions)) [error](/builtin#error)
DragTo(target [Locator](#Locator), options ...[LocatorDragToOptions](#LocatorDragToOptions)) [error](/builtin#error)
ElementHandle(options ...[LocatorElementHandleOptions](#LocatorElementHandleOptions)) ([ElementHandle](#ElementHandle), [error](/builtin#error))
ElementHandles() ([][ElementHandle](#ElementHandle), [error](/builtin#error))
ContentFrame() [FrameLocator](#FrameLocator)
Evaluate(expression [string](/builtin#string), arg interface{}, options ...[LocatorEvaluateOptions](#LocatorEvaluateOptions)) (interface{}, [error](/builtin#error))
EvaluateAll(expression [string](/builtin#string), arg ...interface{}) (interface{}, [error](/builtin#error))
EvaluateHandle(expression [string](/builtin#string), arg interface{}, options ...[LocatorEvaluateHandleOptions](#LocatorEvaluateHandleOptions)) ([JSHandle](#JSHandle), [error](/builtin#error))
Fill(value [string](/builtin#string), options ...[LocatorFillOptions](#LocatorFillOptions)) [error](/builtin#error)
Filter(options ...[LocatorFilterOptions](#LocatorFilterOptions)) [Locator](#Locator)
First() [Locator](#Locator)
Focus(options ...[LocatorFocusOptions](#LocatorFocusOptions)) [error](/builtin#error)
FrameLocator(selector [string](/builtin#string)) [FrameLocator](#FrameLocator)
GetAttribute(name [string](/builtin#string), options ...[LocatorGetAttributeOptions](#LocatorGetAttributeOptions)) ([string](/builtin#string), [error](/builtin#error))
GetByAltText(text interface{}, options ...[LocatorGetByAltTextOptions](#LocatorGetByAltTextOptions)) [Locator](#Locator)
GetByLabel(text interface{}, options ...[LocatorGetByLabelOptions](#LocatorGetByLabelOptions)) [Locator](#Locator)
GetByPlaceholder(text interface{}, options ...[LocatorGetByPlaceholderOptions](#LocatorGetByPlaceholderOptions)) [Locator](#Locator)
GetByRole(role [AriaRole](#AriaRole), options ...[LocatorGetByRoleOptions](#LocatorGetByRoleOptions)) [Locator](#Locator)
GetByTestId(testId interface{}) [Locator](#Locator)
GetByText(text interface{}, options ...[LocatorGetByTextOptions](#LocatorGetByTextOptions)) [Locator](#Locator)
GetByTitle(text interface{}, options ...[LocatorGetByTitleOptions](#LocatorGetByTitleOptions)) [Locator](#Locator)
Highlight() [error](/builtin#error)
Hover(options ...[LocatorHoverOptions](#LocatorHoverOptions)) [error](/builtin#error)
InnerHTML(options ...[LocatorInnerHTMLOptions](#LocatorInnerHTMLOptions)) ([string](/builtin#string), [error](/builtin#error))
InnerText(options ...[LocatorInnerTextOptions](#LocatorInnerTextOptions)) ([string](/builtin#string), [error](/builtin#error))
InputValue(options ...[LocatorInputValueOptions](#LocatorInputValueOptions)) ([string](/builtin#string), [error](/builtin#error))
IsChecked(options ...[LocatorIsCheckedOptions](#LocatorIsCheckedOptions)) ([bool](/builtin#bool), [error](/builtin#error))
IsDisabled(options ...[LocatorIsDisabledOptions](#LocatorIsDisabledOptions)) ([bool](/builtin#bool), [error](/builtin#error))
IsEditable(options ...[LocatorIsEditableOptions](#LocatorIsEditableOptions)) ([bool](/builtin#bool), [error](/builtin#error))
IsEnabled(options ...[LocatorIsEnabledOptions](#LocatorIsEnabledOptions)) ([bool](/builtin#bool), [error](/builtin#error))
IsHidden(options ...[LocatorIsHiddenOptions](#LocatorIsHiddenOptions)) ([bool](/builtin#bool), [error](/builtin#error))
IsVisible(options ...[LocatorIsVisibleOptions](#LocatorIsVisibleOptions)) ([bool](/builtin#bool), [error](/builtin#error))
Last() [Locator](#Locator)
Locator(selectorOrLocator interface{}, options ...[LocatorLocatorOptions](#LocatorLocatorOptions)) [Locator](#Locator)
Nth(index [int](/builtin#int)) [Locator](#Locator)
Or(locator [Locator](#Locator)) [Locator](#Locator)
Page() ([Page](#Page), [error](/builtin#error))
Press(key [string](/builtin#string), options ...[LocatorPressOptions](#LocatorPressOptions)) [error](/builtin#error)
PressSequentially(text [string](/builtin#string), options ...[LocatorPressSequentiallyOptions](#LocatorPressSequentiallyOptions)) [error](/builtin#error)
Screenshot(options ...[LocatorScreenshotOptions](#LocatorScreenshotOptions)) ([][byte](/builtin#byte), [error](/builtin#error))
ScrollIntoViewIfNeeded(options ...[LocatorScrollIntoViewIfNeededOptions](#LocatorScrollIntoViewIfNeededOptions)) [error](/builtin#error)
SelectOption(values [SelectOptionValues](#SelectOptionValues), options ...[LocatorSelectOptionOptions](#LocatorSelectOptionOptions)) ([][string](/builtin#string), [error](/builtin#error))
SelectText(options ...[LocatorSelectTextOptions](#LocatorSelectTextOptions)) [error](/builtin#error)
SetChecked(checked [bool](/builtin#bool), options ...[LocatorSetCheckedOptions](#LocatorSetCheckedOptions)) [error](/builtin#error)
SetInputFiles(files interface{}, options ...[LocatorSetInputFilesOptions](#LocatorSetInputFilesOptions)) [error](/builtin#error)
Tap(options ...[LocatorTapOptions](#LocatorTapOptions)) [error](/builtin#error)
TextContent(options ...[LocatorTextContentOptions](#LocatorTextContentOptions)) ([string](/builtin#string), [error](/builtin#error))
Type(text [string](/builtin#string), options ...[LocatorTypeOptions](#LocatorTypeOptions)) [error](/builtin#error)
Uncheck(options ...[LocatorUncheckOptions](#LocatorUncheckOptions)) [error](/builtin#error)
WaitFor(options ...[LocatorWaitForOptions](#LocatorWaitForOptions)) [error](/builtin#error)
Err() [error](/builtin#error)}
Locators are the central piece of Playwright's auto-waiting and retry-ability. In a nutshell, locators represent a way to find element(s) on the page at any moment. A locator can be created with the [Page.Locator] method.Learn more about locators.
type LocatorAriaSnapshotOptions struct {
Ref *[bool](/builtin#bool) `json:"ref"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorAssertions interface {
Not() [LocatorAssertions](#LocatorAssertions)
ToBeAttached(options ...[LocatorAssertionsToBeAttachedOptions](#LocatorAssertionsToBeAttachedOptions)) [error](/builtin#error)
ToBeChecked(options ...[LocatorAssertionsToBeCheckedOptions](#LocatorAssertionsToBeCheckedOptions)) [error](/builtin#error)
ToBeDisabled(options ...[LocatorAssertionsToBeDisabledOptions](#LocatorAssertionsToBeDisabledOptions)) [error](/builtin#error)
ToBeEditable(options ...[LocatorAssertionsToBeEditableOptions](#LocatorAssertionsToBeEditableOptions)) [error](/builtin#error)
ToBeEmpty(options ...[LocatorAssertionsToBeEmptyOptions](#LocatorAssertionsToBeEmptyOptions)) [error](/builtin#error)
ToBeEnabled(options ...[LocatorAssertionsToBeEnabledOptions](#LocatorAssertionsToBeEnabledOptions)) [error](/builtin#error)
ToBeFocused(options ...[LocatorAssertionsToBeFocusedOptions](#LocatorAssertionsToBeFocusedOptions)) [error](/builtin#error)
ToBeHidden(options ...[LocatorAssertionsToBeHiddenOptions](#LocatorAssertionsToBeHiddenOptions)) [error](/builtin#error)
ToBeInViewport(options ...[LocatorAssertionsToBeInViewportOptions](#LocatorAssertionsToBeInViewportOptions)) [error](/builtin#error)
ToBeVisible(options ...[LocatorAssertionsToBeVisibleOptions](#LocatorAssertionsToBeVisibleOptions)) [error](/builtin#error)
ToContainClass(expected interface{}, options ...[LocatorAssertionsToContainClassOptions](#LocatorAssertionsToContainClassOptions)) [error](/builtin#error)
ToContainText(expected interface{}, options ...[LocatorAssertionsToContainTextOptions](#LocatorAssertionsToContainTextOptions)) [error](/builtin#error)
ToHaveAccessibleDescription(description interface{}, options ...[LocatorAssertionsToHaveAccessibleDescriptionOptions](#LocatorAssertionsToHaveAccessibleDescriptionOptions)) [error](/builtin#error)
ToHaveAccessibleErrorMessage(errorMessage interface{}, options ...[LocatorAssertionsToHaveAccessibleErrorMessageOptions](#LocatorAssertionsToHaveAccessibleErrorMessageOptions)) [error](/builtin#error)
ToHaveAccessibleName(name interface{}, options ...[LocatorAssertionsToHaveAccessibleNameOptions](#LocatorAssertionsToHaveAccessibleNameOptions)) [error](/builtin#error)
ToHaveAttribute(name [string](/builtin#string), value interface{}, options ...[LocatorAssertionsToHaveAttributeOptions](#LocatorAssertionsToHaveAttributeOptions)) [error](/builtin#error)
ToHaveClass(expected interface{}, options ...[LocatorAssertionsToHaveClassOptions](#LocatorAssertionsToHaveClassOptions)) [error](/builtin#error)
ToHaveCount(count [int](/builtin#int), options ...[LocatorAssertionsToHaveCountOptions](#LocatorAssertionsToHaveCountOptions)) [error](/builtin#error)
ToHaveCSS(name [string](/builtin#string), value interface{}, options ...[LocatorAssertionsToHaveCSSOptions](#LocatorAssertionsToHaveCSSOptions)) [error](/builtin#error)
ToHaveId(id interface{}, options ...[LocatorAssertionsToHaveIdOptions](#LocatorAssertionsToHaveIdOptions)) [error](/builtin#error)
ToHaveJSProperty(name [string](/builtin#string), value interface{}, options ...[LocatorAssertionsToHaveJSPropertyOptions](#LocatorAssertionsToHaveJSPropertyOptions)) [error](/builtin#error)
ToHaveRole(role [AriaRole](#AriaRole), options ...[LocatorAssertionsToHaveRoleOptions](#LocatorAssertionsToHaveRoleOptions)) [error](/builtin#error)
ToHaveText(expected interface{}, options ...[LocatorAssertionsToHaveTextOptions](#LocatorAssertionsToHaveTextOptions)) [error](/builtin#error)
ToHaveValue(value interface{}, options ...[LocatorAssertionsToHaveValueOptions](#LocatorAssertionsToHaveValueOptions)) [error](/builtin#error)
ToHaveValues(values []interface{}, options ...[LocatorAssertionsToHaveValuesOptions](#LocatorAssertionsToHaveValuesOptions)) [error](/builtin#error)
ToMatchAriaSnapshot(expected [string](/builtin#string), options ...[LocatorAssertionsToMatchAriaSnapshotOptions](#LocatorAssertionsToMatchAriaSnapshotOptions)) [error](/builtin#error)}
The LocatorAssertions class provides assertion methods that can be used to make assertions about the Locatorstate in the tests.
type LocatorAssertionsToBeAttachedOptions struct {
Attached *bool json:"attached"
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorAssertionsToBeCheckedOptions struct {
Checked *[bool](/builtin#bool) `json:"checked"`
Indeterminate *[bool](/builtin#bool) `json:"indeterminate"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorAssertionsToBeDisabledOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorAssertionsToBeEditableOptions struct {
Editable *bool json:"editable"
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorAssertionsToBeEmptyOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorAssertionsToBeEnabledOptions struct {
Enabled *bool json:"enabled"
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorAssertionsToBeFocusedOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorAssertionsToBeHiddenOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorAssertionsToBeInViewportOptions struct {
Ratio *[float64](/builtin#float64) `json:"ratio"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorAssertionsToBeVisibleOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`
Visible *[bool](/builtin#bool) `json:"visible"`}
type LocatorAssertionsToContainClassOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorAssertionsToContainTextOptions struct {
IgnoreCase *[bool](/builtin#bool) `json:"ignoreCase"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
UseInnerText *[bool](/builtin#bool) `json:"useInnerText"`}
type LocatorAssertionsToHaveAccessibleDescriptionOptions struct {
IgnoreCase *[bool](/builtin#bool) `json:"ignoreCase"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorAssertionsToHaveAccessibleErrorMessageOptions struct {
IgnoreCase *[bool](/builtin#bool) `json:"ignoreCase"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorAssertionsToHaveAccessibleNameOptions struct {
IgnoreCase *[bool](/builtin#bool) `json:"ignoreCase"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorAssertionsToHaveAttributeOptions struct {
IgnoreCase *[bool](/builtin#bool) `json:"ignoreCase"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorAssertionsToHaveCSSOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorAssertionsToHaveClassOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorAssertionsToHaveCountOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorAssertionsToHaveIdOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorAssertionsToHaveJSPropertyOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorAssertionsToHaveRoleOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorAssertionsToHaveTextOptions struct {
IgnoreCase *[bool](/builtin#bool) `json:"ignoreCase"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
UseInnerText *[bool](/builtin#bool) `json:"useInnerText"`}
type LocatorAssertionsToHaveValueOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorAssertionsToHaveValuesOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorAssertionsToMatchAriaSnapshotOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorBlurOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorBoundingBoxOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorCheckOptions struct {
Force *[bool](/builtin#bool) `json:"force"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Position *[Position](#Position) `json:"position"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
Trial *[bool](/builtin#bool) `json:"trial"`}
type LocatorClearOptions struct {
Force *[bool](/builtin#bool) `json:"force"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorClickOptions struct {
Button *[MouseButton](#MouseButton) `json:"button"`
ClickCount *[int](/builtin#int) `json:"clickCount"`
Delay *[float64](/builtin#float64) `json:"delay"`
Force *[bool](/builtin#bool) `json:"force"`
Modifiers [][KeyboardModifier](#KeyboardModifier) `json:"modifiers"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Position *[Position](#Position) `json:"position"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
Trial *[bool](/builtin#bool) `json:"trial"`}
type LocatorDblclickOptions struct {
Button *[MouseButton](#MouseButton) `json:"button"`
Delay *[float64](/builtin#float64) `json:"delay"`
Force *[bool](/builtin#bool) `json:"force"`
Modifiers [][KeyboardModifier](#KeyboardModifier) `json:"modifiers"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Position *[Position](#Position) `json:"position"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
Trial *[bool](/builtin#bool) `json:"trial"`}
type LocatorDispatchEventOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorDragToOptions struct {
Force *[bool](/builtin#bool) `json:"force"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
SourcePosition *[Position](#Position) `json:"sourcePosition"`
TargetPosition *[Position](#Position) `json:"targetPosition"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
Trial *[bool](/builtin#bool) `json:"trial"`}
type LocatorEvaluateOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorFillOptions struct {
Force *[bool](/builtin#bool) `json:"force"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorFilterOptions struct {
Has [Locator](#Locator) `json:"has"`
HasNot [Locator](#Locator) `json:"hasNot"`
HasNotText interface{} `json:"hasNotText"`
HasText interface{} `json:"hasText"`
Visible *[bool](/builtin#bool) `json:"visible"`}
type LocatorFocusOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorGetAttributeOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorGetByAltTextOptions struct {
Exact *[bool](/builtin#bool) `json:"exact"`}
type LocatorGetByLabelOptions struct {
Exact *[bool](/builtin#bool) `json:"exact"`}
type LocatorGetByPlaceholderOptions struct {
Exact *[bool](/builtin#bool) `json:"exact"`}
type LocatorGetByRoleOptions struct {
Checked *[bool](/builtin#bool) `json:"checked"`
Disabled *[bool](/builtin#bool) `json:"disabled"`
Exact *[bool](/builtin#bool) `json:"exact"`
Expanded *[bool](/builtin#bool) `json:"expanded"`
IncludeHidden *[bool](/builtin#bool) `json:"includeHidden"`
Level *[int](/builtin#int) `json:"level"`
Name interface{} `json:"name"`
Pressed *[bool](/builtin#bool) `json:"pressed"`
Selected *[bool](/builtin#bool) `json:"selected"`}
type LocatorGetByTextOptions struct {
Exact *[bool](/builtin#bool) `json:"exact"`}
type LocatorGetByTitleOptions struct {
Exact *[bool](/builtin#bool) `json:"exact"`}
type LocatorHoverOptions struct {
Force *[bool](/builtin#bool) `json:"force"`
Modifiers [][KeyboardModifier](#KeyboardModifier) `json:"modifiers"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Position *[Position](#Position) `json:"position"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
Trial *[bool](/builtin#bool) `json:"trial"`}
type LocatorInnerHTMLOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorInnerTextOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorInputValueOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorIsCheckedOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorIsDisabledOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorIsEditableOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorIsEnabledOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorIsHiddenOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorIsVisibleOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorLocatorOptions struct {
Has [Locator](#Locator) `json:"has"`
HasNot [Locator](#Locator) `json:"hasNot"`
HasNotText interface{} `json:"hasNotText"`
HasText interface{} `json:"hasText"`}
type LocatorOptions LocatorFilterOptions
type LocatorPressOptions struct {
Delay *[float64](/builtin#float64) `json:"delay"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorPressSequentiallyOptions struct {
Delay *[float64](/builtin#float64) `json:"delay"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorScreenshotOptions struct {
Animations *[ScreenshotAnimations](#ScreenshotAnimations) `json:"animations"`
Caret *[ScreenshotCaret](#ScreenshotCaret) `json:"caret"`
Mask [][Locator](#Locator) `json:"mask"`
MaskColor *[string](/builtin#string) `json:"maskColor"`
OmitBackground *[bool](/builtin#bool) `json:"omitBackground"`
Path *[string](/builtin#string) `json:"path"`
Quality *[int](/builtin#int) `json:"quality"`
Scale *[ScreenshotScale](#ScreenshotScale) `json:"scale"`
Style *[string](/builtin#string) `json:"style"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
Type *[ScreenshotType](#ScreenshotType) `json:"type"`}
type LocatorScrollIntoViewIfNeededOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorSelectOptionOptions struct {
Force *[bool](/builtin#bool) `json:"force"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorSelectTextOptions struct {
Force *[bool](/builtin#bool) `json:"force"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorSetCheckedOptions struct {
Force *[bool](/builtin#bool) `json:"force"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Position *[Position](#Position) `json:"position"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
Trial *[bool](/builtin#bool) `json:"trial"`}
type LocatorSetInputFilesOptions struct {
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorTapOptions struct {
Force *[bool](/builtin#bool) `json:"force"`
Modifiers [][KeyboardModifier](#KeyboardModifier) `json:"modifiers"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Position *[Position](#Position) `json:"position"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
Trial *[bool](/builtin#bool) `json:"trial"`}
type LocatorTypeOptions struct {
Delay *[float64](/builtin#float64) `json:"delay"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type LocatorUncheckOptions struct {
Force *[bool](/builtin#bool) `json:"force"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Position *[Position](#Position) `json:"position"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
Trial *[bool](/builtin#bool) `json:"trial"`}
type LocatorWaitForOptions struct {
State *[WaitForSelectorState](#WaitForSelectorState) `json:"state"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type Margin struct {
Top *[string](/builtin#string) `json:"top"`
Right *[string](/builtin#string) `json:"right"`
Bottom *[string](/builtin#string) `json:"bottom"`
Left *[string](/builtin#string) `json:"left"`}
The Mouse class operates in main-frame CSS pixels relative to the top-left corner of the viewport. Every `page` object has its own Mouse, accessible with [Page.Mouse].
type MouseClickOptions struct {
Button *[MouseButton](#MouseButton) `json:"button"`
ClickCount *[int](/builtin#int) `json:"clickCount"`
Delay *[float64](/builtin#float64) `json:"delay"`}
type MouseDblclickOptions struct {
Button *[MouseButton](#MouseButton) `json:"button"`
Delay *[float64](/builtin#float64) `json:"delay"`}
type MouseDownOptions struct {
Button *[MouseButton](#MouseButton) `json:"button"`
ClickCount *[int](/builtin#int) `json:"clickCount"`}
type MouseMoveOptions struct {
Steps *[int](/builtin#int) `json:"steps"`}
type MouseUpOptions struct {
Button *[MouseButton](#MouseButton) `json:"button"`
ClickCount *[int](/builtin#int) `json:"clickCount"`}
type NameValue struct {
Name [string](/builtin#string) `json:"name"`
Value [string](/builtin#string) `json:"value"`}
type OptionalCookie struct {
Name string json:"name"
Value string json:"value"
URL *[string](/builtin#string) `json:"url"`
Domain *[string](/builtin#string) `json:"domain"`
Path *[string](/builtin#string) `json:"path"`
Expires *[float64](/builtin#float64) `json:"expires"`
HttpOnly *[bool](/builtin#bool) `json:"httpOnly"`
Secure *[bool](/builtin#bool) `json:"secure"`
SameSite *[SameSiteAttribute](#SameSiteAttribute) `json:"sameSite"`}
type OptionalStorageState struct {
Cookies [][OptionalCookie](#OptionalCookie) `json:"cookies"`
Origins [][Origin](#Origin) `json:"origins"`}
type Origin struct {
Origin string json:"origin"
LocalStorage []NameValue json:"localStorage"
}
type Page interface { EventEmitter
Clock() [Clock](#Clock)
OnClose(fn func([Page](#Page)))
OnConsole(fn func([ConsoleMessage](#ConsoleMessage)))
OnCrash(fn func([Page](#Page)))
OnDialog(fn func([Dialog](#Dialog)))
OnDOMContentLoaded(fn func([Page](#Page)))
OnDownload(fn func([Download](#Download)))
OnFileChooser(fn func([FileChooser](#FileChooser)))
OnFrameAttached(fn func([Frame](#Frame)))
OnFrameDetached(fn func([Frame](#Frame)))
OnFrameNavigated(fn func([Frame](#Frame)))
OnLoad(fn func([Page](#Page)))
OnPageError(fn func([error](/builtin#error)))
OnPopup(fn func([Page](#Page)))
OnRequest(fn func([Request](#Request)))
OnRequestFailed(fn func([Request](#Request)))
OnRequestFinished(fn func([Request](#Request)))
OnResponse(fn func([Response](#Response)))
OnWebSocket(fn func([WebSocket](#WebSocket)))
OnWorker(fn func([Worker](#Worker)))
AddInitScript(script [Script](#Script)) [error](/builtin#error)
AddScriptTag(options [PageAddScriptTagOptions](#PageAddScriptTagOptions)) ([ElementHandle](#ElementHandle), [error](/builtin#error))
AddStyleTag(options [PageAddStyleTagOptions](#PageAddStyleTagOptions)) ([ElementHandle](#ElementHandle), [error](/builtin#error))
BringToFront() [error](/builtin#error)
Check(selector [string](/builtin#string), options ...[PageCheckOptions](#PageCheckOptions)) [error](/builtin#error)
Click(selector [string](/builtin#string), options ...[PageClickOptions](#PageClickOptions)) [error](/builtin#error)
Close(options ...[PageCloseOptions](#PageCloseOptions)) [error](/builtin#error)
Content() ([string](/builtin#string), [error](/builtin#error))
Context() [BrowserContext](#BrowserContext)
Dblclick(selector [string](/builtin#string), options ...[PageDblclickOptions](#PageDblclickOptions)) [error](/builtin#error)
DispatchEvent(selector [string](/builtin#string), typ [string](/builtin#string), eventInit interface{}, options ...[PageDispatchEventOptions](#PageDispatchEventOptions)) [error](/builtin#error)
DragAndDrop(source [string](/builtin#string), target [string](/builtin#string), options ...[PageDragAndDropOptions](#PageDragAndDropOptions)) [error](/builtin#error)
EmulateMedia(options ...[PageEmulateMediaOptions](#PageEmulateMediaOptions)) [error](/builtin#error)
EvalOnSelector(selector [string](/builtin#string), expression [string](/builtin#string), arg interface{}, options ...[PageEvalOnSelectorOptions](#PageEvalOnSelectorOptions)) (interface{}, [error](/builtin#error))
EvalOnSelectorAll(selector [string](/builtin#string), expression [string](/builtin#string), arg ...interface{}) (interface{}, [error](/builtin#error))
Evaluate(expression [string](/builtin#string), arg ...interface{}) (interface{}, [error](/builtin#error))
EvaluateHandle(expression [string](/builtin#string), arg ...interface{}) ([JSHandle](#JSHandle), [error](/builtin#error))
ExposeBinding(name [string](/builtin#string), binding [BindingCallFunction](#BindingCallFunction), handle ...[bool](/builtin#bool)) [error](/builtin#error)
ExposeFunction(name [string](/builtin#string), binding [ExposedFunction](#ExposedFunction)) [error](/builtin#error)
Fill(selector [string](/builtin#string), value [string](/builtin#string), options ...[PageFillOptions](#PageFillOptions)) [error](/builtin#error)
Focus(selector [string](/builtin#string), options ...[PageFocusOptions](#PageFocusOptions)) [error](/builtin#error)
Frame(options ...[PageFrameOptions](#PageFrameOptions)) [Frame](#Frame)
FrameLocator(selector [string](/builtin#string)) [FrameLocator](#FrameLocator)
Frames() [][Frame](#Frame)
GetAttribute(selector [string](/builtin#string), name [string](/builtin#string), options ...[PageGetAttributeOptions](#PageGetAttributeOptions)) ([string](/builtin#string), [error](/builtin#error))
GetByAltText(text interface{}, options ...[PageGetByAltTextOptions](#PageGetByAltTextOptions)) [Locator](#Locator)
GetByLabel(text interface{}, options ...[PageGetByLabelOptions](#PageGetByLabelOptions)) [Locator](#Locator)
GetByPlaceholder(text interface{}, options ...[PageGetByPlaceholderOptions](#PageGetByPlaceholderOptions)) [Locator](#Locator)
GetByRole(role [AriaRole](#AriaRole), options ...[PageGetByRoleOptions](#PageGetByRoleOptions)) [Locator](#Locator)
GetByTestId(testId interface{}) [Locator](#Locator)
GetByText(text interface{}, options ...[PageGetByTextOptions](#PageGetByTextOptions)) [Locator](#Locator)
GetByTitle(text interface{}, options ...[PageGetByTitleOptions](#PageGetByTitleOptions)) [Locator](#Locator)
GoBack(options ...[PageGoBackOptions](#PageGoBackOptions)) ([Response](#Response), [error](/builtin#error))
GoForward(options ...[PageGoForwardOptions](#PageGoForwardOptions)) ([Response](#Response), [error](/builtin#error))
RequestGC() [error](/builtin#error)
Goto(url [string](/builtin#string), options ...[PageGotoOptions](#PageGotoOptions)) ([Response](#Response), [error](/builtin#error))
Hover(selector [string](/builtin#string), options ...[PageHoverOptions](#PageHoverOptions)) [error](/builtin#error)
InnerHTML(selector [string](/builtin#string), options ...[PageInnerHTMLOptions](#PageInnerHTMLOptions)) ([string](/builtin#string), [error](/builtin#error))
InnerText(selector [string](/builtin#string), options ...[PageInnerTextOptions](#PageInnerTextOptions)) ([string](/builtin#string), [error](/builtin#error))
InputValue(selector [string](/builtin#string), options ...[PageInputValueOptions](#PageInputValueOptions)) ([string](/builtin#string), [error](/builtin#error))
IsChecked(selector [string](/builtin#string), options ...[PageIsCheckedOptions](#PageIsCheckedOptions)) ([bool](/builtin#bool), [error](/builtin#error))
IsClosed() [bool](/builtin#bool)
IsDisabled(selector [string](/builtin#string), options ...[PageIsDisabledOptions](#PageIsDisabledOptions)) ([bool](/builtin#bool), [error](/builtin#error))
IsEditable(selector [string](/builtin#string), options ...[PageIsEditableOptions](#PageIsEditableOptions)) ([bool](/builtin#bool), [error](/builtin#error))
IsEnabled(selector [string](/builtin#string), options ...[PageIsEnabledOptions](#PageIsEnabledOptions)) ([bool](/builtin#bool), [error](/builtin#error))
IsHidden(selector [string](/builtin#string), options ...[PageIsHiddenOptions](#PageIsHiddenOptions)) ([bool](/builtin#bool), [error](/builtin#error))
IsVisible(selector [string](/builtin#string), options ...[PageIsVisibleOptions](#PageIsVisibleOptions)) ([bool](/builtin#bool), [error](/builtin#error))
Keyboard() [Keyboard](#Keyboard)
Locator(selector [string](/builtin#string), options ...[PageLocatorOptions](#PageLocatorOptions)) [Locator](#Locator)
MainFrame() [Frame](#Frame)
Mouse() [Mouse](#Mouse)
Opener() ([Page](#Page), [error](/builtin#error))
Pause() [error](/builtin#error)
PDF(options ...[PagePdfOptions](#PagePdfOptions)) ([][byte](/builtin#byte), [error](/builtin#error))
Press(selector [string](/builtin#string), key [string](/builtin#string), options ...[PagePressOptions](#PagePressOptions)) [error](/builtin#error)
QuerySelector(selector [string](/builtin#string), options ...[PageQuerySelectorOptions](#PageQuerySelectorOptions)) ([ElementHandle](#ElementHandle), [error](/builtin#error))
QuerySelectorAll(selector [string](/builtin#string)) ([][ElementHandle](#ElementHandle), [error](/builtin#error))
AddLocatorHandler(locator [Locator](#Locator), handler func([Locator](#Locator)), options ...[PageAddLocatorHandlerOptions](#PageAddLocatorHandlerOptions)) [error](/builtin#error)
RemoveLocatorHandler(locator [Locator](#Locator)) [error](/builtin#error)
Reload(options ...[PageReloadOptions](#PageReloadOptions)) ([Response](#Response), [error](/builtin#error))
Request() [APIRequestContext](#APIRequestContext)
Route(url interface{}, handler routeHandler, times ...[int](/builtin#int)) [error](/builtin#error)
RouteFromHAR(har [string](/builtin#string), options ...[PageRouteFromHAROptions](#PageRouteFromHAROptions)) [error](/builtin#error)
RouteWebSocket(url interface{}, handler func([WebSocketRoute](#WebSocketRoute))) [error](/builtin#error)
Screenshot(options ...[PageScreenshotOptions](#PageScreenshotOptions)) ([][byte](/builtin#byte), [error](/builtin#error))
SelectOption(selector [string](/builtin#string), values [SelectOptionValues](#SelectOptionValues), options ...[PageSelectOptionOptions](#PageSelectOptionOptions)) ([][string](/builtin#string), [error](/builtin#error))
SetChecked(selector [string](/builtin#string), checked [bool](/builtin#bool), options ...[PageSetCheckedOptions](#PageSetCheckedOptions)) [error](/builtin#error)
SetContent(html [string](/builtin#string), options ...[PageSetContentOptions](#PageSetContentOptions)) [error](/builtin#error)
SetDefaultNavigationTimeout(timeout [float64](/builtin#float64))
SetDefaultTimeout(timeout [float64](/builtin#float64))
SetExtraHTTPHeaders(headers map[[string](/builtin#string)][string](/builtin#string)) [error](/builtin#error)
SetInputFiles(selector [string](/builtin#string), files interface{}, options ...[PageSetInputFilesOptions](#PageSetInputFilesOptions)) [error](/builtin#error)
SetViewportSize(width [int](/builtin#int), height [int](/builtin#int)) [error](/builtin#error)
Tap(selector [string](/builtin#string), options ...[PageTapOptions](#PageTapOptions)) [error](/builtin#error)
TextContent(selector [string](/builtin#string), options ...[PageTextContentOptions](#PageTextContentOptions)) ([string](/builtin#string), [error](/builtin#error))
Title() ([string](/builtin#string), [error](/builtin#error))
Touchscreen() [Touchscreen](#Touchscreen)
Type(selector [string](/builtin#string), text [string](/builtin#string), options ...[PageTypeOptions](#PageTypeOptions)) [error](/builtin#error)
Uncheck(selector [string](/builtin#string), options ...[PageUncheckOptions](#PageUncheckOptions)) [error](/builtin#error)
UnrouteAll(options ...[PageUnrouteAllOptions](#PageUnrouteAllOptions)) [error](/builtin#error)
Unroute(url interface{}, handler ...routeHandler) [error](/builtin#error)
URL() [string](/builtin#string)
Video() [Video](#Video)
ViewportSize() *[Size](#Size)
ExpectConsoleMessage(cb func() [error](/builtin#error), options ...[PageExpectConsoleMessageOptions](#PageExpectConsoleMessageOptions)) ([ConsoleMessage](#ConsoleMessage), [error](/builtin#error))
ExpectDownload(cb func() [error](/builtin#error), options ...[PageExpectDownloadOptions](#PageExpectDownloadOptions)) ([Download](#Download), [error](/builtin#error))
ExpectEvent(event [string](/builtin#string), cb func() [error](/builtin#error), options ...[PageExpectEventOptions](#PageExpectEventOptions)) (interface{}, [error](/builtin#error))
ExpectFileChooser(cb func() [error](/builtin#error), options ...[PageExpectFileChooserOptions](#PageExpectFileChooserOptions)) ([FileChooser](#FileChooser), [error](/builtin#error))
WaitForFunction(expression [string](/builtin#string), arg interface{}, options ...[PageWaitForFunctionOptions](#PageWaitForFunctionOptions)) ([JSHandle](#JSHandle), [error](/builtin#error))
WaitForLoadState(options ...[PageWaitForLoadStateOptions](#PageWaitForLoadStateOptions)) [error](/builtin#error)
ExpectNavigation(cb func() [error](/builtin#error), options ...[PageExpectNavigationOptions](#PageExpectNavigationOptions)) ([Response](#Response), [error](/builtin#error))
ExpectPopup(cb func() [error](/builtin#error), options ...[PageExpectPopupOptions](#PageExpectPopupOptions)) ([Page](#Page), [error](/builtin#error))
ExpectRequest(urlOrPredicate interface{}, cb func() [error](/builtin#error), options ...[PageExpectRequestOptions](#PageExpectRequestOptions)) ([Request](#Request), [error](/builtin#error))
ExpectRequestFinished(cb func() [error](/builtin#error), options ...[PageExpectRequestFinishedOptions](#PageExpectRequestFinishedOptions)) ([Request](#Request), [error](/builtin#error))
ExpectResponse(urlOrPredicate interface{}, cb func() [error](/builtin#error), options ...[PageExpectResponseOptions](#PageExpectResponseOptions)) ([Response](#Response), [error](/builtin#error))
WaitForSelector(selector [string](/builtin#string), options ...[PageWaitForSelectorOptions](#PageWaitForSelectorOptions)) ([ElementHandle](#ElementHandle), [error](/builtin#error))
WaitForTimeout(timeout [float64](/builtin#float64))
WaitForURL(url interface{}, options ...[PageWaitForURLOptions](#PageWaitForURLOptions)) [error](/builtin#error)
ExpectWebSocket(cb func() [error](/builtin#error), options ...[PageExpectWebSocketOptions](#PageExpectWebSocketOptions)) ([WebSocket](#WebSocket), [error](/builtin#error))
ExpectWorker(cb func() [error](/builtin#error), options ...[PageExpectWorkerOptions](#PageExpectWorkerOptions)) ([Worker](#Worker), [error](/builtin#error))
Workers() [][Worker](#Worker)
WaitForEvent(event [string](/builtin#string), options ...[PageWaitForEventOptions](#PageWaitForEventOptions)) (interface{}, [error](/builtin#error))}
Page provides methods to interact with a single tab in a Browser, or anextension background page in Chromium. One Browserinstance might have multiple Page instances. This example creates a page, navigates it to a URL, and then saves a screenshot: The Page class emits various events (described below) which can be handled using any of Node's native`EventEmitter` methods, such as `on`, `once` or `removeListener`. This example logs a message for a single page `load` event: To unsubscribe from events use the `removeListener` method:
type PageAddScriptTagOptions struct {
Content *[string](/builtin#string) `json:"content"`
Path *[string](/builtin#string) `json:"path"`
Type *[string](/builtin#string) `json:"type"`
URL *[string](/builtin#string) `json:"url"`}
type PageAddStyleTagOptions struct {
Content *[string](/builtin#string) `json:"content"`
Path *[string](/builtin#string) `json:"path"`
URL *[string](/builtin#string) `json:"url"`}
type PageAssertions interface {
Not() [PageAssertions](#PageAssertions)
ToHaveTitle(titleOrRegExp interface{}, options ...[PageAssertionsToHaveTitleOptions](#PageAssertionsToHaveTitleOptions)) [error](/builtin#error)
ToHaveURL(urlOrRegExp interface{}, options ...[PageAssertionsToHaveURLOptions](#PageAssertionsToHaveURLOptions)) [error](/builtin#error)}
The PageAssertions class provides assertion methods that can be used to make assertions about the Page state in the tests.
type PageAssertionsToHaveTitleOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type PageAssertionsToHaveURLOptions struct {
IgnoreCase *[bool](/builtin#bool) `json:"ignoreCase"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type PageCheckOptions struct {
Force *[bool](/builtin#bool) `json:"force"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Position *[Position](#Position) `json:"position"`
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
Trial *[bool](/builtin#bool) `json:"trial"`}
type PageClickOptions struct {
Button *[MouseButton](#MouseButton) `json:"button"`
ClickCount *[int](/builtin#int) `json:"clickCount"`
Delay *[float64](/builtin#float64) `json:"delay"`
Force *[bool](/builtin#bool) `json:"force"`
Modifiers [][KeyboardModifier](#KeyboardModifier) `json:"modifiers"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Position *[Position](#Position) `json:"position"`
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
Trial *[bool](/builtin#bool) `json:"trial"`}
type PageCloseOptions struct {
Reason *[string](/builtin#string) `json:"reason"`
RunBeforeUnload *[bool](/builtin#bool) `json:"runBeforeUnload"`}
type PageDblclickOptions struct {
Button *[MouseButton](#MouseButton) `json:"button"`
Delay *[float64](/builtin#float64) `json:"delay"`
Force *[bool](/builtin#bool) `json:"force"`
Modifiers [][KeyboardModifier](#KeyboardModifier) `json:"modifiers"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Position *[Position](#Position) `json:"position"`
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
Trial *[bool](/builtin#bool) `json:"trial"`}
type PageDispatchEventOptions struct {
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type PageDragAndDropOptions ¶
type PageDragAndDropOptions struct {
Force *[bool](/builtin#bool) `json:"force"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
SourcePosition *[Position](#Position) `json:"sourcePosition"`
Strict *[bool](/builtin#bool) `json:"strict"`
TargetPosition *[Position](#Position) `json:"targetPosition"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
Trial *[bool](/builtin#bool) `json:"trial"`}
type PageEmulateMediaOptions struct {
ColorScheme *[ColorScheme](#ColorScheme) `json:"colorScheme"`
Contrast *[Contrast](#Contrast) `json:"contrast"`
ForcedColors *[ForcedColors](#ForcedColors) `json:"forcedColors"`
Media *[Media](#Media) `json:"media"`
ReducedMotion *[ReducedMotion](#ReducedMotion) `json:"reducedMotion"`}
type PageEvalOnSelectorOptions struct {
Strict *[bool](/builtin#bool) `json:"strict"`}
type PageExpectConsoleMessageOptions struct {
Predicate func([ConsoleMessage](#ConsoleMessage)) [bool](/builtin#bool) `json:"predicate"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type PageExpectDownloadOptions struct {
Predicate func([Download](#Download)) [bool](/builtin#bool) `json:"predicate"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type PageExpectEventOptions struct {
Predicate interface{} `json:"predicate"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type PageExpectFileChooserOptions struct {
Predicate func([FileChooser](#FileChooser)) [bool](/builtin#bool) `json:"predicate"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type PageExpectNavigationOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`
URL interface{} `json:"url"`
WaitUntil *[WaitUntilState](#WaitUntilState) `json:"waitUntil"`}
type PageExpectPopupOptions struct {
Predicate func(Page) bool json:"predicate"
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type PageExpectRequestFinishedOptions struct {
Predicate func([Request](#Request)) [bool](/builtin#bool) `json:"predicate"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type PageExpectRequestOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type PageExpectResponseOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type PageExpectWebSocketOptions struct {
Predicate func([WebSocket](#WebSocket)) [bool](/builtin#bool) `json:"predicate"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type PageExpectWorkerOptions struct {
Predicate func([Worker](#Worker)) [bool](/builtin#bool) `json:"predicate"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type PageFillOptions struct {
Force *[bool](/builtin#bool) `json:"force"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type PageFocusOptions struct {
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type PageFrameOptions struct {
Name *[string](/builtin#string) `json:"name"`
URL interface{} `json:"url"`}
type PageGetAttributeOptions struct {
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type PageGetByAltTextOptions struct {
Exact *[bool](/builtin#bool) `json:"exact"`}
type PageGetByLabelOptions struct {
Exact *[bool](/builtin#bool) `json:"exact"`}
type PageGetByPlaceholderOptions struct {
Exact *[bool](/builtin#bool) `json:"exact"`}
type PageGetByRoleOptions struct {
Checked *[bool](/builtin#bool) `json:"checked"`
Disabled *[bool](/builtin#bool) `json:"disabled"`
Exact *[bool](/builtin#bool) `json:"exact"`
Expanded *[bool](/builtin#bool) `json:"expanded"`
IncludeHidden *[bool](/builtin#bool) `json:"includeHidden"`
Level *[int](/builtin#int) `json:"level"`
Name interface{} `json:"name"`
Pressed *[bool](/builtin#bool) `json:"pressed"`
Selected *[bool](/builtin#bool) `json:"selected"`}
type PageGetByTextOptions struct {
Exact *[bool](/builtin#bool) `json:"exact"`}
type PageGetByTitleOptions struct {
Exact *[bool](/builtin#bool) `json:"exact"`}
type PageGoBackOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`
WaitUntil *[WaitUntilState](#WaitUntilState) `json:"waitUntil"`}
type PageGoForwardOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`
WaitUntil *[WaitUntilState](#WaitUntilState) `json:"waitUntil"`}
type PageGotoOptions struct {
Referer *[string](/builtin#string) `json:"referer"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
WaitUntil *[WaitUntilState](#WaitUntilState) `json:"waitUntil"`}
type PageHoverOptions struct {
Force *[bool](/builtin#bool) `json:"force"`
Modifiers [][KeyboardModifier](#KeyboardModifier) `json:"modifiers"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Position *[Position](#Position) `json:"position"`
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
Trial *[bool](/builtin#bool) `json:"trial"`}
type PageInnerHTMLOptions struct {
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type PageInnerTextOptions struct {
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type PageInputValueOptions struct {
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type PageIsCheckedOptions struct {
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type PageIsDisabledOptions struct {
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type PageIsEditableOptions struct {
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type PageIsEnabledOptions struct {
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type PageIsHiddenOptions struct {
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type PageIsVisibleOptions struct {
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type PageLocatorOptions struct {
Has [Locator](#Locator) `json:"has"`
HasNot [Locator](#Locator) `json:"hasNot"`
HasNotText interface{} `json:"hasNotText"`
HasText interface{} `json:"hasText"`}
type PagePdfOptions struct {
DisplayHeaderFooter *bool json:"displayHeaderFooter"
FooterTemplate *string json:"footerTemplate"
Format *[string](/builtin#string) `json:"format"`
HeaderTemplate *[string](/builtin#string) `json:"headerTemplate"`
Height *[string](/builtin#string) `json:"height"`
Landscape *[bool](/builtin#bool) `json:"landscape"`
Margin *[Margin](#Margin) `json:"margin"`
Outline *[bool](/builtin#bool) `json:"outline"`
PageRanges *[string](/builtin#string) `json:"pageRanges"`
Path *[string](/builtin#string) `json:"path"`
PreferCSSPageSize *[bool](/builtin#bool) `json:"preferCSSPageSize"`
PrintBackground *[bool](/builtin#bool) `json:"printBackground"`
Scale *[float64](/builtin#float64) `json:"scale"`
Tagged *[bool](/builtin#bool) `json:"tagged"`
Width *[string](/builtin#string) `json:"width"`}
type PagePressOptions struct {
Delay *[float64](/builtin#float64) `json:"delay"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type PageQuerySelectorOptions struct {
Strict *[bool](/builtin#bool) `json:"strict"`}
type PageReloadOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`
WaitUntil *[WaitUntilState](#WaitUntilState) `json:"waitUntil"`}
type PageRouteFromHAROptions struct {
NotFound *[HarNotFound](#HarNotFound) `json:"notFound"`
Update *[bool](/builtin#bool) `json:"update"`
UpdateContent *[RouteFromHarUpdateContentPolicy](#RouteFromHarUpdateContentPolicy) `json:"updateContent"`
UpdateMode *[HarMode](#HarMode) `json:"updateMode"`
URL interface{} `json:"url"`}
type PageScreenshotOptions struct {
Animations *[ScreenshotAnimations](#ScreenshotAnimations) `json:"animations"`
Caret *[ScreenshotCaret](#ScreenshotCaret) `json:"caret"`
Clip *[Rect](#Rect) `json:"clip"`
FullPage *[bool](/builtin#bool) `json:"fullPage"`
Mask [][Locator](#Locator) `json:"mask"`
MaskColor *[string](/builtin#string) `json:"maskColor"`
OmitBackground *[bool](/builtin#bool) `json:"omitBackground"`
Path *[string](/builtin#string) `json:"path"`
Quality *[int](/builtin#int) `json:"quality"`
Scale *[ScreenshotScale](#ScreenshotScale) `json:"scale"`
Style *[string](/builtin#string) `json:"style"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
Type *[ScreenshotType](#ScreenshotType) `json:"type"`}
type PageSelectOptionOptions struct {
Force *[bool](/builtin#bool) `json:"force"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type PageSetCheckedOptions struct {
Force *[bool](/builtin#bool) `json:"force"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Position *[Position](#Position) `json:"position"`
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
Trial *[bool](/builtin#bool) `json:"trial"`}
type PageSetInputFilesOptions struct {
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type PageTapOptions struct {
Force *[bool](/builtin#bool) `json:"force"`
Modifiers [][KeyboardModifier](#KeyboardModifier) `json:"modifiers"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Position *[Position](#Position) `json:"position"`
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
Trial *[bool](/builtin#bool) `json:"trial"`}
type PageTypeOptions struct {
Delay *[float64](/builtin#float64) `json:"delay"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type PageUncheckOptions struct {
Force *[bool](/builtin#bool) `json:"force"`
NoWaitAfter *[bool](/builtin#bool) `json:"noWaitAfter"`
Position *[Position](#Position) `json:"position"`
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
Trial *[bool](/builtin#bool) `json:"trial"`}
type PageUnrouteAllOptions struct {
Behavior *[UnrouteBehavior](#UnrouteBehavior) `json:"behavior"`}
type PageWaitForEventOptions struct {
Predicate interface{} `json:"predicate"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type PageWaitForFunctionOptions struct {
Polling interface{} `json:"polling"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type PageWaitForLoadStateOptions struct {
State *[LoadState](#LoadState) `json:"state"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type PageWaitForSelectorOptions struct {
State *[WaitForSelectorState](#WaitForSelectorState) `json:"state"`
Strict *[bool](/builtin#bool) `json:"strict"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type PageWaitForURLOptions struct {
Timeout *[float64](/builtin#float64) `json:"timeout"`
WaitUntil *[WaitUntilState](#WaitUntilState) `json:"waitUntil"`}
type Playwright struct { Selectors Selectors Chromium BrowserType Firefox BrowserType WebKit BrowserType Request APIRequest Devices map[string]*DeviceDescriptor
}
Playwright represents a Playwright instance
Run starts a Playwright instance.
Requires the driver and the browsers to be installed before. Either use Install() or use playwright cli.
func (c *Playwright) On(name string, handler interface{})
func (c *Playwright) Once(name string, handler interface{})
func (c *Playwright) RemoveListener(name string, handler interface{})
Stop stops the Playwright instance
type PlaywrightAssertions interface {
APIResponse(response [APIResponse](#APIResponse)) [APIResponseAssertions](#APIResponseAssertions)
Locator(locator [Locator](#Locator)) [LocatorAssertions](#LocatorAssertions)
Page(page [Page](#Page)) [PageAssertions](#PageAssertions)}
Playwright gives you Web-First Assertions with convenience methods for creating assertions that will wait and retry until the expected condition is met. Consider the following example: Playwright will be re-testing the node with the selector `.status` until fetched Node has the `"Submitted"` text. It will be re-fetching the node and checking it over and over, until the condition is met or until the timeout is reached. You can pass this timeout as an option. By default, the timeout for assertions is set to 5 seconds.
func NewPlaywrightAssertions(timeout ...float64) PlaywrightAssertions
NewPlaywrightAssertions creates a new instance of PlaywrightAssertions
- timeout: default value is 5000 (ms)
type PlaywrightDriver struct { Version string
}
PlaywrightDriver wraps the Playwright CLI of upstream Playwright.
It's required for playwright-go to work.
func NewDriver(options ...RunOptions) (PlaywrightDriver, error)
func (*PlaywrightDriver) Command ¶ added in v0.4400.1
Command returns an exec.Cmd for the driver.
func (d *PlaywrightDriver) DownloadDriver() error
DownloadDriver downloads the driver only
Install downloads the driver and the browsers depending on RunOptions.
Uninstall removes the driver and the browsers.
type Proxy struct {
Server [string](/builtin#string) `json:"server"`
Bypass *[string](/builtin#string) `json:"bypass"`
Username *[string](/builtin#string) `json:"username"`
Password *[string](/builtin#string) `json:"password"`}
type RecordVideo struct {
Dir [string](/builtin#string) `json:"dir"`
Size *[Size](#Size) `json:"size"`}
Whenever the page sends a request for a network resource the following sequence of events are emitted by Page:
- [Page.OnRequest] emitted when the request is issued by the page.
- [Page.OnResponse] emitted when/if the response status and headers are received for the request.
- [Page.OnRequestFinished] emitted when the response body is downloaded and the request is complete.
If request fails at some point, then instead of `requestfinished` event (and possibly instead of 'response' event), the [Page.OnRequestFailed] event is emitted. **NOTE** HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will complete with `requestfinished` event. If request gets a 'redirect' response, the request is successfully finished with the `requestfinished` event, and a new request is issued to a redirected url.
type RequestSizesResult struct {
RequestBodySize [int](/builtin#int) `json:"requestBodySize"`
RequestHeadersSize [int](/builtin#int) `json:"requestHeadersSize"`
ResponseBodySize [int](/builtin#int) `json:"responseBodySize"`
ResponseHeadersSize [int](/builtin#int) `json:"responseHeadersSize"`}
type RequestTiming struct {
StartTime [float64](/builtin#float64) `json:"startTime"`
DomainLookupStart [float64](/builtin#float64) `json:"domainLookupStart"`
DomainLookupEnd [float64](/builtin#float64) `json:"domainLookupEnd"`
ConnectStart [float64](/builtin#float64) `json:"connectStart"`
SecureConnectionStart [float64](/builtin#float64) `json:"secureConnectionStart"`
ConnectEnd [float64](/builtin#float64) `json:"connectEnd"`
RequestStart [float64](/builtin#float64) `json:"requestStart"`
ResponseStart [float64](/builtin#float64) `json:"responseStart"`
ResponseEnd [float64](/builtin#float64) `json:"responseEnd"`}
Response class represents responses which are received by page.
type ResponseSecurityDetailsResult struct {
Issuer *[string](/builtin#string) `json:"issuer"`
Protocol *[string](/builtin#string) `json:"protocol"`
SubjectName *[string](/builtin#string) `json:"subjectName"`
ValidFrom *[float64](/builtin#float64) `json:"validFrom"`
ValidTo *[float64](/builtin#float64) `json:"validTo"`}
type ResponseServerAddrResult struct {
IpAddress [string](/builtin#string) `json:"ipAddress"`
Port [int](/builtin#int) `json:"port"`}
Whenever a network route is set up with [Page.Route] or [BrowserContext.Route], the `Route` object allows to handle the route. Learn more about networking.
type RouteContinueOptions struct {
Headers map[string]string json:"headers"
Method *[string](/builtin#string) `json:"method"`
PostData interface{} `json:"postData"`
URL *[string](/builtin#string) `json:"url"`}
type RouteFallbackOptions struct {
Headers map[string]string json:"headers"
Method *[string](/builtin#string) `json:"method"`
PostData interface{} `json:"postData"`
URL *[string](/builtin#string) `json:"url"`}
type RouteFetchOptions struct {
Headers map[string]string json:"headers"
MaxRedirects *[int](/builtin#int) `json:"maxRedirects"`
MaxRetries *[int](/builtin#int) `json:"maxRetries"`
Method *[string](/builtin#string) `json:"method"`
PostData interface{} `json:"postData"`
Timeout *[float64](/builtin#float64) `json:"timeout"`
URL *[string](/builtin#string) `json:"url"`}
type RouteFromHarUpdateContentPolicy ¶ added in v0.3500.0
type RouteFromHarUpdateContentPolicy string
var ( RouteFromHarUpdateContentPolicyEmbed *RouteFromHarUpdateContentPolicy = getRouteFromHarUpdateContentPolicy("embed") RouteFromHarUpdateContentPolicyAttach = getRouteFromHarUpdateContentPolicy("attach") )
type RouteFulfillOptions struct {
Body interface{} `json:"body"`
ContentType *[string](/builtin#string) `json:"contentType"`
Headers map[[string](/builtin#string)][string](/builtin#string) `json:"headers"`
Path *[string](/builtin#string) `json:"path"`
Response [APIResponse](#APIResponse) `json:"response"`
Status *[int](/builtin#int) `json:"status"`}
RunOptions are custom options to run the driver
type ScreenshotAnimations string
var ( ScreenshotAnimationsDisabled *ScreenshotAnimations = getScreenshotAnimations("disabled") ScreenshotAnimationsAllow = getScreenshotAnimations("allow") )
var ( ScreenshotCaretHide *ScreenshotCaret = getScreenshotCaret("hide") ScreenshotCaretInitial = getScreenshotCaret("initial") )
var ( ScreenshotScaleCss *ScreenshotScale = getScreenshotScale("css") ScreenshotScaleDevice = getScreenshotScale("device") )
var ( ScreenshotTypePng *ScreenshotType = getScreenshotType("png") ScreenshotTypeJpeg = getScreenshotType("jpeg") )
type Script struct {
Path *[string](/builtin#string) `json:"path"`
Content *[string](/builtin#string) `json:"content"`}
type SelectOptionValues struct { ValuesOrLabels *[]string Values *[]string Indexes *[]int Labels *[]string Elements *[]ElementHandle }
SelectOptionValues is the option struct for ElementHandle.Select() etc.
type Selectors interface {
Register(name [string](/builtin#string), script [Script](#Script), options ...[SelectorsRegisterOptions](#SelectorsRegisterOptions)) [error](/builtin#error)
SetTestIdAttribute(attributeName [string](/builtin#string))}
Selectors can be used to install custom selector engines. See extensibility for more information.
type SelectorsRegisterOptions struct {
ContentScript *[bool](/builtin#bool) `json:"contentScript"`}
type ServiceWorkerPolicy string
var ( ServiceWorkerPolicyAllow *ServiceWorkerPolicy = getServiceWorkerPolicy("allow") ServiceWorkerPolicyBlock = getServiceWorkerPolicy("block") )
type Size struct {
Width [int](/builtin#int) `json:"width"`
Height [int](/builtin#int) `json:"height"`}
type StorageState struct {
Cookies []Cookie json:"cookies"
Origins []Origin json:"origins"
}
func (s StorageState) ToOptionalStorageState() *OptionalStorageState
ToOptionalStorageState converts StorageState to OptionalStorageState for use directly in [Browser.NewContext]
The Touchscreen class operates in main-frame CSS pixels relative to the top-left corner of the viewport. Methods on the touchscreen can only be used in browser contexts that have been initialized with `hasTouch` set to true. This class is limited to emulating tap gestures. For examples of other gestures simulated by manually dispatching touch events, see the emulating legacy touch events page.
API for collecting and saving Playwright traces. Playwright traces can be opened inTrace Viewer after Playwright script runs. Start recording a trace before performing actions. At the end, stop tracing and save it to a file.
type TracingGroupOptions struct {
Location *[TracingGroupOptionsLocation](#TracingGroupOptionsLocation) `json:"location"`}
type TracingGroupOptionsLocation struct {
File string json:"file"
Line *int json:"line"
Column *int json:"column"
}
type TracingStartChunkOptions struct {
Name *[string](/builtin#string) `json:"name"`
Title *[string](/builtin#string) `json:"title"`}
type TracingStartOptions struct {
Name *[string](/builtin#string) `json:"name"`
Screenshots *[bool](/builtin#bool) `json:"screenshots"`
Snapshots *[bool](/builtin#bool) `json:"snapshots"`
Sources *[bool](/builtin#bool) `json:"sources"`
Title *[string](/builtin#string) `json:"title"`}
When browser context is created with the `recordVideo` option, each page has a video object associated with it.
type WaitForSelectorState string
type WebError interface {
Page() [Page](#Page)
Error() [error](/builtin#error)}
WebError class represents an unhandled exception thrown in the page. It is dispatched via the [BrowserContext.OnWebError] event.
type WebSocket interface {
OnClose(fn func([WebSocket](#WebSocket)))
OnFrameReceived(fn func([][byte](/builtin#byte)))
OnFrameSent(fn func([][byte](/builtin#byte)))
OnSocketError(fn func([string](/builtin#string)))
IsClosed() [bool](/builtin#bool)
URL() [string](/builtin#string)
ExpectEvent(event [string](/builtin#string), cb func() [error](/builtin#error), options ...[WebSocketExpectEventOptions](#WebSocketExpectEventOptions)) (interface{}, [error](/builtin#error))
WaitForEvent(event [string](/builtin#string), options ...[WebSocketWaitForEventOptions](#WebSocketWaitForEventOptions)) (interface{}, [error](/builtin#error))}
The WebSocket class represents WebSocket connections within a page. It provides the ability to inspect and manipulate the data being transmitted and received. If you want to intercept or modify WebSocket frames, consider using WebSocketRoute.
type WebSocketExpectEventOptions struct {
Predicate interface{} `json:"predicate"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type WebSocketRoute interface {
Close(options ...[WebSocketRouteCloseOptions](#WebSocketRouteCloseOptions))
ConnectToServer() ([WebSocketRoute](#WebSocketRoute), [error](/builtin#error))
OnClose(handler func(*[int](/builtin#int), *[string](/builtin#string)))
OnMessage(handler func(interface{}))
Send(message interface{})
URL() [string](/builtin#string)}
Whenever a `WebSocket` route is set up with [Page.RouteWebSocket] or [BrowserContext.RouteWebSocket], the `WebSocketRoute` object allows to handle the WebSocket, like an actual server would do. **Mocking** By default, the routed WebSocket will not connect to the server. This way, you can mock entire communcation over the WebSocket. Here is an example that responds to a `"request"` with a `"response"`. Since we do not call [WebSocketRoute.ConnectToServer] inside the WebSocket route handler, Playwright assumes that WebSocket will be mocked, and opens the WebSocket inside the page automatically. Here is another example that handles JSON messages: **Intercepting** Alternatively, you may want to connect to the actual server, but intercept messages in-between and modify or block them. Calling [WebSocketRoute.ConnectToServer] returns a server-side `WebSocketRoute` instance that you can send messages to, or handle incoming messages. Below is an example that modifies some messages sent by the page to the server. Messages sent from the server to the page are left intact, relying on the default forwarding. After connecting to the server, all **messages are forwarded** between the page and the server by default. However, if you call [WebSocketRoute.OnMessage] on the original route, messages from the page to the server **will not be forwarded** anymore, but should instead be handled by the “[object Object]”. Similarly, calling [WebSocketRoute.OnMessage] on the server-side WebSocket will **stop forwarding messages** from the server to the page, and “[object Object]” should take care of them. The following example blocks some messages in both directions. Since it calls [WebSocketRoute.OnMessage] in both directions, there is no automatic forwarding at all.
type WebSocketRouteCloseOptions struct {
Code *[int](/builtin#int) `json:"code"`
Reason *[string](/builtin#string) `json:"reason"`}
type WebSocketWaitForEventOptions struct {
Predicate interface{} `json:"predicate"`
Timeout *[float64](/builtin#float64) `json:"timeout"`}
type Worker interface {
OnClose(fn func([Worker](#Worker)))
Evaluate(expression [string](/builtin#string), arg ...interface{}) (interface{}, [error](/builtin#error))
EvaluateHandle(expression [string](/builtin#string), arg ...interface{}) ([JSHandle](#JSHandle), [error](/builtin#error))
URL() [string](/builtin#string)}
The Worker class represents a WebWorker. `worker` event is emitted on the page object to signal a worker creation. `close` event is emitted on the worker object when the worker is gone.