def track_events(target: ElementHandle) -> JSHandle: return target.evaluate_handle("""target => { const events = []; for (const event of [ 'mousedown', 'mouseenter', 'mouseleave', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'click', 'pointercancel', 'pointerdown', 'pointerenter', 'pointerleave', 'pointermove', 'pointerout', 'pointerover', 'pointerup', 'touchstart', 'touchend', 'touchmove', 'touchcancel',]) target.addEventListener(event, () => events.push(event), false); return events; }""")
def trackElementHandle(self, elementHandle: sync_api.ElementHandle, name: str, options: ElementHandleTrackOptions = None): screenshotOptions = _to_dict( options.screenshotOptions) if options else {} screenshot = elementHandle.screenshot(**screenshotOptions) imageBase64 = base64.b64encode(screenshot).decode('ascii') self.track( TestRun( name, imageBase64, options.agent.os if options and options.agent else None, self.browser.name, options.agent.viewport if options and options.agent else None, options.agent.device if options and options.agent else None, options.diffTollerancePercent if options else None, options.ignoreAreas if options else None, ))
def find_toggler(self, node_element: ElementHandle) -> ElementHandle: toggler = node_element.query_selector(".jqtree-toggler") assert toggler return toggler
def el_text(el: ElementHandle): return el.inner_text()