{"record":{"id":"36e7a4db96595e5d","repo":"grafana/k6","slug":"dispatching-locator-event-q-to-q-w","errorCode":null,"errorMessage":"dispatching locator event %q to %q: %w","messagePattern":"dispatching locator event %q to %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/locator.go","lineNumber":638,"sourceCode":"\t\treturn fmt.Errorf(\"tapping on %q: %w\", l.selector, err)\n\t}\n\n\tapplySlowMo(l.ctx)\n\n\treturn nil\n}\n\n// DispatchEvent dispatches an event for the element matching the\n// locator's selector with strict mode on.\nfunc (l *Locator) DispatchEvent(typ string, eventInit any, opts *FrameDispatchEventOptions) error {\n\tl.log.Debugf(\n\t\t\"Locator:DispatchEvent\", \"fid:%s furl:%q sel:%q typ:%q eventInit:%+v opts:%+v\",\n\t\tl.frame.ID(), l.frame.URL(), l.selector, typ, eventInit, opts,\n\t)\n\n\topts.Strict = true\n\tif err := l.frame.dispatchEvent(l.selector, typ, eventInit, opts); err != nil {\n\t\treturn fmt.Errorf(\"dispatching locator event %q to %q: %w\", typ, l.selector, err)\n\t}\n\n\tapplySlowMo(l.ctx)\n\n\treturn nil\n}\n\n// WaitFor waits for the element matching the locator's selector with strict mode on.\nfunc (l *Locator) WaitFor(opts *FrameWaitForSelectorOptions) error {\n\tl.log.Debugf(\"Locator:WaitFor\", \"fid:%s furl:%q sel:%q opts:%+v\", l.frame.ID(), l.frame.URL(), l.selector, opts)\n\n\topts.Strict = true\n\t_, err := l.frame.waitFor(l.selector, opts, 20)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"waiting for %q: %w\", l.selector, err)\n\t}\n\n\treturn nil","sourceCodeStart":620,"sourceCodeEnd":656,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/common/locator.go#L620-L656","documentation":"Wrapped failure from Frame.dispatchEvent while dispatching the named DOM event on the element matched by the locator's selector (strict mode forced). Fires on zero/multiple matches or when the CDP evaluation that triggers the event constructor/dispatch fails (e.g. unknown event type in the page context).","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/locator.go:638 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a standard event type name (e.g. 'click', 'submit', 'keydown') understood by the page","Ensure the selector matches exactly one attached element","Pass a valid eventInit object matching the event's constructor"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}