klassijs/klassi-js

Handling of AJAX calls

Closed this issue · 4 comments

Currently using that library for automation at my firm. I have a question related to handling the ajax calls? we are using v2.3.5 at the moment. Right now I'm making a wait call to see the element is visible or not and perfrom some function after that. The problem is that at local it's working fine but when I run over CI/CD pipeline. It fails. I created a function in helper.js and run a script "jQuery.active == 0". But it was not working as expected. Can you help me out here?

can you tell me the error you are getting in from the CI/CD please

Error: Ajax is not finished
This is the function I used for it.

async function waitUntilAjaxIsFinished(timeout = ajaxTimeout) {
const timeoutMsg = 'Ajax is not finished';
await waitUntilScriptResultIsTrue(() => jQuery.active == 0, timeoutMsg, timeout);
await waitUntilScriptResultIsTrue(() => jQuery.active == 0, timeoutMsg, timeout);
}

I honestly don't use Ajax for making calls to see if elements are visible when there are
isDisplayed
isExisting
isClickable
isEnabled
already built into the webdriverio.

Also why are you calling the same function twice in succession (await waitUntilScriptResultIsTrue(() => jQuery.active == 0, timeoutMsg, timeout);)

That was legacy code and the I'm currently refactoring it. The questions you asked are similar what I had asked already. But thanks.