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.
Unable to find global identifier for div elements.
Hi All,
In my application, I have multiple tabs in multiple modules. These modules (not tabs) are identified as _div("mymenu_menu0_0_x") by Sahi controller. So it's easy to click on all modules one by one OR by providing their text names.
Now, the tabs within these modules are not identified in similar way by Sahi controller. Sahi identifies those tabs, by their class names tailing by a dynamic index no. So I can not write a global code for all tabs.
For Example, in a module, say "Configuration (_div("mymenu_menu0_0_1")), there are multiple tabs which are identified by controller as:
Tab name - "Notification" is identified as _div("tablavel2_menu_middel[114]")
"Messages" - _div("tablavel2_menu_middel[115]")
"Web Proxy" - _div("tablavel2_menu_middel[116]") and so...
Here the index no. at first tab is dynamic, so I can not judge other tabs by incrementing one for each.
For these Tabs, if I write a code line as:
_getText(_div("mymenu_menu0_0_1_3")), then it shows the name properly as, "Web Proxy" but _click(_div("mymenu_menu0_0_1_3")) does not click on Web Proxy tab. There I must write as:
_click(_div("tablavel2_menu_middel[116]")).
HTML snippet for tab "Web Proxy" is:
<div id="mymenu_menu0_0_1_3" class="tablavel2_menu" index="3">
<div class="tablavel2_menu_left"></div>
<div class="tablavel2_menu_middel">Web Proxy</div>
<div class="tablavel2_menu_right"></div>
</div>
Kindly help in resolving this issue.
In my application, I have multiple tabs in multiple modules. These modules (not tabs) are identified as _div("mymenu_menu0_0_x") by Sahi controller. So it's easy to click on all modules one by one OR by providing their text names.
Now, the tabs within these modules are not identified in similar way by Sahi controller. Sahi identifies those tabs, by their class names tailing by a dynamic index no. So I can not write a global code for all tabs.
For Example, in a module, say "Configuration (_div("mymenu_menu0_0_1")), there are multiple tabs which are identified by controller as:
Tab name - "Notification" is identified as _div("tablavel2_menu_middel[114]")
"Messages" - _div("tablavel2_menu_middel[115]")
"Web Proxy" - _div("tablavel2_menu_middel[116]") and so...
Here the index no. at first tab is dynamic, so I can not judge other tabs by incrementing one for each.
For these Tabs, if I write a code line as:
_getText(_div("mymenu_menu0_0_1_3")), then it shows the name properly as, "Web Proxy" but _click(_div("mymenu_menu0_0_1_3")) does not click on Web Proxy tab. There I must write as:
_click(_div("tablavel2_menu_middel[116]")).
HTML snippet for tab "Web Proxy" is:
<div id="mymenu_menu0_0_1_3" class="tablavel2_menu" index="3">
<div class="tablavel2_menu_left"></div>
<div class="tablavel2_menu_middel">Web Proxy</div>
<div class="tablavel2_menu_right"></div>
</div>
Kindly help in resolving this issue.
This discussion has been closed.
Comments
Try
_click(_xy(_div("mymenu_menu0_0_1_3"), 20, 5))
or
_click(_div("tablavel2_menu_middel", _in(_div("mymenu_menu0_0_1_3"))))
Explanation:
_div("mymenu_menu0_0_1_3") will give you the outer div. You want to click the middle div inside it. Sahi clicks on the top left corner of any element. If you wrap it with _xy(el, x, y), then it will click (x,y) coordinates inside the element. The better way is to use the _in API to get the correct tablavel2_menu_middel.
Regards,
Narayan
Thanks for your response but unfortunately both solutions do not work for me.
Is there any other option to resolve this?
BR,
nagar
Can you set _setStrictVisibilityCheck(true) at the starting of the script and use _setStrictVisibilityCheck(false) at the end of the script , now check what is the "Web proxy" been identified as?
Also, can you try :
_click(_div("Web Proxy",_in(_div("tablavel2_menu_middel[116]")));
Regards
Sumitra
I don't want to use index nos. in the code line so I am not opting for second option, but yes, _setStrictVisibilityCheck() works like charm.
Thanks a lot for the solution.