function sendTouchEvent(x, y, element, eventType) { const touchObj = new Touch({ identifier: Date.now(), target: element, clientX: x, clientY: y, radiusX: 2.5, radiusY: 2.5, rotationAngle: 10, force: 0.5, }); const touchEvent = new TouchEvent(eventType, { cancelable: true, bubbles: true, touches: [touchObj], targetTouches: [], changedTouches: [touchObj], shiftKey: true, }); element.dispatchEvent(touchEvent); } async function tapElement (element) { const { x, y } = element.getBoundingClientRect() const intX = parseInt(x) const intY = parseInt(y) const touchstart = 'touchstart' const touchend = 'touchend' sendTouchEvent(intX, intY, element, touchstart) await new Promise(resolve => setTimeout(resolve, 100)) sendTouchEvent(intX, intY, element, touchend) } const elemetToTouch = $x('//*[@id="root"]/main/div/div[2]/div[2]/div/div[1]/button/h5')[0] tapElement(elemetToTou