Tests run from the console (KRE) do not find items after inserting the information bar at the bottom of the page


#1

We have inserted a bar with displayed information in our application (it has not changed references to test objects), and therefore I have a problem. Tests run automatically from the console do not find many items even though they are physically in place and thus do not pass the tests. Such a test launched in Katlon Studio passes. After disabling this information bar, the problem disappears. It appears again after switching on. I am asking for information about the reason, because I thought it was a bug in the Katalon Runtime Engine.


#2

let me guess again. command line == headles mode?
you know, without proper info about the issue we can only guess. so you can wait for a century until you get a propper solution.

some details about the execution environment may help too …


#3

I apologize for not expressing myself precisely. No, I do not run tests in headless mode. I run tests normally in chrome using a .bat file, in this file I have a command from Katalon running the test collection. The strip does not cover any elements, does not change the paths to test objects. And Katalon returns Unable click on object: object not found. Do you need anything more specific?


#4

Karol

What you need to do is both tedious and pretty simple:

In your case, I’d want to see a line or two of test code that fails, along with the failure/error report it produces. I’d also like to the the HTML of the element that fails. If you can also add the HTML of the new element which you think causes the issue, that would be good too.

Like I aid, tedious. But not exactly difficult. Do that and we’ll be able to help (or ask more focused questions).

Grabbing screenshots of active HTML is best achieved using the DevTools.


#5

Thanks for sending the link, it explained a lot.
In the attachment I send the files: Code.txt (contains the code that causes the problem), ErrorFromConsole.txt (contains an error from the console), PageScreen.png (screen of the page with the element with the problem highlighted, and the information bar at the bottom of the page), ScreenHTMLPageWithProblematicsAndNewElement .png (screen html of the page with the problematic element selected and the new element - information bar).Code.txt (169 Bytes)
ErrorFromConsole.txt (3.2 KB)


#6

Caused by: com.kms.katalon.core.webui.exception.WebElementNotFoundException:
Web element with id: ‘Object Repository/xSale/DodajKontrahentaPage/DodajKontakt_btn
located by ‘By.xpath: /html/body/div[2]/div/div[3]/div[4]/div/div/div[2]/a/button’ not found

I think I see why Ibus jumped at “headless” - I didn’t expect that error from this.

I’m now very interested in the CSS associated with the service-bar-fixed-wrapper:

Using DevTools, highlight that div-element and take another capture - make sure you capture the panels to the right which should show the CSS.


#7

I send a screen of what you asked for


#8

So, from the info you have provided, you don’t have a problem with click, you have a problem with scrolling.

Right now, I suspect that the fixed-position div (service-bar-fixed-wrapper) might be somehow interfering with the behavior of scrollToElment(). I would prefer the element had a max-height in its CSS, something like 32px (or whatever measurement system you happen to be using to provide such a limited height). Note: I can’t be sure that is the problem, but I do suspect it is.

To try to move this forward, I’d like to try something. But I want you to realize, I’m not suggesting this as a solution - not yet anyway.

Instead of this:

WebUI.scrollToElement(findTestObject('xSale/DodajKontrahentaPage/DodajKontakt_btn'), 5, FailureHandling.STOP_ON_FAILURE)

Try this in its place:

String js = '''
  var selector = "a[href='/Contact/Add?customerId=158']";
  var aTag =  document.querySelector(selector);
  aTag.scrollIntoView();
  aTag.click();
  '''
  WebUI.executeJavaScript(js, null)

aTag.click() is optional but I figured that’s where you’re heading so I put it in.
Note the red stuff is surrounded by TRIPLE single quotes <- that’s not a typo!

Let me know.


#9

you can try also to maximize the browser window (via the testcase code, ofcourse) before to attempt to locate the elements.
not sure if it will help (and definetly is not a final solution) but it can help to locate from where the issue occur ( at this moment my bets are on the browser window size, which may be different when executing from the script vs executed straight from katalon gui)


#10

Yep. And why you jumped on headless. Let’s see if that js moves us forward - it won’t fail if the element is accessible. Rather than investigate what WebUI is doing, I took the pragmatic approach.

We’ll see soon enough.


#11

that’s why two or more minds are better than one :slight_smile:


#12

I have ruled out a problem with the browser window size. On the server, tests are done in 1024x768 resolution, but I run them manually on the server in 1920x1080 resolution and the problem was the same, so I excluded this option. I will check if using js helps.


#13

I put your js in my test but it returned an error. In the Code2.txt file I put the test code, and ErrorFromConsole2.txt the content of the error. In addition, if you want you can look at the application demo. Problem link: https://demo.xsale.ai/Customer/Edit/7Code2.txt (1.2 KB)
ErrorFromConsole2.txt (4.4 KB)


#14

I replaced the selector in your code with the correct one and this code worked. however, after running with KRE on the server of this test I have an error similar to that from before inserting the correct selectorErrorr.txt (4.6 KB)


#15

That error is saying the selector doesn’t resolve to an element on the page.

If you changed the selector, I need to see it.

In addition, the selector I gave you will only work when the customerId is 158. If that value is changed per page load, you should let me know.


#16

I visited the site via the link you posted and checked the page against your screenshot. I then updated the code and tested it.

String js = ''' 
var selector = "a[href='/Contact/Add?customerId=7']"; 
var aTag = document.querySelector(selector); 
aTag.scrollIntoView(); 
aTag.click(); 
''' 
WebUI.executeJavaScript(js, null)

This works.