Test run passes without errors but the click action does not appear to work on the object in the UI, and the spy object cant find the object all a sudden when it was working before

Before hitting that Ask the Community button, make sure to:

### Operating System
Windows 10

ISSUE
Test is FAILING - Unable to find element with Xpath and dedicated unique identifier… It was working for days then one day no locator is working. I tried a different browser to see if it was a browser issues, that’s fine!

I tried different locators and nothing!

I restarted Katalon and tried again and nothing.

### Log Folder:

Something I noticed as well
When I capture the object on Object SPY it says unable to find the object but WHY? If its there…
It was all passing before and all a sudden nothing works.

and in Katalon there is no Self healing…
image

INSPECT IMAGE BELOW
image

HTML IMAGE

XPATH IMAGE
image

Info from last Xpath
image

//div[(text() = ’
HMDA Transmittal

Run edit checks to validate that your HMDA data is ready for transmission.
Run edit checks on your HMDA data, and correct data anomalies so your transmittal file complies with CFPB file and edit specifications.

        ' or . = '
          HMDA Transmittal

Run edit checks to validate that your HMDA data is ready for transmission.
Run edit checks on your HMDA data, and correct data anomalies so your transmittal file complies with CFPB file and edit specifications.

        ')]

IF WE select the ATTRIBUTE: using unique DATA tag for this object

GROOVY CODE

\

TODAYS LOG FILE 9 /13/23
IT passes but really failed and didnt click on the element

Expected Behavior
find objects

Actual Behavior
not finding XPATH or dedicated attribute

1 Like

Any test script can not click an element if the element is NOT yet there in the page, OK?

I found that your script is NOT explicitly waiting for the target element to appear in the page before clicking it. Therefore your code is unstable. Your script may accidentally work but is more likely to fail.

You should use WebUI.waitForElementPresent(Testobject, timeout) and other keywords just before you call WebUI.click(TestObject) in order to make sure the target element has been loaded and is really there in the page before you click it.

[WebUI] Wait For Element Visible | Katalon Docs

[WebUI] Wait For Element Clickable | Katalon Docs

[WebUI] Enhanced Click | Katalon Docs

Rule of thumb: You should explicitly wait for the element before clicking it. Always!

The Recorder and Spy tools of Katalon Studio does NOT generate any code to wait for the targeted elements before clicking them. It’s a shame. You should not rely on these tools much. You have to insert the code of WebUI.waitForElementXXXX manually.

Exactly you should try as suggested by @kazurayam

Great now it works but its still not clicking on the element hence the next step is not passing. One of my team mates also having same issue! Object is there buts not clicking on the object. Weird behavior

Possibly the locator expression is wrong: it is not pointing the HTML element you want.

You wrote “Weired behavior” — possibly you used the Record tool of Katalon Studio to generate the Test Object, but you have never checked its validity against the HTML source. The tool is just a tool. The auto-generated Test Objects are just the suggestions for you to get started with; not the definitive solutions. The tools generate fragile codes quite sometimes. Or, the target HTML might have changed after you generated them. So, you need to review and edit the auto-generated codes manually. That’s the mission of IT staff, you know. — Are you disappointed to hear this?

What to do next? — I don’t see, as you haven’t disclosed any detail information. Please provide more information:

  1. HTML source code , while pointing which element is of your interest
  2. Definition of the Test Object, we need to see the locator expression (XPath or CSS Selector)
  3. Test Case script source code, while pointing which statement you have a problem about

Preferabkt you should create a new discussion thread with an appropriate title, so that you can close this thread.

and
[WebUI] Wait For Page Load | Katalon Docs

One of the parameters of the waitForXXX is a “timeOut”. DO NOT PUT the “timeOut” at 0 (zero). Put it at 5 or 10. Give your pages time to form. You may be in a hurry, but your pages will form when they are ready :slight_smile:

enhance click is much fruitful when test run for safari browser.

I am new to this, what do you suggest for the title! Once again thanks for your help! Let me add some more screen shots

check the newly added screen shots for HTML, Groovy code and HTML source code… NEW title is
“test run passes without errors but the click action does not appear to work on the object in the UI”

Hi thanks but I am using windows not apple :slight_smile:
Any other suggestions

I think you’re digging too deep into the HTML. I think you want to click the HTML <a> element.

The code below will click on the HTML <a> element shown in your HTML screenshot.

image

It’s not clear if those are spaces or underscores between the words in the URL.I’m going with spaces:

String js="""document.querySelector("a[href='/hmda transmittals/dataset selection']").click();"""
WebUI.executeJavaScript(js, null)

Replace your WebUI.click() with that code and try it.

1 Like

Please Select Attributes of Selection Methos under Object Repository and also select only text value under object properties.
You can also check whether your object repository value is correct or not by below ways,

  1. copy xpath from your repository
  2. open your page in browser and click right mouse on the object and click inspect
  3. click ctrl +F and type your copied xpath here
  4. See your element is being highlighted or Not.
    If you element is highlighted then your xpath is correct other wise you need to create another xpath.
    FYI @naomy.arnold
1 Like

Please check if page is fully loaded and elements are interact-able!

So I figured out the issue, There was a change to PROD, and with this changed added TWO extra steps. they had no idea it would affect automation. Once I used the web recorder after the change I then noticed there were two extra steps hence why my objects was not clickable because it was NOW on a different page! Thank you all so much for your input! I learned a lot.

2 Likes

Thank you Dinesh I figured out the issue. I appreciate your help.

There was a change to PROD, and with this changed added TWO extra steps. they had no idea it would affect automation. Once I used the web recorder after the change I then noticed there were two extra steps hence why my objects was not clickable because it was NOW on a different page! Thank you all so much for your input! I learned a lot.

1 Like

So I figured out the issue, thank you so much for your help. I posted below with what fixed the issue

2 Likes