Xpath on pop-up doesn't seem to exist

I’ve struggled with a problem which seems pretty easy to solve, but I can’t seem to get it right.

On the page I’m writing the test for, the user meets a pop-up message.

I tried this code in order to close the pop-up:

TestObject luk = new TestObject(‘Object Repository/Smoketest/Page/div__cf-container__close’)



WebUI.waitForElementVisible(luk, 8)


But, I get the following error:
12-28-2019 07:40:44 AM Test Cases/Smoketest

Elapsed time: 59.677s

Test Cases/Smoketest FAILED.
com.kms.katalon.core.exception.StepFailedException: Unable to click on object ‘Object Repository/Smoketest/Page/div__cf-container__close’
Caused by: org.openqa.selenium.WebDriverException: chrome not reachable

I defined the object by using the Inspct tool in Chrome > Copy > Xpath

What do I do wrong?


When you post an error message, make sure you capture the “Caused by” part.

More advice here:

Here, you create a new instance of testobject, before a browser driver is instantiated. Why such approach?

I’ve edited my original post with your improvement.

The caused by message is here:
Caused by: org.openqa.selenium.WebDriverException: chrome not reachable
_ (Session info: chrome=79.0.3945.88)_

I also added the “caused by” part to the main post.

If you put the line with testobject = blah after the openBrowser in your code, there is any improvement?

1 Like

I moved the code line, so it looks like this now:

siteName = ‘site’



TestObject luk = new TestObject(‘Object Repository/Smoketest/Page/div__cf-container__close’)

WebUI.waitForElementVisible(luk, 8)


Now I get this error:

Caused by: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: ‘Object Repository/Smoketest/Page/div__cf-container__close’ located by 'By.xpath: ’ not found

TestObject luk = findTestObject('Object Repository/Smoketest/Page_UddannelsesGuiden/div__cf-container__close')
1 Like

Thanks, Russ!

So far so good - the test case runs succesfully.
However, the pop-up window on the site does not close.

I run the code:
siteName = ‘site’



WebUI.delay (6)

TestObject luk = findTestObject(‘Object Repository/Smoketest/Page/div__cf-container__close’)



The pop-up hasn’t closed.

I need to see the HTML behind the close button. You can use DevTools to take a screenshot of the HTML.

Here you go:
The URL for the page is: ug.dk

The popup does not appear when I visit that URL.

I see it in Chrome. I’m guessing the site uses tracking which Firefox prevents but Chrome allows.

You need to look at your XPath again. Using a CSS locator works fine. You can try this in the browser console to see it work:

document.querySelector("#colorbox +div .cf-container .cf-container__close").click()

If you want to switch to CSS, use this selector in your TestObject definition:

#colorbox +div .cf-container .cf-container__close

There is also a JavaScript error on the page:

“Implicit Consent” - that would be funny if it wasn’t so invasive. Who are these people? :rage:

Thanks, Russ.

I tested the function in the console as you suggested - worked perfectly.
However, I’ve changed the selector to CSS in Katalon, and the popup still don’t close via Katalon.

So - the test execution is “Passed” but this i not reflrected in the UI

I’ve solved it! Thanks for your help, guys!