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 node id’s of span?

santosh.takekarsantosh.takekar Members
edited November -1 in Sahi - Open Source
Hello team,

I am trying to automate a web application under test. The page layout of application is divided into two parts; on left side, tree view is there and on right side, content view is there.
On clicking items of tree view, details of clicked items are being displayed in content view (i.e. right side of the page).

I have struck with an issue related to “node expansion” on tree view.
The node Id’s of span is changing during run time, because of this recorded sahi scripts fails during execution.

How to find node id’s of span?
The sample code is like this
_click(_span("sahi project"));
_click(_image("reveNode108Toggle"));

The node id =108 changes during run time ("reveNode108Toggle"). how ever, the span text='sahi project" is constant.

Should I use _span(identifier[, domRelation]) API "? I do not know how to use this API.

Kindly guide me.

Comments

  • narayannarayan Administrators
    Yes Santosh,

    _span(identifier[, domRelation]) is what you need.

    In your case, it could be:

    _click(_image(0, _near(_span("sahi project"))));

    or

    _click(_image(/reveNode.*Toggle/, _near(_span("sahi project"))));

    Regards,
    Narayan
  • Hello Narayan,

    I have used this statement and it solved my problem.

    _click(_image(/reveNode.*Toggle/, _near(_span("sahi project"))));


    Thanks and regards,
    Santosh T.
This discussion has been closed.