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.

Dom access API's

tejasbhojaktejasbhojak Members
edited November -1 in Sahi - Open Source
i used this API
_byClassName("className", "div")

this should fetch me all the div's with className in argument
but instead of returning array it returns only one element.

is there any API that returns array of HTMLObjects?

Comments

  • Can we do jQuery type DOM access using sahi?
  • Can some body please reply to my question
    i want to use jQuery inside sahi how do i do that??
  • narayannarayan Administrators
    Hi tejasbhojak,

    If you can give us an example of how you would like to use it, we can show how to do it.

    Regards,
    Narayan
  • SumitraSumitra Members
    Hi tejasbhojak,

    Kindly check these links:

    http://sahi.co.in/forums/viewtopic.php?id=1811

    Let me know if this helps you.

    Regards
    Sumitra
  • on the DOM i have many div's there are certain set of css class common on each div
    while some sets are unique to specific div's
    i want to write a sahi script which allow's me to do a bulk operations on all the div's
    like we do in jQuery
    example
    var allDiv = $("div.commonClass");
    var typeA = allDiv.filter(filterOnSomeCustomLogic());
    var typeB = allDiv.filter(filterOnSomeCustomLogic_B());
    so i need a way to write jquery code in my.sah file
  • I am not sure if automation "Testers" use libraries like jQuery or YUI to traverse DOM.but
    if a developer has to tests its HTML + Javascript component
    then sahi should allow using jquery(or any other library) to create some testing abstractions(Dom validation API's) for their own components.
    Narayan it would be really cool to write complete sahi script in jquery.
  • narayannarayan Administrators
    Hi Tejas,

    You can write your javascript functions around jquery, put it in <browser> tags and call them anywhere using Sahi.

    Eg.
    <browser>
    function checkIfAllAlternateRowsAreRed(){
      // my implementation using jquery
    } 
    </browser>
    
    _call(checkIfAllAlternateRowsAreRed());
    
    or
    
    _assertTrue(checkIfAllAlternateRowsAreRed());
    

    That said, you raised the correct question. Automation testers should NOT use libraries that developers use. Use the above only if you are aware that you are trying to test a JS component. Writing scripts in jquery is actually a bad idea. You will never be able to test if the actual applications behaves correctly, because you may be using the same buggy framework that the developer was using.

    Regards,
    Narayan
Sign In or Register to comment.