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.

Issue of DOM relations use

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

I am testing adempiere via sahi.write scripts as follow and ues DOM relations.

part of login scripts:
_setValue(_textbox(0), "SuperUser");
_assertEqual("SuperUser",_getText(_textbox(0)));
_setValue(_password(0), "System");
_assertEqual("System",_getText(_password(0)));
if(_condition(_exists(_image("spacer.gif",_near(_span("Language"))))))
{
 _log("success");
}else{
 _log("error");
}

the lastest step for confirm if image "spacer.gif" exists or not.

my reslult is "error".so problem happened because of wrong script "_image("spacer.gif",_near(_span("Language")))"

html codes:
<tr id="rowLanguage">
  <td id="z_cc_k" class="login-label">
  <span id="z_cc_l" class="z-label" z.zcls="z-label" class="z-label">Language</span>
  </td>
  <td id="z_cc_m" class="login-field">
    <span id="z_cc_n" class="z-combobox" style="width:220px;" z.zcls="z-combobox" z.onSelect="true" z.aco="true" z.adr="true"    z.type="zul.cb.Cmbox" z.combo="true">
      <table border='0' cellspacing='0' cellpadding='0' width='220px' style='display:inline-block'>
         <tr style='white-space:nowrap; border:none220px'>
            <td style='width: 100%; border:none'>
               <input id="z_cc_n!real" autocomplete="off" class="z-combobox-inp" value="English" type="text" style='width: 100%'/>
            </td>
           <td style='width: 17px'>
               <span id="z_cc_n!btn" class="z-combobox-btn" style="margin-left:2px">
                   <img class="z-combobox-img" onmousedown="return false;" src="/webui/zkau/web/8914214/img/spacer.gif""/>
               </span>
          </td>
       </tr>
</table>...

I don't know how to ues DOM relations accurately.Please help me.

Addition: adempiere base on ZK,the element's id is dynamic.so can't use id as Identifier .

Regards,
sunny

Comments

  • My purpose is to confirm if the elments exists or not.

    my old script
    _assertExists(_image(1));
    
    image(1) is the same as "spacer.gif",but i don't want to use scripts like "_image(1)", "_cell("Standard[5]")"...

    tested with
    _assertExists(_image("spacer.gif"));
    
    Assertion Failed.

    ADempiere Online Demonstration:http://www.testadempiere.com/webui/
  • I modifed my scripts:
    if(_condition(_image("spacer.gif",_near(_span("Language"))))!= null)
    {
     _log("success");
    }else{
     _log("error");
    }  //refer to:http://sahi.co.in/forums/viewtopic.php?id=1123
    _click(_image("spacer.gif",_near(_span("Language"))));
    

    Result:
    _sahi.saveCondition("__lastConditionValue__0", _image("spacer.gif",_near(_span("Language"))))  at 2010-4-14 17:48:23
    success  at 2010-4-14 17:48:23
    _log("success");  at 2010-4-14 17:48:23
    _click(_image("spacer.gif",_near(_span("Language"))));
    Error: The parameter passed to _click was not found on the browser
    Error("The parameter passed to _click was not found on the browser")@:0
    ((void 0),"_click")@http://adserver/_s_/spr/concat.js:374
    ((void 0))@http://adserver/_s_/spr/concat.js:425
    ()@http://adserver/_s_/spr/concat.js:2589
    ()@http://adserver/_s_/spr/concat.js:2589
    @http://adserver/_s_/spr/concat.js:2414
    
    Click for browser script  at 2010-4-14 17:48:34
    

    Now the assertion gets "success"
    but why the test of next step is failed?
  • narayannarayan Administrators
    I will need to look at the application for your initial problem.

    But I can explain the last error.
    _condition returns true or false.
    so _condition() != null will always be true. That is why you got success.
  • Hi narayan,

    Thank you!

    you can test Adempiere by:ADempiere Online Demonstration:http://www.testadempiere.com/webui/

    Regards,
    sunny
Sign In or Register to comment.