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 get all the elements from a "Div" or "area" ?

AkshadaAkshada Members
edited November -1 in Sahi - Open Source
Hi,

How do i get all the elements in the Div/Area ??
There was an extra textbox appearing, So i want to check if No of textboxes present under the "Div" are 3 and not 4.

How could this be done in JAVA??

Thanks in advance!!
Regards,
Akshada

Comments

  • AkshadaAkshada Members
    fetch(), getText, collectSimilar wont help!!
  • narayannarayan Administrators
    You can do
    int count = browser.textbox("/.*/").in(browser.div("divId")).countSimilar();
    

    Regards,
    Narayan
  • sivasiva Members
    edited August 2011
    Hi Akshada,

    i hope this will help you to get all the elements present under specific area/ div

    _collect("_link", "/./", _in(_div("divID")));

    in this line i have used "_link" to get the link information, in the same way you have to mention the required object instead of link

    ******************************************************************************

    var $all_Links = _collect("_link", "/./", _in(_div("divID")));
    var $each_Link = [];
    for (var $i=0; $i<$all_Links.length; $i++) {
    _set($each_Link[$i], $all_Links[$i].id);
    }
    for (var $i=0; $i<$each_Link.length; $i++) {
    _alert($each_Link[$i]);
    }

    ****************************************************************************
  • Hi Siva,

    Thanks for your reply.
    But i cant collect elements in JAVA. There is just the collectSimilar function which gives me similar elements of that type.

    How do i do this in Java??

    Regards
    Akshada
Sign In or Register to comment.