Skip to content

propagate addCommand to children for multiremote#13904

Merged
christian-bromann merged 1 commit intowebdriverio:mainfrom
ccharnkij:multiremote-addCommand
Nov 22, 2024
Merged

propagate addCommand to children for multiremote#13904
christian-bromann merged 1 commit intowebdriverio:mainfrom
ccharnkij:multiremote-addCommand

Conversation

@ccharnkij
Copy link
Contributor

Proposed changes

For #13836, pass the new command down to the children instances of multiremote browser.

Types of changes

  • Polish (an improvement for an existing feature)
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (improvements to the project's docs)
  • Specification changes (updates to WebDriver command specifications)
  • Internal updates (everything related to internal scripts, governance documentation and CI files)

Checklist

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation (if appropriate)
  • I have added proper type definitions for new commands (if appropriate)

Reviewers: @webdriverio/project-committers

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 21, 2024

Open in Stackblitz

eslint-plugin-wdio

pnpm add https://pkg.pr.new/webdriverio/webdriverio/eslint-plugin-wdio@13904

@wdio/appium-service

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/appium-service@13904

@wdio/browser-runner

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/browser-runner@13904

@wdio/browserstack-service

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/browserstack-service@13904

@wdio/allure-reporter

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/allure-reporter@13904

@wdio/cli

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/cli@13904

@wdio/concise-reporter

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/concise-reporter@13904

@wdio/config

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/config@13904

@wdio/cucumber-framework

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/cucumber-framework@13904

@wdio/dot-reporter

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/dot-reporter@13904

@wdio/firefox-profile-service

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/firefox-profile-service@13904

@wdio/globals

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/globals@13904

@wdio/jasmine-framework

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/jasmine-framework@13904

@wdio/json-reporter

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/json-reporter@13904

@wdio/junit-reporter

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/junit-reporter@13904

@wdio/lighthouse-service

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/lighthouse-service@13904

@wdio/local-runner

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/local-runner@13904

@wdio/logger

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/logger@13904

@wdio/mocha-framework

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/mocha-framework@13904

@wdio/protocols

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/protocols@13904

@wdio/repl

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/repl@13904

@wdio/reporter

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/reporter@13904

@wdio/runner

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/runner@13904

@wdio/sauce-service

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/sauce-service@13904

@wdio/shared-store-service

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/shared-store-service@13904

@wdio/smoke-test-cjs-service

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/smoke-test-cjs-service@13904

@wdio/smoke-test-reporter

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/smoke-test-reporter@13904

@wdio/smoke-test-service

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/smoke-test-service@13904

@wdio/spec-reporter

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/spec-reporter@13904

@wdio/static-server-service

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/static-server-service@13904

@wdio/sumologic-reporter

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/sumologic-reporter@13904

@wdio/testingbot-service

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/testingbot-service@13904

@wdio/types

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/types@13904

@wdio/utils

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/utils@13904

@wdio/webdriver-mock-service

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/webdriver-mock-service@13904

webdriver

pnpm add https://pkg.pr.new/webdriverio/webdriverio/webdriver@13904

webdriverio

pnpm add https://pkg.pr.new/webdriverio/webdriverio@13904

commit: 3a35702

@christian-bromann
Copy link
Member

@ccharnkij thanks for contributing to the project.

Something I would like to understand better is how attaching the custom command to every instance works exactly. Note that when you register a custom command to a multiremote browser, the instance you operate within the custom command will act as a multiremote browser, e.g.:

import { multiremotebrowser } from '@wdio/globals'

multiremotebrowser.addCustomCommand('concatePageTitles', async function (this: WebdriverIO.MultiremoteBrowser) {
	const titles = await this.getTitle() // returns string[]
    return titles.join(' - ')
})

console.log(await multiremotebrowser.concatePageTitles()) // prints "Page A - Page B - Page C

Attaching this custom command to an instance wouldn't make sense because this.getTitle returns a different type of result.

I haven't really explored this use case thoroughly but this is what I expected it to work. Mind providing more context?

@ccharnkij
Copy link
Contributor Author

Yes, you are correct on that. The this object for the browser and instances are different and if, using your example, the call is made from an instance, then the output would only be the title of the page that an instance is on. I think the use case will depend on the user. The user will have take into account the different this, if it's being used, when making a new function.

@christian-bromann
Copy link
Member

@ccharnkij thanks for clarifying, mind pushing a change to the Custom Commands docs on how to handle custom commands with Multiremote?

@ccharnkij
Copy link
Contributor Author

better?

@ccharnkij
Copy link
Contributor Author

Looks like this here is the issue from the latest commits to main in the element.test.ts.

const combinedPrototype = [
        ...new Set([...elementPrototype, ...files])
    ]

@ccharnkij ccharnkij force-pushed the multiremote-addCommand branch from 4b2cb7d to 3a35702 Compare November 22, 2024 17:57
Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@christian-bromann christian-bromann added the PR: Polish 💅 PRs that contain improvements on existing features label Nov 22, 2024
@christian-bromann christian-bromann merged commit 45c5627 into webdriverio:main Nov 22, 2024
@wdio-bot
Copy link
Contributor

Hey ccharnkij 👋

Thank you for your contribution to WebdriverIO! Your pull request has been marked as an "Expensable" contribution.

We've sent you an email with further instructions on how to claim your expenses from our development fund.
Please make sure to check your spam folder as well. If you have any questions, feel free to reach out to us at expense@webdriver.io or in the contributing channel on Discord.

We are looking forward to more contributions from you in the future 🙌

Have a nice day,
The WebdriverIO Team 🤖

@ccharnkij
Copy link
Contributor Author

@christian-bromann Btw, I saw another issue on implementing the UI. Not sure how helpful I can be, but I'd love to join.

@christian-bromann
Copy link
Member

@ccharnkij awesome, please reach out in the contributor channel on Discord. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Expensable $35 💸 PR: Polish 💅 PRs that contain improvements on existing features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants