Unable to click on edit link, it says unable to find the element located by xpath


I am Unable to click on edit link, it says unable to find the element located by xpath

katalon recorded xpath, spy recorder x path is not working, so i created customized x path

//tbody/tr[3]/td[18]/a[1] - this xpath worked 2 to 3 times and then it stopped working, so i modified xpath and tried again by using below xpaths but it did not work,


PFA html screenshots, Please let me know how can i proceed
also ,question is why the first xpath worked 2 3 times and then suddenly stopped working?


Can you post your test code?

Error occurs on step 90, but now i deleted a href attribute from object properties and it started working, now it gives error on step 92, saying same thing unable to find the element located by xpath PFA screenshots of object properties of step 90 and 92 and also test code

Please post the error from the Console.

Please post your test code from Script View.

And please read this post it gives examples of the kind of things we like to see:

attaching test code and error screenshot

First, you need to verify that Xpath is working correctly. There are tools in the browser to help you do that but I can’t advise – I never use Xpath. (Shout out @Brandon_Hein, @Marek_Melocik).

Side note: are you waiting until the element is visible? It could be that the test is too fast for the browser.

Hi @Amruta.bagle

Looking at the XPath, I have a very high concern about its correctness. You can verify the correctness of an XPath in Chrome is tool open the inspection tool, navigate to Elements tab, ctrl + F and paste the XPath in. If your target element is highlighted then the problem elsewhere, otherwise you’d need to choose a more robust XPath.

From personal experience though, XPaths with long attribute values are very fragile, so I’d advise choosing a different XPath anyway.

Cheers !

1 Like

@Amruta.bagle You can use Chropath to capture xpath.

Thankyou All for your help!!!

It worked finally by absolute xpath
It accepted the whole x path right from html tag, previously i was giving it from middle starting from td which it was not accepting

xpath that worked is : /html[1]/body[1]/form[1]/section[1]/div[1]/div[1]/table[1]/tbody[1]/tr[1]/td[1]/table[1]/tbody[1]/tr[1]/td[1]/table[1]/tbody[1]/tr[2]/td[1]/div[4]/table[1]/tbody[1]/tr[1]/td[1]/table[1]/tbody[1]/tr[4]/td[2]/div[1]/table[1]/tbody[1]/tr[1]/td[1]/a[1]

It didn’t work with a relative xpath ? Even found with ChroPath ?
Your absolute Xpath is really horrible and will be hard to maintain

1 Like

Relative path did not work
Relative path worked but only for that session as i tried new session it failed
Problem with relative path is all attributes are dynamic even parent sibling, following child all seemed dynamic…there is no any reference point so i used absolute path
chropath suggested this absolute path…the short one which i was trying to use it did not accept

@Amruta.bagle Can you share the relative xpath for this object? There should be a way to use relative xpath using conditions in object selector properties. As said in above post absolute path would not work in the long run and may also break if you try to run your test on a mobile device.

@Manpreet :
Relative xpath for object is:

It contains dynamic guid, can you please help with any option of how to use relative xpath or any
other option but not absolute xpath in this case?

You can try
//input[contains(@id, 'a non-dynamic part')]
Or if you can get the dynamic part, you can create an object on the script

@Amruta.bagle I think

is the non-dynamic part. Can you try @HeleneB suggestion?

@HeleneB, @manpreet.mukkar This xpath worked : //input[contains(@id,‘dxcpDecisionTable_dxtxtTrueRouteTask’)]

Thanks for your help!!