About:blank Chrome Print Dialog

Does anyone know how to interact with any about:blank windows in chrome? I cannot seem to get anything i have tried to work. All I am trying to do is let it open switch to and close it.

1 Like

Hi there,

Thank you very much for your topic. Please note that it may take a little while before a member of our community or from Katalon team responds to you.

Thanks!

int currentWindowIndex = WebUI.getWindowIndex()
String script = 
        var handles = [];
        var titles = [];
        
        handles.push(window.name || window.location.href);
        titles.push(document.title);

        for (var i = 0; i < window.frames.length; i++) {
            var frame = window.frames[i];
            handles.push(frame.name || frame.location.href);
            titles.push(frame.document.title);
        }

        JSON.stringify({ handles: handles, titles: titles });
    
def result = WebUI.executeJavaScript(script, null)
				println("JavaScript result: " + result)
				
				def jsonSlurper = new JsonSlurper()
				def data = jsonSlurper.parseText(result)
				println("Parsed data: " + data)
				
				def windowHandles = data.handles
				def windowTitles = data.titles
				println("Window handles: " + windowHandles)
				println("Window titles: " + windowTitles)

String targetTitle = 'about:blank' 
				int index = windowTitles.indexOf(targetTitle)
				println("Index of target title: " + index)
if (index != -1) {
WebUI.switchToWindowIndex(index)
WebUI.takeScreenshot()
WebUI.closeWindowIndex(index)
WebUI.switchToWindowIndex(currentWindowIndex)
}

Hi @josh.meeks,

Can you try with this if the window has the title

// Wait for the about:blank window to open
WebUI.delay(2)

// Switch to the about:blank window
WebUI.switchToWindowTitle("about:blank")

// Close the about:blank window
WebUI.closeWindow()

or by index

WebUI.switchToWindowIndex(1) // Index starts from 0, so 1 is the second window

// Close the window
WebUI.closeWindow()

I have tried this as well as the index method you suggested. The issue is that there is a print dialog present atop the about:blank window, and either way I cant seem to get Katalon to interact with the window.

Using Robot VK does allow me to close the window but it only works occasionally. I have to manually interact with the window from time to time.

It seems that there is a timing issue with robot vk as well. If I let the window load then robot vk will not close the window, but if I run the keys before the window load has finished it seems to close the window no problem.

1 Like