Stop page load forcefully

Is there a way to simulate clicking on ‘X’ icon of the browser while the page is loading.

WebUI.sendKeys(findTestObject('some object on the page'), Keys.chord(Keys.ESCAPE))

I tried to do the above, but the issue is until the ‘X’ is clicked, none of the objects on the page gets detected.

So when I run my test and stop the browser loading manually, then objects on the page gets detected and test passes.

I am looking for a way to simulate this.

try this WebUI.executeJavascript(‘window.stop()’,null)

Are you certain about that? That doesn’t sound like the correct diagnosis.

@lucas2
It says

expecting ')', found '’' @ line 39, column 39.

Can you confirm if what you share is syntactically correct?

@Russ_Thomas
Yes, I am because when the new window opens, my test is doing WebUI.verifyelementvisible() on one of the objects on new tab.

When I switch to the new handle, the new page keeps loading forever, but as soon as I click on ‘X’ icon on my browser manually, the test finds the object instantly and passes.

Just to add to this, when I follow this scenario on regular chrome browser (the one that is not being controlled by automated test software) the new page loads successfully instantly. But for some reason, when the same scenario is executed on the browser instance initiated by Katalon, the page keeps loading forever.

And after 300 seconds, the test stops, fail and throw timeout error. At that same instance, the page stops loading.

Which is the correct behavior because the test has failed – no human would wait 300 seconds, so timing out at that point and failing the test is reasonable behavior.

Here’s my diagnosis…

The page is waiting for something to arrive from the server. It never arrives.

You should try to find out what is hung up using the network tab in DevTools. Then, submit a report to the developers and explain their server is not responding in a timely manner.

Clicking the stop-loading button is not a valid means of completing a test case. Web pages should load in a timely manner and allow the test case to complete normally.

@Russ_Thomas

Yes, that sounds about right. Thanks

sorry, I made a mistake it’s WebUI.executeJavaScript(‘window.stop()’,null)