18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
Deleting Action through Image
I have a page which has listing as the following:
delImg First Name
delImg Second Name
delImg Third Name
delImg Fourth Name
When I record an action for it by clicking on delImg for 4th item (which is an image), it records the following into scripting:
_click(_image(42));
When I play this it successfully deletes it. But if I run the same script again it will not find that 4th Item and because it looks for this delImg on exact that location as recorded.
Can anyone suggest any work around for such scenario where it could explicit look for the name 'Fourth Name' and if that exists only then it try to delete it using the image?
delImg First Name
delImg Second Name
delImg Third Name
delImg Fourth Name
When I record an action for it by clicking on delImg for 4th item (which is an image), it records the following into scripting:
_click(_image(42));
When I play this it successfully deletes it. But if I run the same script again it will not find that 4th Item and because it looks for this delImg on exact that location as recorded.
Can anyone suggest any work around for such scenario where it could explicit look for the name 'Fourth Name' and if that exists only then it try to delete it using the image?
Comments
_image(0, _near(_div("Fourth Name")));
or
_image(0, _in(_div("Fourth Name")));
If you could post the HTML for this section it would be easier to help.
This is the actual html:
Here when playing this script it is possible that the system on which I am running this script as part of my regression test might not have the edit / delete image at this specific location.
How could I post an image here so that I could show you the actual portion which is having this issue?
I also don't see the link for Sahi API documentation is not working. Can you please also fix that?
Is this link not working for you: http://sahi.co.in/w/sahi-apis ? There have been some problems with the hosting recently. Could you please recheck?
Regards,
Narayan
Yes. The API link seems to be working fine for me now. Thanks for checking it too.
-Meraj
_image("BT_delete_B.png", _near(_cell("Fourth Name")));
is what you need.
(I did not see where the name was in the html you sent. Assuming that MRK1:myContent:MRKNew is the name.)
Btw, try simplifying the identifiers for you textbox and selectbox, by using some other alternate identifier; they seem to be quite complex.
Regards,
Narayan
Sahi is handling this very nicely, I was only having this issue where I wanted to edit / delete something from the list specifically. I will try as you mentioned and update here.
Best regards,
- Meraj
For the above I am getting this error 'Reference Error: _near is not defined'.
For this one I am getting this error 'JSERROR TypeError: Cannot find function _image.'
Probably I am using an old Sahi version (Build: 2009-01-21)?
Btw, scripts have moved into userdata directory, so you may want to copy your existing scripts folder into userdata.
-Narayan
My problem has also been solved after using _near method as you mentioned:
I hope it works fine with multiple rows when run in actual regression test and only click edit button on the row where it has this 'NCMS:MyContent:MRKNew2' text.
Thanks for all your help.
regards,
-Meraj