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.

Can we find element type by using element id?

nagarnagar Members
edited November -1 in Sahi - Open Source
Hi All,

My requirement may be unrealistic or illogical, but I need to find element type by using it's identifier.

Suppose, there is an element identified by Sahi controller: _textbox("username")

Now, I don't want to use this element identified by controller. I just want to pass the identifier as "username" into script and want to find the element type of id: "username", i.e. "textbox".

Is this possible?

If yes then please provide the solution.


regards,
nagar

Comments

  • Hi nagar,

    I'm not sure if i have understand correctly what you need, but here is my solution:
    _set($emailId, _textbox("").id);
    //_set($emailId, _textbox("", _in(_div("form"))).id); //it'll better if DOM relation is specified
    _highlight(_textbox($emailId));
    
  • narayannarayan Administrators
    If it is the id of a form element, you can do

    var $type = null;
    _set($type, document.getElementById("id").type);

    _alert($type); // alerts "text"
Sign In or Register to comment.