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.

Beginner question - How do I retreive an ID to use later in the test?

jhendric1000jhendric1000 Members
edited May 2010 in Sahi - Open Source
Sorry for the beginner question - I'm just learning and I can't figure out how to do this one particular thing. Using a test, I create a new record which, upon clicking [Save] a unique ID is displayed for the record. I need to retain this ID in a variable so that I can query the record later in the test by its ID. This ID will obviously change each time I re-run the test and create a new record.

EDIT: I figured it out!!! I found another example and I was able to infer what I needed to do. Just in case someone else has a similar question, here's how I set a value into a variable based on the div ID:

<browser>
function fetchID(){
var ImpActID = _getText(_byId("FV2026"));
return ImpActID;
}
</browser>

$ImpActID = "";
_set($ImpActID, fetchID());

Comments

  • narayannarayan Administrators
    Hi jhendric1000,

    Your solution is right.
    If you are just getting the id in fetchID(), you could do the same with just
    $ImpActID = "";
    _set($ImpActID, _getText(_byId("FV2026")));
    

    Regards,
    Narayan
  • jhendric1000jhendric1000 Members
    edited May 2010
    Even better. Thank you! I can't tell you how great this tool is!
Sign In or Register to comment.