Please note that Sahi's development and support teams do not actively monitor this. This is more a community forum. If you are a Sahi Pro user looking for commercial support, please email support @ sahipro.com with your query.

How to record randomly generated ids using Sahi Script

Divya_S12Divya_S12 Members
edited December 2013 in Sahi - Open Source
Hi all,

I want to click on a div element having a description and randomly generated ID. Recorded script works on playback , however on a different project it fails since the ID generated is random.

Could you please assist ?

Best Answer

Answers

  • Hi Divya,
    Does the div element have any attribute that is consistent over different projects and isn't a randomly generated value?

    Regards,
    Pratyush
  • Hi Pratyush,
    Below is the div element code. As you can see below , the NCO - ### gets changed for different projects and also the values for the characteristics IP Variant , Port Speed , NTU Mode etc)

    _click(_div("Ethernet Lite Port | NCO-02271283IP Variant: IPv4 Port Speed: 32K NTU Mode: EFM Order Type: New Customer Required Date: 04/02/2014"));

    Is there any way to click on this div element by identifying just with the description value Ethernet Lite Port as other values seem to differ with the projects.
  • Hi Bhavitha,

    Still I am facing the same issue. Could you please assist ?
  • Hi Divya,
    As Pratyush mentioned, there must be some element which does not change,

    Go to Developer tools on your browser, and identify the above element using inspect button and check out the styles/properties of this "div" element and u might find some attributes to identify it.
    (Also you can try with something like this according to DOM structure of you application- _click(_div(0,_near("")))

    If not try to refer this element with reference to some other element using _near/_under.
    If still nothing works, you can try using xpath as last option.(sahi has api's, _byXpath()).
  • Thanks Bhavitha.
    I was able to click on the div element using _under api.
Sign In or Register to comment.