2.4.2 - Example test failing in pipeline only

Hey, I commented on a similar post, but I think it’s not behaving normally, since that thread is already closed: 2.4.2 - Example test failing on GitHub Actions - #7 by cassandrahl

I’m on module 2.4.2 of MoT’s Foundation Certificate in Test Automation (JS version), and one of the example tests is failing only when it’s run in the pipeline because of not finding the .card-title element; locally, it’s fine.

I already tried the suggested sleep 10 command and curl --head -X GET --retry 60 --retry-connrefused --retry-delay 1 http://localhost:3000 in the .yml file, as well as adding await browser.pause(2000) before the call for the element, but I’m still getting the same error. I even increased it to 15000, just to be sure.

Do any of you have ideas as to what else I can try? I want to solve this before continuing with the course. Thanks!

1 Like

Havent used wdio before, but is there a config to enable videos or screenshot of the test runs? If you can do that then update the github actions to make the video available.

Feel if you can’t see what the pipeline is doing will be tricky to know whats going on here.

Otherwise maybe try logging the url before the button click and after , then before the await card title and after also and see what page its on. Assuming the button click takes you to another url?

1 Like

Thanks for the great suggestions!

I added a URL log, which shows that the page isn’t changing after login. I added a wait for the URL to change, but even after 60 seconds, it stays the same. I tried to add screenshots, but I can’t get that working in the pipeline either, only locally. I’m kind of going round in circles…

The test did pass in the pipeline randomly twice, which shows that it can work, but upon rerunning the job against the same commit, it always failed.

1 Like

Hi,

Just to confirm, is this running locally without issue? I’ll DM you and perhaps we can debug this together over a call?

2 Likes

Yes, it always works locally. That would be great, thanks!

you can try adding a visibility check for the element If its visible then only apply any other operation on it.

Something on below lines

Explicit wait
// Wait for element to exist
$(‘selector’).waitForExist({ timeout: 15000 });

// Wait for element to be visible
$(‘selector’).waitForDisplayed({ timeout: 15000 });

// Wait for element to be clickable
$(‘selector’).waitForClickable({ timeout: 15000 });

Custom waits
browser.waitUntil(() => {
return $(‘selector’).getText() === ‘Expected Text’;
}, {
timeout: 15000,
timeoutMsg: ‘Expected text not found within 5s’
});

Try above 2 and you can put more than 15 seconds as well for the first go to lets say 60 seconds to check out.

Mostly its a loading issue which can be solved by waits

Thanks for the suggestion! I managed to resolve the issue by changing the OS: 2.4.2 - Example test failing on GitHub Actions - #10 by mwinteringham

2 Likes