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.

Multiple selection

sumansuman Members
edited November -1 in Sahi - Open Source
Hi,
I am new to sahi tool, First of all I congratulate for providing such a great tool.

Here I am facing following problem.
I have main div inside I have multiple sub div tags each of wich is distinguish by rowindex attribute with a value 0,1,2,3 etc.
inside each sub div I have a table and which contain cell 0,0 a check box.

Problem: when I am trying to select each check box in multiple sub div's it is selecting the last one.
for example if I want to select sub divs 0,2,3 tables check box it is selecting only the last div i.e 3 is selecting

Code:
_click(_cell(_table(0, _in(_byClassName("x-grid3-scroller", "div"))), 0, 0))
_click(_cell(_table(2, _in(_byClassName("x-grid3-scroller", "div"))), 0, 0))
_click(_cell(_table(3, _in(_byClassName("x-grid3-scroller", "div"))), 0, 0))


Please correct me, if I am doing anything wrong.

Comments

  • narayannarayan Administrators
    Hi Suman,

    Looks like this issue is similar to http://sahi.co.in/forums/viewtopic.php?pid=5827
    Could you please give an example site where we can reproduce this issue and suggest a solution.

    Regards,
    Narayan
  • sumansuman Members
    yes narayan, I am also looking for the same solution.

    you can test this in the following url

    coz of I am not active member I could not able to post the url please replace - with /
    -java2s (prefix with www, suffix with com)
    -Code
    -JavaScriptDemo
    -GridPanelFramedwithCheckboxSelectionandHorizontalScrolling.htm


    I opened the sahi controll on this page I try to select 1, 3 row using following script, but it is selecting 3rd one.

    _click(_cell(_table(0, _in(_byClassName("x-grid3-scroller", "div"))), 0, 0))

    _click(_cell(_table(2, _in(_byClassName("x-grid3-scroller", "div"))), 0, 0))

    Thanks for prompt response and support.
  • narayannarayan Administrators
    Hi Suman,

    Your expression returns a cell which is actually outside the div that acts as the checkbox. The behaviour is consistent with what you get when you click anywhere on that row other than the checkbox.

    In the sample page you mention, to identify the checkbox, use this example script:
    _navigateTo("http://www.java2s.com/Code/JavaScriptDemo/GridPanelFramedwithCheckboxSelectionandHorizontalScrolling.htm");
    _click(_div("x-grid3-row-checker", _near(_div("Alcoa Inc"))));
    _click(_div("x-grid3-row-checker", _near(_div("Altria Group Inc"))));
    _click(_div("x-grid3-row-checker", _near(_div("American Express Company"))));
    

    If you want it by index, use
    _navigateTo("http://www.java2s.com/Code/JavaScriptDemo/GridPanelFramedwithCheckboxSelectionandHorizontalScrolling.htm");
    _click(_div("x-grid3-row-checker[0]"));
    _click(_div("x-grid3-row-checker[1]"));
    _click(_div("x-grid3-row-checker[2]"));
    

    The expression you have used to identify the element looks a bit complicated. Are you trying to port some existing scripts from XPath?

    Regards,
    Narayan
  • sumansuman Members
    Hi Narayan,
    I tried both ways as you suggested, but it is not working from sahi controller, I am using old sahi
    which is Build: 2009-10-23.
    could you please suggest me how to work on this version.
  • narayannarayan Administrators
    Hi Suman,

    I would recommend you to upgrade to the latest version.

    Regards,
    Narayan
  • sumansuman Members
    Hi Narayan,

    it is working if I change the code as below.

    _click(_byClassName("x-grid3-row-checker[0]","div")

    Thanks a lot for the support.
This discussion has been closed.