Tests on Angular application not stable

Hi,

We are using RF + Browser library for our Angular (15) based application. Works great, but when running tests from our Azure DevOps pipeline, we experience on average 3 random tests out of 90 which fail. We can’t reproduce this when running tests from our local machines.

Based on the screenshots I think that these fails might be caused by the Javascript not having finished execution. I was wondering if there is something like ‘Wait until network is idle’, but then not for network traffic, but for javascript execution.

Other suggestions / best practices for using RF with Angular are welcome. I wouldn’t like switching to the AngularJs library however, because we like what we have with the Browser library very much.

Thanks in advance for your reaction!

Björn

Hi Bjorn,

Have you tried Wait Until Network Is Idle?

If that doesn’t work, take note of an element that only exist after the javascript is finished and then use Wait For Elements State with a state of attached or visible on that element.

Hope that helps,

Dave.

Hi Dave,

We are currently using ‘Wait until network is idle’, but I’ll add additional ones in locations that might be critical. I will also add element state validations.

I was wondering however whether there would be something like ‘Wait until Script Idle’. We have quite a complex Angular framework with a lot of nested components, observables etc. So it’s difficult I guess to find an element that we can use as a definition of ‘script has finished’.

Thanks!

Björn

Hi Björn,

well this answer was for SeleniumLibrary Wait for complete page load in robot framework - #2 by damies13, however the same thing could probably be achieved with Browser Library using Execute JavaScript or Evaluate JavaScript, or even Wait For Function, i’m not sure which is better for this, but I would try Wait For Function first. Something like this I’d guess:

Wait For Function    return document.readyState == "complete"

or

Wait For Function    return document.readyState == "complete"    //html

I guess you’ll need to play with it and find out, I’ve never done this with Browser Library.

Hope that helps,

Dave.

1 Like

Hi Dave,

I’ve seen this post before I created mine. However, according to the documentation this is related to the loading of the page. At least that’s how I interpreted it. I will try it anyway.

Adding the additional checks for element state and network idle unfortunately didn’t end up with success.

Thanks again!

Björn

1 Like

Hi Björn,

FYI, document is the javascript object for the current page in the browser, readyState is a property of the document which gives you the page status, when it reaches "complete" then all the javascript’s are supposed to be finished executing including all the ones that are triggered by onLoad. "loaded" is the readyState value when all the html has been loaded and parsed, this is the state that triggers all the onLoad javascript functions.

So if you waited for the page to reach "complete" and the element is not there, then it might not get loaded till you interact with the page somehow (mouse over another element?)

If the site is publicly accessable and you can tell me which element you need I can have a look for you if you like.

Dave.

1 Like

Hi Dave,

We’ve been trying out different ways to cope with our challenges. It boils down to that we seem to have a stability issue in the application when starting. In over 95% of the tests everything works out fine, but sometimes the application just doesn’t load when opened from a test that runs on a (Linux) build agent in a DevOps pipeline.

We will first have another look at this.

Björn

1 Like

Hi Björn,

if it’s unstable in Browser on Linux, it will be unstable for all browsers and all OS’s, because it’s the web browser doing the page rendering not Robot Framework.

I guess your automation found an intermittent bug :+1:t3:

Dave.

1 Like