-
Notifications
You must be signed in to change notification settings - Fork 14
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
Using this with cucumber doesn't seem to work #29
Comments
Hi there 👋 Thanks for raising this. I wasn't able to reproduce the issue, but I did have to change the example to await(await browser.$(`button*=${this.text}`)).waitForDisplayed() I think support for async chaining has been added recently in WebdriverIO v7.9, is that the version you are using? I've pushed my branch and run the tests in an action in case you wanted to have a look / compare the differences in setup and stuff. 😄 (the tests results are in the I'm hoping it's the potentially missing |
Well, I have 2 end-2-end tests that work with just webdrive-io and cucumber combo. When I add this library, and thus get the following code, they fail. The following is a piece of "page object" that I updated to use the I get the error " Cannot read property 'waitForDisplayed' of null", so it seems this library can't find the elements, while webdriver-io does.
Using the following dependencies:
|
Hi again, sorry for the slow response! I've been on holiday 😄 Thanks for the extra information, I've aligned our package versions but unfortunately I'm still unable to reproduce the problem. I am able to reproduce the error you are getting, but only when that the element is not currently in the DOM when you execute async waitForLoaded() {
const { findByText } = setupBrowser(browser)
await findByText(/Welcome/i, {}, { timeout: 5000 }) // where the timeout matches your wdio timeout
} The reason I think that might help it is that the Would you mind also trying the following to verify what the WebdriverIO selector is finding in your case? async waitForLoaded() {
const message = await browser.$('h1*=Welcome')
console.log(message)
console.log('wait for displayed...')
await message.waitForDisplayed();
console.log('elementId': message.elementId)
} If the element does not exist when
If using a Anyways let me know how you get on 😁 |
Ok, I'm back from vacation and trying this out. If I just replace the When I then went on and executed your logs, I see that there is an element found, so the following:
Gives me these logs:
|
So let me state my config and test, maybe you can see something missing or different about it. package.json script
package.json dependencies (listing more dependencies which are used for unit testing but not for e2e testing, because maybe this library does some auto-loading that conflicts?)
wdio.conf.js
webdriverDefaultConfig
chromeDefaultConfig
our-feature.feature
auth-login.steps.ts
auth-login.fragment.ts
|
Giving this another try, without any luck. I see strange logs when I run the tests: Could this be because cucumber is driven by @wdio directly? |
Another thing I notice is that when the element can't actually be found, I do get an error thrown that this is the case. When I use a selector that finds the element, I just get
So it appears that the label can indeed be found, because otherwise I see an error being thrown, but the function gives back |
Hmm that is very interesting! That shouldn't be happening for sure. Possibly I'm executing the wrong underlying dom-testing-library query then because findBy should never return null... I'll have to investigate. Sorry for the radio-silence, I left this alone in the hope I'd have some fresh ideas when I got back to it. I'm going to have another go at reproducing the issues you are finding. I'll let you know if I find anything! |
Oh these logs are because this library needs to inject some dependencies into the browser env, specifically dom-testing-library and simmer. The first execute call is to check whether dom-testing-library or simmer need to be injected, and the second execute call (and the gnarly looking log) are dom-testing-library being injected by executing it's umd distribution. |
@dietergeerts I unfortunately still haven't been able to reproduce what you are finding. Would you be interested in connecting over discord sometime to debug it together? Otherwise I think a repro would help, I'm struggling to find the problem as it stands 😭 |
I have the same problem and after digging into it, I found out that the problem is the serialization of the returned elements in the .executeAsync call to the browser. If done manually with JSON.stringify, it complains about circular references, which are introduced by __reactFiber* and __reactProps* fields. If I replace the HTML element in the result by something else, it works fine (but only for queries that return a selector). So that would point in the direction of React Fibre causing these issues. |
Hi @markusmeyer, Thank you for letting us know what you found! I have just checked and trying to serialize elements with circular references does cause the result to be null or an empty array so this could be the underlying issue. It looks like the issue is similar to this one, except in our case we need to serialize the element to send it back from the browser rather than a worker. Anyways I think I have a fix which I will push up tomorrow 🥳 |
I've realised I made a mistake when I reproduced this yesterday, I had crashed the toy react app I was using which is why the element wasn't found. It does look like Webdriver deals with circular references on HTML elements in some way when sending them back to from executeAsync. I'm going to dig deeper however as the issues in jest with React fibre seem to be difficult to reproduce. It could be that the underlying Webdriver version could have an impact too so I'll try exploring that. @markusmeyer Would you be able to provide a repo / snippet with the code that failed for you? I do think this is a good area to keep exploring! |
@olivierwilkinson , is there any further progress on this? We're starting to write more and more unit tests, so it would be easier to write them with these helpers, and more maintainable. |
Hi @dietergeerts, sadly not. I tried going through multiple underlying versions and examples but wasn't able to pin down the culprit. I would really appreciate a repro if you are able to provide me with one, I've been trying various things but it's more or less guess work at the moment. I know that providing a repro might be a decent amount of work but I promise I'll dedicate myself to getting it fixed as soon as possible afterwards! I really want to get it fixed also 🙏 |
@olivierwilkinson , is there any template I can use to quickly create a repro? |
Not for this project no, but I do have a branch that I was using as a test bed: test-cucumber-support. I wasn't able to reproduce the issue on that branch though and it's likely to be something we haven't thought of that is specific to your project, so probably the easiest way is to clone your project into a new repo and remove everything unrelated and/or sensitive. |
By default, wdio uses |
Thank you for this! 🙌 I'll look into that as soon as I can, probably Monday as I am away this weekend. |
I did a bit more digging. I believe the following combination doesn't work well: In the end, I decided to make some modifications to the lib so it would work for my project. What I did is, I completely avoid sending the HTML element as part of the Here is the change: segovia@bd1e508 @olivierwilkinson Do you think it makes sense to integrate some or all of these changes to this code base? |
Oh interesting! I think the strategy of adding a custom id to create a selector from might break some wdio behaviours with retrying stale selectors but I might be wrong, there should be a failing test if my suspicions are correct. Definitely raise a PR though because we can figure that out and iterate on what you have here 😁. I'll also try to set up a React app in the tests so we can check the Fiber stuff. Thanks for digging further on this! Really appreciate it 🙌 |
Just to keep everyone in the loop I have a reproduction locally, once I have time I'll update the tests to include a case for this scenario 😄 It is a problem when testing production React apps with the default WebdriverIO config, which uses Puppeteer under the hood to drive the browser. Using the selenium-standalone or chromedriver service seems to fix it for me. @dietergeerts if that doesn't fix the issue for you please let me know. 🤞 Once I've updated the test setup with a failing test I'll move on to look at the PR @segovia has raised more closely 😄 Thanks everyone for adding info as they found it and being patient! 🙌 |
@dietergeerts I have just published v3.0.7 which I think will fix the issues you have been finding! Big thanks to @segovia for the PR 🙌 Let me know if it works for you and then I'll close this 😄 |
Apologies for not responding. We are currently in a merger of 2 companies, and thus there is no time/effort we can do on checking this out. When we can move further with this, I'll sure will check it out and let you know if it works or not in our use-case. Thx for all the work done! |
Hi,
I'm trying to use this for our end-2-end testing with cucumber, but it doesn't seem to work.
Is it a known issue that it doesn't work with cucumber, or perhaps it can be something else? Any pointers would be helpful. I would like to use this as we already use it for our unit tests, and it makes us write better code, by making sure our application is semantically correct.
The text was updated successfully, but these errors were encountered: