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 cell in grid

gligogligo Members
edited November -1 in Sahi - Open Source
Hello,
I have problem with selecting a cell in grid. The cell is div, but I want to select it, based on row and column cells.
xpath is something like that

cell: /html/body/div[3]/div/div/div[2]/div/div[2]/div/div[3]/div[2]/div/div[2]/table/tbody/tr/td/<div class="/xty_flxgridCellMetaValue/" </div>
column: /html/body/div[3]/div/div/div[2]/div/div[2]/div/div[3]/div/div/div/table/thead/tr/td/div/<span> Test Product </span>
row: /html/body/div[3]/div/div/div[2]/div/div[2]/div/div[2]/div[2]/div/div[2]/table/tbody/tr/td[2]/<div>Name</div>

Is such a thing possible?

Comments

  • narayannarayan Administrators
    Try

    _cell(0, _near(_div("Name"), _under(_span("Test Product"))))

    or


    _cell(0, _near(_div("Name"), _under(_div("Test Product"))))
  • No, it does not work... :(
    [Exception] TypeError: obj is undefined
  • narayannarayan Administrators
    Could you please paste the HTML code here, or email a snapshot to support@sahi.co.in? We will be able to help you better then. I don't speak much XPath. Sorry!
  • <div id="ext-gen58" class="x-grid3-header">
    <div id="ext-gen71" class="x-grid3-header-inner">...</div>
    <div id="ext-gen59" class="x-grid3-scroller">
    <div id="ext-gen60" class="x-grid3-body" >
    <div id="ext-gen203" class="x-grid3-row xty_flxgridBorderTRL xty_flexgrid-rowNumberer x-grid3-row-first " ....</div>
    <div id="ext-gen205" class="x-grid3-row xty_flxgridBorderTRL xty_flexgrid-rowNumberer " ><table class="x-grid3-row-table">
    <tbody>
    <tr>
    <td ....>
    <div ....> </div></td>
    (as row) <td class="x-grid3-col x-grid3-cell x-grid3-td-1 xty_flxgridBorderL x-grid3-cell-selected" tabindex="0"><div id="ext-gen230" class="x-grid3-cell-inner x-grid3-col-1 xty_flxgridCellMetaName" unselectable="on">Name<spam class="requiredfield"></spam></div></td></tr></tbody></table></div>




    <div id="ext-gen61" class= "x-grid3-viewport x-grid3-unlocked">
    <div id="ext-gen62" class ="x-grid3-header" >
    <div class="x-grid3-header-offset" >
    <table style="width: 275px; height: auto;" border="0" cellpadding="0" cellspacing="0"><thead><tr class="x-grid3-hd-row">
    <td class="x-grid3-hd x-grid3-cell x-grid3-td-14354 " >
    <div class="x-grid3-hd-inner x-grid3-hd-14354" unselectable="on" >
    (as column) <span style="text-align: center;">B<br>temp1</span><img class="x-grid3-sort-icon"></div></td>

    <div class="x-grid3-row xty_flxgridBorderTRL x-grid3-row-first ">
    <div class="x-grid3-row-table" >
    <table id="ext-gen303" class="x-grid3-row-table" style="height: 100%; width: 275px;" border="0" cellpadding="0" cellspacing="0">
    <tbody>
    <tr>
    <td class="x-grid3-col x-grid3-cell x-grid3-td-14354 xty_flxgridBorderL " style="width: 173px;" tabindex="0">
    (searched cell) <div class="x-grid3-cell-inner x-grid3-col-14354 xty_flxgridCellMetaValue" unselectable="on"><spam class="requiredfield"></spam></div></td></tr></tbody></table>


    I want to find (cell), based on (row) and (column)
  • Anything?
  • narayannarayan Administrators
    Hi Gligo,

    When copied into an HTML page, this code snippet is not rendered correctly. Could you please send a screenshot to support@sahi.co.in?

    Thanks,
    Narayan
  • gligogligo Members
    Hi Narayan,
    I have sent to the email a screenshot, html...is that enough?
  • gligogligo Members
    I finally found a way to click on a cell in my case. It looks sth like this:
    $row = _getCellText(_div("/x-grid3-col-row-number-id/",_near(_div("/" + $attribut + "/"))));
    $nrow = parseInt($row);
    $nrow = $nrow -1;
    _click(_div("/xty_flxgrid/[" + $nrow + "]",_under(_div("/" + $column + "/"))));

    Stupid or not, it works for now :)
    So, the topic can be closed
  • narayannarayan Administrators
    Glad you found a solution.

    Does this not work?

    _click(_div("/xty_flxgrid/", _near(_div("/" + $attribut + "/")), _under(_div("/" + $column + "/"))));

    Regards,
    Narayan
  • gligogligo Members
    No Narayan, this not works..i tried so many times, but the problem was that the tables are 2 different, instead of 1, so the first 2 columns (where the rows are written) are 1 table, the other columns are second table.
    They appears all together and seams as 1, but they are not and maybe thats why this with the row does not work
Sign In or Register to comment.