Unable to close a ui-dialog in Katalon Studio

I have a custom keyword to handle the Accept button of an ui-dialog . I see in the console mode that the script is running but the ui-dialog doesn’t close and i cann´t continue with the rest of the script.

The custom keyword is:

public class UidialogClick {

@Keyword

def clickUsingJS (TestObject to) {

WebDriver driver = DriverFactory.getWebDriver()

WebElement element = WebUiCommonHelper.findWebElement(to, 30)

JavascriptExecutor executor = ((driver) as JavascriptExecutor)

executor.executeScript(‘arguments[0].click()’, element)

}

and i am calling it from the script as follows:

dynamicObject = findTestObject(‘Object Repository/Page_Declaraciones por internet (12)/span_Aceptar’)

WebUI.scrollToElement(dynamicObject, 1)

WebUI.waitForElementClickable(dynamicObject, 3)

CustomKeywords.‘customKeywordsF102A.UidialogClick.clickUsingJS’(dynamicObject)

Hi Fernanda

Do you see an error message?

Does the element scroll into view?

What selection methods are used to locate the object: ‘Object Repository/Page_Declaraciones por internet (12)/span_Aceptar’ ? CSS? xpath? something else?

I suspect the method chosen is not working – but with an error message, it’s hard to say.

Hi Fernanda,

I have the same problem when using the default Accept Alert keyword. I worked around the issue by running my script in Chrome rather than Firefox. This may fix the issue for you as well, but Hoping Katalon devs can find a better fix that allows for both browsers to handle the alert.

WebUI.acceptAlert()
is supposed to catch the alert window, and click ok.

Hi Fernanda,

I am having a similar issue when using the default Accept Alert Keyword - WebUI.acceptAlert()
When I run my test on Firefox, I see the alert box pop-up, but I can’t see the OK button clicked, nor does the pop-up close. The test also stalls, without executing the next step. I also see no error message in debug.

I was able to work-around this by executing my test in Chrome. In Chrome, the pop-up shows as expected, the Accept Alert executes and closes the pop-up with OK selected.

@Russ Thomas In my case, I am simply clicking on my main page, and that produces and Alert pop-up. The Accept Alert should automatically find and interact with the pop-up. In Firefox, this doesn’t seem to be the case, but in Chrome it works as expected.

If anyone has a suggestion to use this function in Firefox as well as Chrome, it would be appreciated.

Maybe you need to wait a while?

    WebUI.waitForAlert(10)
    WebUI.delay(1)
    WebUI.acceptAlert()

The key thing is the first line, which waits for an alert to appear before trying to accept an alert on line 3. It’s entirely possible that the geckodriver (Firefox) is getting ahead of you.

The second line is optional - it’s only there to give you a chance to see the alert dialog.

Hope it helps you.

Russ

Hi Russ and Jas. Thanks for your answers. I reviewed the selection method and i was using the basic method to select the object, so i changed the method to Xpath and i could to continue with the flow of my test.