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.

Test Adempiere with Sahi

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

I test Adempiere via Sahi,test login and Product Creation.But met a problem.

My test:

The scripts,

adlogin_test.sah
_setValue(_textbox(0), "SuperUser");
_setValue(_password(0), "System");
_click(_image(2),"Ok24.png");
_click(_image("spacer.gif"));
_click(_cell("GardenWorld Admin"));
_click(_image("spacer.gif[1]"));
_click(_image(5),"Ok24.png")

create_product.sah
_click(_span("z-tree-ico z-tree-root-close[7]"));
_click(_span("z-tree-ico z-tree-tee-close[23]"));
_click(_image("mWindow.png[186]"));
_click(_image("New24.png"));
_setValue(_textbox(5), "ProductA");
_click(_image("spacer.gif[3]"));
_setValue(_textbox(6), "create a product");
_click(_image("spacer.gif[6]"));
_click(_cell("Day"));
_click(_checkbox("on[4]"));
_click(_image("Save24.png"));
_click(_link(4));

i put the scripts to my.suite and test.

test them by commandline with command:
sahi # java -cp lib/ant-sahi.jar net.sf.sahi.test.TestRunner /mnt/sda4/Sahi/sahi/userdata/scripts/my.suite "/usr/bin/firefox" adurl /mnt/sda4/Sahi/sahi/default localhost 9999 1 firefox

passed test.Successful!

will load two browser's window.load one window when login,after login, then load a new window to create product.

But if test with Xvfb,has problem as follow:

run:
sahi # java -cp lib/ant-sahi.jar net.sf.sahi.test.TestRunner /mnt/sda4/Sahi/sahi/userdata/scripts/my.suite "/usr/bin/firefox" adurl /mnt/sda4/Sahi/sahi/default localhost 9999 1 firefox "--display=:99 -profile /mnt/sda4/Sahi/sahi/userdata/browser/ff/profiles/sahi1 -no-remote"

problem:
_click(_span("z-tree-ico z-tree-root-close[7]"));
Error: The parameter passed to _click was not found on the browser

Xvfb start by(started before test):
# cd /usr/bin/
bin #Xvfb :99 -auth /etc/X99.hosts -screen 0 800x600x24 &

Can anyone help me on this issue?

Thanks
sunny

Comments

  • The above loaded two windows.now i let it load one,modify script like this:

    create_product.sah,make it include adlogin_test.sah
    _include("adlogin_test.sah");
    _click(_span("z-tree-ico z-tree-root-close[7]"));
    _click(_span("z-tree-ico z-tree-tee-close[23]"));
    _click(_image("mWindow.png[187]"));
    _click(_image("New24.png"));
    _setValue(_textbox(5), "ProductA");
    _click(_image("spacer.gif[3]"));
    _setValue(_textbox(6), "create a product");
    _click(_image("spacer.gif[6]"));
    _click(_cell("Day"));
    _click(_checkbox("on[4]"));
    _click(_image("Save24.png"));
    _click(_link(4));
    _click(_link("Log Out"));
    

    my.suite
    create_product.sah
    

    run the scripts,but also has problem:
    _click(_cell("GardenWorld Admin"));  at 2010-3-29 17:55:02
    _click(_image("spacer.gif[1]")); at 2010-3-29 17:55:03
    _click(_image(5),"Ok24.png"); at 2010-3-29 17:55:04
    JSERROR
    Step >_sahi._click(_sahi._span("z-tree-ico z-tree-root-close[7]"));< did not complete in 130 seconds. at 2010-3-29 17:57:16
    

    I think no problem with my scripts,because sometimes they can passed test,

    can pass test if run them by separated.

    and if i reload the window manually after login,they can passed test
    _click(_image("spacer.gif[1]"));  at 2010-3-29 18:36:52
    _click(_image(5),"Ok24.png"); at 2010-3-29 18:36:53
    undefined: zkCmsp is not defined (adurl/webui/zkau/web/8914214/js/zk/zk.js.dsp:10)
    No trace available
    Click for browser script at 2010-3-29 18:37:31
    _click(_span("z-tree-ico z-tree-root-close[7]")); at 2010-3-29 18:37:32
    _click(_span("z-tree-ico z-tree-tee-close[23]")); at 2010-3-29 18:37:33
    _click(_image("mWindow.png[187]")); at 2010-3-29 18:37:36
    _click(_image("New24.png")); at 2010-3-29 18:37:47
    _setValue(_textbox(5), "ProductA"); at 2010-3-29 18:38:13
    _click(_image("spacer.gif[3]")); at 2010-3-29 18:38:15
    _setValue(_textbox(6), "create a product"); at 2010-3-29 18:38:18
    _click(_image("spacer.gif[6]")); at 2010-3-29 18:38:19
    _click(_cell("Each")); at 2010-3-29 18:38:22
    _click(_checkbox("on[4]")); at 2010-3-29 18:38:23
    _click(_image("Save24.png")); at 2010-3-29 18:38:26
    _click(_link(4)); at 2010-3-29 18:38:28
    _click(_link("Log Out")); at 2010-3-29 18:38:34
    

    so i add script after login scripts.
    _navigateTo("adurl"," true");
    

    but also can't pass test.

    The above tests tested by Sahi Controller.

    info:

    Sahi
    Version : V3
    Build : 2010-03-21
    Check for updates

    Browser
    UserAgent : Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.6) Gecko/2009030911 Gentoo Firefox/3.0.6
    Name : Mozilla Firefox
    Version : 5.0 (X11; en-US)
    Native XmlHTTPRequest : true
    Is Java enabled : true
    Is cookie enabled : true

    Operating System
    Name : Linux
    Version : 2.6.27-gentoo-r8
    Architecture : i386
    Is process list available : true

    Java
    Java Installed Directory : /opt/sun-jdk-1.6.0.11/jre
    JRE Version : 1.6.0_11
    Is keytool available : true

    Can anyone help me?
  • narayannarayan Administrators
    Hi sunny,

    We will investigate this and get back to you.

    Regards,
    Narayan
  • narayannarayan Administrators
    Hi Sunny,

    Instead of using profile sahi1, you should be using sahi$threadNo.
    (Sahi will replace $threadNo with 0,1,2 etc. to use separate profiles.)

    sahi # java -cp lib/ant-sahi.jar net.sf.sahi.test.TestRunner /mnt/sda4/Sahi/sahi/userdata/scripts/my.suite "/usr/bin/firefox" adurl /mnt/sda4/Sahi/sahi/default localhost 9999 1 firefox "--display=:99 -profile /mnt/sda4/Sahi/sahi/userdata/browser/ff/profiles/sahi$threadNo -no-remote"
    

    I am still checking the refresh related issue.

    Regards,
    Narayan
  • narayannarayan Administrators
    Hi sunny,

    Your problem with Sahi hanging is that Sahi is waiting for one particular AJAX request to finish, while that request is actually a comet request (which will never finish).

    I have added a condition to check for "comet" in XHR request URLs and not wait on them.

    Open sahi/htdocs/spr/concat.js and search for
        XMLHttpRequest.prototype.open = function(method, url, async, username, password){
            url = ""+url;
            var opened = this.openOld(method, url, async, username, password);
            if (url.indexOf("/_s_/") == -1){
                    //_sahi.d("xhr url="+url);
                    try{
                            var xs = _sahi.topSahi().XHRs;
                            xs[xs.length] = this;
                    }catch(e){
                        _sahi._debug("concat.js: Diff domain: Could not add XHR to list for automatic monitoring "+e);
                    }
                    this.setRequestHeader("sahi-isxhr", "true");
            }
            return opened;
        }
    

    and replace it with:
        XMLHttpRequest.prototype.open = function(method, url, async, username, password){
            url = ""+url;
            var opened = this.openOld(method, url, async, username, password);
            if (url.indexOf("/_s_/") == -1){
                    try{
                        if (url.indexOf("comet") == -1){
                            var xs = _sahi.topSahi().XHRs;
                            xs[xs.length] = this;
                        }
                    }catch(e){
                        _sahi._debug("concat.js: Diff domain: Could not add XHR to list for automatic monitoring "+e);
                    }
                    this.setRequestHeader("sahi-isxhr", "true");
            }
            return opened;
        }
    


    We will add this to the coming build.

    Regards,
    Narayan
  • Hi Narayan,

    Thanks :)

    Regards,
    sunny
  • narayannarayan Administrators
    Hi sunny,

    Could you confirm that it worked for you?

    Regards,
    Narayan
  • Hi Narayan,

    No. I will try your solution tomorrow!

    Regards,
    sunny
  • narayannarayan Administrators
    Sure :)
  • Hi narayan,

    I try your solution that modifed sahi/htdocs/spr/concat.js,it worked now by Sahi Controller.

    but if i test by coomandline:
    sahi # java -cp lib/ant-sahi.jar net.sf.sahi.test.TestRunner /mnt/sda4/Sahi/sahi0321/sahi/userdata/scripts/my.suite "/usr/bin/firefox" adurl /mnt/sda4/Sahi/sahi/default localhost 9999 1 firefox "--display=:99 -profile /mnt/sda4/Sahi/sahi0321/sahi/userdata/browser/ff/profiles/sahi$threadNo -no-remote"
    

    has problem:
    Test  Total Steps  Failures  Errors  Success Rate
      create_product.sah  1  0  1  0%
    
      Starting script
    JSERROR
    Script did not start within 310 seconds.  at 2010-4-2 15:33:24
    

    and using profile sahi1
    sahi # java -cp lib/ant-sahi.jar net.sf.sahi.test.TestRunner /mnt/sda4/Sahi/sahi0321/sahi/userdata/scripts/my.suite "/usr/bin/firefox" adurl /mnt/sda4/Sahi/sahi/default localhost 9999 1 firefox "--display=:99 -profile /mnt/sda4/Sahi/sahi0321/sahi/userdata/browser/ff/profiles/sahi$threadNo -no-remote"
    

    works ok.

    Thanks!

    Regards,
    sunny
  • narayannarayan Administrators
    Hi Sunny,

    Forgot that you are on linux.

    Please use sahi\$threadNo instead of sahi$threadNo

    Regards,
    Narayan
  • Hi narayan,

    Tested,works ok!

    Thank you very much!

    Regards,
    sunny
This discussion has been closed.