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.

select by id

JustinWyllieJustinWyllie Members
edited November -1 in Sahi - Open Source
Hi

I would like to select an element, say a div, but in fact any element.

The documentation for _div (I can't post the link as the forum won't let me as a new member!) says that it takes the text content of the div as the identifier. But some posts I've read on the web suggest that you can select by id.

How would I select an element by id?

Thank you

~ JustinWyllie

Comments

  • Hi JustinWylie,

    Accessor APIs in Sahi take an identifier and an optional DOM relation as parameters. In the case of a div element, the identifiers can be index, id or the text in the element.

    So you could use _div("text content") or _div("id assigned")

    Note: If the id is dynamic, I would suggest that you use UI relations to identify elements.
    Please refer this article to understand how Sahi can access elements on the browser.

    Regards,
    dkulkarni
Sign In or Register to comment.