Cant find element running on jenkins

Everything is OK when running on local, but can’t find element when running on jenkins.

Does your test code wait for the element to be loaded completely before your code clicking the element? for example use WebUI.verifyElementPresent(TestObject, Integer)

Everything is OK when running on local, but can’t find element when running on jenkins.

It tends to happen. Your test code should always make sure that the element has been loaded, become visible and clickable before clicking it.

Otherwise, your script will be dependent on the runtime environment (local PC or on server), therefore fragile.

Still can’t find element. I found that these kind of problem happens when the test object receives parameter, is that the cause? But when running on local it works fine.

I can not see your code. Therefore I don’t see what you mean.

When test object receives parameter and the script is running on jenkins, it can’t find element often

By the way, this problem occurs at the same place everytime when running on jenkins. And I sure it’s stable on local and they run the same script.

Your script has 3 lines that uses the same Test Object.


And you wrote you can not find element.

On which statement (1st, 2nd, 3rd) error occurs?
What is the error message?

WebUI.verifyElementPresent(TestObject, int timeout) requires 2nd argument as “timeout” in second.

Your screeenshot does not show how you set it.

How long you set for the timeout?

I have a doubt how the variable row is set. I guess, row is null. Could you check if the row is set with appropriate value?

ShortWaitTime = 5, WaitTime = 60

variable row is set 0 when init.

I guess the parameter was not passed into the test object when running on jenkins?

Please show us the HTML source of the element that the locator points to.

I would suggest you to do step-wise debug for the locator.

You have this locator at the moment, which fails

//td[contains(@id, 'idEditTransitionsTable-rows-row${index}-col1')]//span[contains(@id, 'label') and contains(@class, 'sapMSltLabel')]

Then, how about this?

//td[contains(@id, 'idEditTransitionsTable-rows-row${index}-col1')]//span[contains(@id, 'label')]

Then, how about this?

//td[contains(@id, 'idEditTransitionsTable-rows-row${index}-col1')]//span

Then, how about this?

//td[contains(@id, 'idEditTransitionsTable-rows-row${index}-col1')]

Then, how about this?

//td[contains(@id, 'idEditTransitionsTable-rows-row')]

Then, how about this?

//td[contains(@id, 'id')]

At some stage, you test will turn from failing to passing. Then you would find the real factor which causes the locator failing.

I tried to locate it without passing parameter and it worked, so that means the problem is the parameter can’t be passed into the test object when running on jenkins.

But the target object was rendered when data load, that means target object does not have unique id. So it will need too much code if we don’t use the parameter.

In order to understand your problem we need to reproduce your problem in a browser on our local PC.

Is the URL of your Application-Under-Test a public one on the Internet? If it is, please share it.

Otherwise, please save the page as a MIME HTML file and share the saved file here.

How to save the page as a MHTML file ?

  1. start Chrome browser manually
  2. navigate to the URL of your target web page
  3. do Right click somewhere on the page, you will see a drop down menu where you can choose “Save as”
  4. “Save as” calls up a dialog where you can select a menu “save as, Webpage, Single file” .
  5. select the menu,
  6. choose “.mht” as the filename extension, and do save it.
  7. you will get a file saved.

That’s a MHTML file.

If you could share the MHTML file, we will be able to reproduce your target HTML live on our PC without immediate internet connection to its URL. We will be able to hack for more research.

How you initialize the row? Please show the code to us.


My workmate told me to try some other jenkins environment settings first.
Anyway thanks for you help :smiley:.

I believe that in the older version of Katalon Studio, ${index} in a locator was NOT interpolated when the Test Objext has Selection Method: XPath. It only worked for Selection Method: Attributes.

I am not sure in which version of KS the interpolation “${index} → 0” was enabled for Selection Method: XPath as well. In fact, I found it works in the recent version just now and got a bit of surprise.

Which version of Katalon Studio do you use on your hands-on PC and on the server where Jenkins runs? You have older version on the server, don’t you?

Why not you change the Test Obect to have Selection Method: XPathAttributes?

Yes! That where the problem is. Thank you!