18 January 2026:


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.

How to find out if a button exitsts or not?

shamsham Members
edited November -1 in Sahi - Open Source
Hi all,

I have a set of pages that "may" have 2 submit buttons , a.k.a, 'Save' , 'Restore Defaults'.
Both these pages contain some textboxes . So i wrote a singe func called 'SetTextboxandRevert()' that stores old values, sets new values and reverts after a check.

But this function now can only handle cases where 'Restore Defaults' button is present. Now there are pages where I have only "Save" buttons. In such a case I'd like to know how to check if I have the 'Restore Defaults' button or only 'Save' button and perform accordingly.

Thanks

Comments

  • Hi Sham,

    Check if this works for you.

    if(_exists(_button("Logout"))){
    do x;
    }
    else{
    do y;
    }

    Regards
    Sumitra
Sign In or Register to comment.