New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[🐛 Bug]: custom element commands doesn't work with browser runner #12717
Comments
Can you provide a minimal reproducible example? |
Thanks for raising this issue 🙏 Unfortunately we can't help you without a reproducible example in this matter. Please read our contributing guidelines on how to create a reproducible example. If you can't provide a reproducible example we will close this issue in 7 days. If you have any questions please reach out to us on our Discord channel. We are happy to help you out there. |
Yes, of course - https://github.com/DudaGod/wdio-issue-12717 |
Thanks for providing the reproduction case, this is indeed a bug. Custom commands on the browser instance are supported but miss the part that allow to register it on
diff --git a/packages/wdio-utils/src/monad.ts b/packages/wdio-utils/src/monad.ts
index 8262c7a43..949ca0bc9 100644
--- a/packages/wdio-utils/src/monad.ts
+++ b/packages/wdio-utils/src/monad.ts
@@ -125,6 +125,7 @@ export default function WebDriver (options: Record<string, any>, modifier?: Func
type: MESSAGE_TYPES.customCommand,
value: {
commandName: name,
+ attachToElement,
cid: process.env.WDIO_WORKER_ID,
}
}
diff --git a/packages/wdio-browser-runner/src/communicator.ts b/packages/wdio-browser-runner/src/communicator.ts
index 850e6b449..c74241999 100644
--- a/packages/wdio-browser-runner/src/communicator.ts
+++ b/packages/wdio-browser-runner/src/communicator.ts
@@ -74,7 +74,7 @@ export class ServerWorkerCommunicator {
this.#customCommands.set(cid, new Set())
}
const customCommands = this.#customCommands.get(cid) || new Set()
- customCommands.add(commandName)
+ customCommands.add({ commandName, attachToElement })
return
}
diff --git a/packages/wdio-browser-runner/src/browser/driver.ts b/packages/wdio-browser-runner/src/browser/driver.ts
index 2fba887a3..770a8c7e6 100644
--- a/packages/wdio-browser-runner/src/browser/driver.ts
+++ b/packages/wdio-browser-runner/src/browser/driver.ts
@@ -251,8 +251,8 @@ export default class ProxyDriver {
if (!cid) {
return
}
- for (const commandName of value.customCommands) {
- browser.addCommand(commandName, this.#getMockedCommand(commandName))
+ for (const {commandName, attachToElement} of value.customCommands) {
+ browser.addCommand(commandName, this.#getMockedCommand(commandName), attachToElement)
}
}
Contributions for this would be much appreciated, I am happy to help. |
Thanks for reporting! We greatly appreciate any contributions that help resolve the bug. While we understand that active contributors have their own priorities, we kindly request your assistance if you rely on this bug being fixed. We encourage you to take a look at our contribution guidelines or join our friendly Discord development server, where you can ask any questions you may have. Thank you for your support, and cheers! |
Can we send here only |
Commands can only get executed on a single element, therefore a single element reference should suffice. |
Have you read the Contributing Guidelines on issues?
WebdriverIO Version
latest
Node.js Version
18.12.1
Mode
Standalone Mode
Which capabilities are you using?
Relevant log output
The text was updated successfully, but these errors were encountered: