Object not found in Docker KRE but found in Local KRE or Katalon Studio

Hello,

I am configuring our CI to run tests via KRE in docker image. We are in a GitLab CI environment.

All seems good about pulling a Katalon project and running a chosen test suite collection, but when we run this TSC on the Katalon Docker image, it fails because of an object not found in page.

What I don’t understand is that TSC is working fine on Katalon Studio and it is also OK when I execute it with local KRE with the same command line.

Elements for analysis :

Versions in docker :
Google Chrome 97.0.4692.99
INFO: Katalon Version: 8.2.5

Versions in local env :
Google Chrome 99.0.4844.83
INFO: Katalon Version: 8.2.5

The GitLab CI config with command used to run TSC :

The spy element we are looking for :

The error in Docker KRE :

And the part of the source code page just before waiting for the element not found, I added 2 lines of code to capture and log it just before the wait instruction : (In green, the element found just before and OK, in yellow the element searched but not found)

Finally, the piece of code where the error is raised : (As before, in green the code which is OK just before and in yellow the error)

I didn’t found a ticket which describes the problem, sorry if another one exists.
I stay available to give more elements if it’s needed and thank you for your help.

Good job on this part, this is what I do when running headless/docker as well. A couple things that may help us:

1.) Instead of doing KeywordUtil.logInfo(mySource), can you instead just do a simple print of the data? The logging class can sometimes add unnecessary formatting to your data. We need the raw HTML.
2.) Once you get the raw HTML, put it into a formatter and repost a screenshot. It’s hard to read the HTML snippet as it is now.
3.) Assuming you get the raw HTML, save that data as a file (test.html or whatever) and open it in a browser. Can you see the button you’re trying to wait for?

Hello @Brandon_Hein,

Thank you for your reply.

I’ve made what you asked to me by writing the source code into an html file directly and saved it as an artifact.
So, I have a result (not easy to read with white on light grey, sorry for that) :

It’s interesting to see the modal on the page, I don’t know if it could interfere with the test.
I will try to save source code before filling input too and see if this modal is already here and I will also try to close it before starting the all test scenario.

I’m coming back here tomorrow with my results, don’t hesitate to ping me if you have another idea or if you see something that I missed.

Understood. I would definitely try and address the modal before doing anything else, as you say. One other thing to look at: are you sharing the entire error log? Sometimes there’s a “Caused by:” statement that contains more information on your error. The part of the error you shared doesn’t really state why it wasn’t able to wait for clickable, and I suspect there’s more to it. Depending on your answers tomorrow, I have a few ideas on how to proceed.

The next “caused by” is the last and it is just saying that the object is null.

And I just noticed that the screen snapshot in report when the error is raised is showing the page without modal.

The next “caused by” is the last and it is just saying that the object is null.

Ok that is the actual problem here. Let me clarify some terms here:

  • A Test Object is a Katalon-specific term. It is nothing more than a container for a locator to eventually find an element on a web page during script execution.
  • An element is an HTML tag on a web page. This is what you actually interact with when you call click(), setText(), etc.

It’s important to understand the difference here. To reiterate, a Test Object is just Katalon’s way to provide you a container for a locator that will ultimately find an element when your script runs.

Now, the “Caused by” in your error is saying that the Object (i.e. Test Object) is null. This is not the same thing as the element not existing on the page. What it really means is that when you called:

findTestObject('Object Repository/SpyElements/1_Page_Registration/00_Code_parrainage/button_okCodeParrainage')

a null was returned, instead of the target Test Object.

Now we need to investigate why this is. When you run it locally, outside of docker it works fine. So the question is, does that Test Object exist in your docker container? I’m not familiar with Katalon’s specific docker implementation, but did you include that Test Object when building the image? Maybe try to rebuild the image with your current project, just to test.

You can always check what’s in your container by doing:

docker exec -it {container_name} /bin/sh

which will open a terminal session in your container. From there, you can cd into your Object Repository and check that all your files are there.

1 Like

In our environment, our docker image is loaded by GitLab CI in a dedicated runner and the Katalon source code is checked out in this environment.
It is the same source code than the one loaded and manipulated locally in Katalon Studio.

What I understood with this error was that the test object was null, not because it is not in the page (I posted images saying that the element is in) but because it was not found in the page (by the code).

With Katalon, I don’t know if there is kind of compilation or build artifact to include in run environment ?
I will try to explore the content of the image before running tests as you suggest.

Not sure what you meant by this, but I will just reiterate: The error you are getting is that Katalon could not find that Test Object in your object repository. Nothing to do with the web page whatsoever. It isn’t even getting that far.

If you can pull that image to your local machine, run the container, then run whichever command is used to check out your Katalon project, then you should be able to open a session within the container and check that your object repository contains that Test Object.

1 Like

You can add in your script section, before the katalonc.sh line, some 'debug’commands, e.g.

ls -al /path/to/project/Object\ Repository/blah/blah

(you can use the same environment variables as in the kataonc line to locate the project path)
Could be that you are pulling your code from an outdated branch … no idea.
Just make sure that all your files are in the right place in your project.
From the info you posted I cannot figure out how the $CI_PROJECT_BLAH are set and if are valid, so you can add also some echo $VARIABLE commands (but I suppose are valid since your project is found)

1 Like

Hello @Brandon_Hein, hello @bionel,

Thank you for your interest and your responses.

I tried what you said to give you more elements.
Before my katalon command, I ran some echo and ls -Ral.

These are my parameters used in
katalonc.sh -noSplash -runMode=console -consoleLog -retry=0 -apiKey="$KATALON_API_KEY" -projectPath="$CI_PROJECT_DIR/$KATALON_PROJECT_FILE" -testSuiteCollectionPath="Test Suites/$TEST_SUITE" --config -webui.autoUpdateDrivers=true
Capture d’écran 2022-03-30 à 11.08.25

List of files in current directory ($CI_PROJECT_DIR) is the checkout of git sources :

And the objects we are looking for seems to be here (in green the input found, and in yellow the button that is null)

So, I finally ran a cat command for these two .rs files, and the result confirms what you said @Brandon_Hein :


Thank you very much for your explanations, it’s helpful.
Now, I will try to figure out why this happens, cause the file is in the git repository (with content) and GitLab CI only runs a checkout, it seems to be more a runner environment problem.

OK the reason was finally “easy”. :sweat_smile:

The file must have been renamed from button_OKcodeParrainage to button_okCodeParrainage.
In Katalon Studio this seems to be well interpreted but git doesn’t understand well when it’s a renaming by switching between lowercase and uppercase.

So, the file was known locally as button_okCodeParrainage, and we were looking for this name, but in GitLab the file was always known as button_OKcodeParrainage.
Finally, I removed button_OKcodeParrainage from repository and recreated it with the good name button_okCodeParrainage and it is now working well.

Thank you very much for your help.

3 Likes