PageSourceSearch

https://playwright.dev/assets/js/35326917.1d4308a9.js

js playwright.dev collected 2026-09-24 06:54:15 UTC 5,106 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkplaywright_dev=self.webpackChunkplaywright_dev||[]).push([["2068"],{45732(e,s,t){t.r(s),t.d(s,{metadata:()=>n,default:()=>d,frontMatter:()=>c,contentTitle:()=>o,toc:()=>l,assets:()=>a});var n=JSON.parse('{"id":"api/class-touchscreen","title":"Touchscreen","description":"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.","source":"@site/versioned_docs/version-stable/api/class-touchscreen.mdx","sourceDirName":"api","slug":"/api/class-touchscreen","permalink":"/docs/api/class-touchscreen","draft":false,"unlisted":false,"tags":[],"version":"stable","frontMatter":{"id":"class-touchscreen","title":"Touchscreen"},"sidebar":"api","previous":{"title":"TimeoutError","permalink":"/docs/api/class-timeouterror"},"next":{"title":"Tracing","permalink":"/docs/api/class-tracing"}}'),r=t(74848),i=t(28453);t(13554),t(41647),t(83137);let c={id:"class-touchscreen",title:"Touchscreen"},o,a={},l=[{value:"Methods",id:"methods",level:2},{value:"tap",id:"touchscreen-tap",level:3}];function h(e){let s={a:"a",admonition:"admonition",code:"code",h2:"h2",h3:"h3",hr:"hr",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,i.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(s.p,{children:["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 ",(0,r.jsx)(s.code,{children:"hasTouch"})," set to true."]}),"\n",(0,r.jsxs)(s.p,{children:["This class is limited to emulating tap gestures. For examples of other gestures simulated by manually dispatching touch events, see the ",(0,r.jsx)(s.a,{href:"/docs/touch-events",children:"emulating legacy touch events"})," page."]}),"\n",(0,r.jsx)(s.hr,{}),"\n",(0,r.jsx)(s.h2,{id:"methods",children:"Methods"}),"\n",(0,r.jsx)(s.h3,{id:"touchscreen-tap",children:"tap"}),"\n",(0,r.jsx)("font",{size:"2",style:{position:"relative",top:"-20px"},children:"Added before v1.9"}),"\n",(0,r.jsx)("x-search",{children:"touchscreen.tap"}),"\n",(0,r.jsxs)(s.p,{children:["Dispatches a ",(0,r.jsx)(s.code,{children:"touchstart"})," and ",(0,r.jsx)(s.code,{children:"touchend"})," event with a single touch at the position (",(0,r.jsx)(s.a,{href:"/docs/api/class-touchscreen#touchscreen-tap-option-x",children:"x"}),",",(0,r.jsx)(s.a,{href:"/docs/api/class-touchscreen#touchscreen-tap-option-y",children:"y"}),")."]}),"\n",(0,r.jsx)(s.admonition,{type:"note",children:(0,r.jsxs)(s.p,{children:[(0,r.jsx)(s.a,{href:"/docs/api/class-touchscreen#touchscreen-tap",children:"touchscreen.tap()"})," will throw if the ",(0,r.jsx)(s.a,{href:"/docs/api/class-browser#browser-new-context-option-has-touch",children:"hasTouch"})," option of the browser context is false."]})}),"\n",(0,r.jsx)(s.p,{children:(0,r.jsx)(s.strong,{children:"Usage"})}),"\n",(0,r.jsx)(s.pre,{children:(0,r.jsx)(s.code,{className:"language-js",children:"await touchscreen.tap(x, y);\n"})}),"\n",(0,r.jsx)(s.p,{children:(0,r.jsx)(s.strong,{children:"Arguments"})}),"\n",(0,r.jsxs)(s.ul,{children:["\n",(0,r.jsxs)(s.li,{children:["\n",(0,r.jsxs)(s.p,{children:[(0,r.jsx)(s.code,{children:"x"})," ",(0,r.jsx)(s.a,{href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type",title:"Number",children:"number"}),(0,r.jsx)("a",{"aria-hidden":"true",tabIndex:"-1",class:"list-anchor-link",id:"touchscreen-tap-option-x"}),(0,r.jsx)("a",{href:"#touchscreen-tap-option-x",class:"list-anchor",children:"#"})]}),"\n",(0,r.jsx)(s.p,{children:"X coordinate relative to the main frame's viewport in CSS pixels."}),"\n"]}),"\n",(0,r.jsxs)(s.li,{children:["\n",(0,r.jsxs)(s.p,{children:[(0,r.jsx)(s.code,{children:"y"})," ",(0,r.jsx)(s.a,{href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type",title:"Number",children:"number"}),(0,r.jsx)("a",{"aria-hidden":"true",tabIndex:"-1",class:"list-anchor-link",id:"touchscreen-tap-option-y"}),(0,r.jsx)("a",{href:"#touchscreen-tap-option-y",class:"list-anchor",children:"#"})]}),"\n",(0,r.jsx)(s.p,{children:"Y coordinate relative to the main frame's viewport in CSS pixels."}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(s.p,{children:(0,r.jsx)(s.strong,{children:"Returns"})}),"\n",(0,r.jsxs)(s.ul,{children:["\n",(0,r.jsxs)(s.li,{children:[(0,r.jsx)(s.a,{href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise",title:"Promise",children:"Promise"}),"<",(0,r.jsx)(s.a,{href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined",title:"void",children:"void"}),">",(0,r.jsx)("a",{"aria-hidden":"true",tabIndex:"-1",class:"list-anchor-link",id:"touchscreen-tap-return"}),(0,r.jsx)("a",{href:"#touchscreen-tap-return",class:"list-anchor",children:"#"})]}),"\n"]})]})}function d(e={}){let{wrapper:s}={...(0,i.R)(),...e.components};return s?(0,r.jsx)(s,{...e,children:(0,r.jsx)(h,{...e})}):h(e)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.