Skip to content
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

Feature/5 multiremote support #6

Merged
merged 7 commits into from
May 27, 2021
Merged

Conversation

elaichenkov
Copy link
Member

feature: #5 Multiremote support

Added:

  • multiremote tests
  • util functions for getting element and elements

Updated:

  • arrow functions > function declaration
  • use this instead of the browser instance
  • tests

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.

How difficult is it to make this work with multiremote as well:

      it('should verify urlContains method', async () => {
        await browser.url('https://webdriver.io');
        expect(await urlContains('io')).toBe(true);
      });

?

@elaichenkov
Copy link
Member Author

How difficult is it to make this work with multiremote as well:

      it('should verify urlContains method', async () => {
        await browser.url('https://webdriver.io');
        expect(await urlContains('io')).toBe(true);
      });

?

It will not work with a single instance and multiremote either.
Because we have to return a function.
So, this function urlContains('io') returns another function where we have logic.
Maybe you meant to make it urlContains('io')()?
I can check this and if it's undefined, then I'll use the browser instead of this, and in multiremote case, the urlContains('io')() method will return an array of booleans[false, true], and in a single instance, the urlContains('io')() method will return just boolean.

@christian-bromann
Copy link
Member

Yeah, in the original issue my example was referring to a single browser instance:

const matrix = await multiremote({ browser1: {...} })
await matrix.browser1.waitUntil(
   titleContains('expected conditions'),
   {
      timeout: 5000,
      timeoutMsg: 'expected title....'
   }
)

but I wonder if we can also allow:

await matrix.waitUntil(
   titleContains('expected conditions'),
   {
      timeout: 5000,
      timeoutMsg: 'expected title....'
   }
)

in which case the conditions need to be fulfilled for all browser instances.

@elaichenkov
Copy link
Member Author

Yeah, in the original issue my example was referring to a single browser instance:

const matrix = await multiremote({ browser1: {...} })
await matrix.browser1.waitUntil(
   titleContains('expected conditions'),
   {
      timeout: 5000,
      timeoutMsg: 'expected title....'
   }
)

but I wonder if we can also allow:

await matrix.waitUntil(
   titleContains('expected conditions'),
   {
      timeout: 5000,
      timeoutMsg: 'expected title....'
   }
)

in which case the conditions need to be fulfilled for all browser instances.

Actually, it works now.
I've just tested the following cases:

      // Passed
      it('should pass for specific instance urlContains method', async () => {
        await browser.url('https://the-internet.herokuapp.com')
        await browserB.url('https://webdriver.io/docs/wdio-wait-for/#api');
    
        //@ts-ignore
        await browser.browserB.waitUntil(
          titleContains('expected conditions'),
          {
            timeout: 1000,
            timeoutMsg: 'expected title for browser B'
          }
        )
      });

      // Passed
      it('should pass for two instances urlContains method', async () => {
        await browser.url('https://webdriver.io/docs/wdio-wait-for/#api')

        await browser.waitUntil(
          titleContains('expected conditions'),
          {
            timeout: 1000,
            timeoutMsg: 'expected title for two instances'
          }
        )
      });

       // Failed
      it('should fail for two instances urlContains method', async () => {
        await browser.url('https://the-internet.herokuapp.com');
        await browserB.url('https://webdriver.io/docs/wdio-wait-for/#api');

        await browser.waitUntil(
          titleContains('expected conditions'),
          {
            timeout: 1000,
            timeoutMsg: 'expected title for two instances'
          }
        )
      });

@christian-bromann
Copy link
Member

Do we need to enhance the tests or do they already cover this?

@elaichenkov
Copy link
Member Author

They cover it, in our tests I do the same, except I don't use the waitUntil method to focus only on our prediction functions.

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.

Awesome, shit it :shipit:

@elaichenkov elaichenkov merged commit 0f379e8 into main May 27, 2021
@elaichenkov elaichenkov deleted the feature/5-multiremote-support branch May 27, 2021 11:41
@christian-bromann
Copy link
Member

@elaichenkov to release trigger the Manual NPM Publish action and set Release type to minor and keep NPM tag at latest

@elaichenkov
Copy link
Member Author

@christian-bromann
Thank you!
There were few issues with npm script and github token, which I've fixed and it works now. Published 2.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants