PMC:QA:Sahi POC Product and BP

From ADempiere
Jump to: navigation, search
This Wiki is read-only for reference purposes to avoid broken links.

Sahi POC Product and BP

You can view the second part(POC) directly.The first part recorded some problems during my test.

Test

test scripts

login 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")

Product creation script

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));

the above script:

1.click "Material Management" which in the menu.

2.click "Material Management Rules"

3.click "Product"(will popup a window-lookup Record:Product)

4.create a new product record by click "new record" button(New24.png)

5.6.7.8.9.10.11,create a new product record.

12.close the product tab.

Problem:

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" 
http://adserver/webui/ /mnt/sda4/Sahi/sahi/default localhost 9999 1 firefox

passed test.

result:

Poc.png

the above test will open two browser's tab,one is login window,one is creating product window after login.

but if test with Xvfb,has problem as follow(the same problem when test by hudson)

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

Poc1.png

solution:

The above loaded two window.we 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:

Poc2.png

i found the same error in sahi forums:http://sahi.co.in/forums/viewtopic.php?id=1231,but have't found the solution.

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

can pass test if run them by separated.

Poc3.png

and if i reload the window after login,they can passed test

Poc4.png

so i add script after login scripts.

_navigateTo("http://adserver/webui/"," true");

_navigateTo(url, forceReload)

Navigates to the given url. If the url is same as what is loaded on the browser, the page will be refreshed only if forceReload is true

but also can't pass test.

The above tests tested by Sahi Controller.

The new problem solution:

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;
    }

More Details please refer to:http://sahi.co.in/forums/viewtopic.php?pid=4646#p4646. Thanks for Narayan's help!

POC

My test environment:

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
  • start hudson and create a new project "Sahi"
  • start Xvfb
# cd /usr/bin/
bin #Xvfb :99 -auth /etc/X99.hosts -screen 0 800x600x24 &

POC for product creation

scripts of product creation

edit sahi scripts for product creation:

_include("adlogin_test.sah");
_navigateTo("http://adserver/webui/"," true");
_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("Each"));
_click(_checkbox("on[4]"));
_click(_image("Save24.png"));
_click(_link(4));
_click(_link("Log Out"));

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");

add sah file(create_product.sah) to suite file(my.suite)

config hudson

Poc5.png

Poc6.png

zkbuild.xml

Example:

<project name="bids" default="runfftests">
	<property environment="env"/>
	<property name="sahi.home" value="${env.SAHI_HOME}" location="/mnt/sda4/Sahi/sahi0321/sahi/" />
	<property name="user.data" value="${env.SAHI_USERDATA_DIR}" location="/mnt/sda4/Sahi/sahi0321/sahi/userdata"  />
	<property name="urlbase" value="http://admpiereservername/webui/" />
	<taskdef name="sahi" classname="net.sf.sahi.ant.RunSahiTask" classpath="${sahi.home}/lib/ant-sahi.jar"/>
	
	<target name="runfftests">
	<antcall target="startsahi"/>
        <sleep seconds="4"/>
		<sahi suite="${user.data}/scripts/my.suite"
		      browser="/usr/bin/firefox"
		      baseurl="${urlbase}"
		      sahihost="localhost"
		      sahiport="9999"
                      failureproperty="sahi.failed"
                      haltonfailure="false"
                      browseroption="--display=:99 -profile ${user.data}/browser/ff/profiles/sahi\$threadNo -no-remote"
                      browserProcessName="firefox"
		      threads="1" >
                    <report type="junit" logdir="/root/.hudson/jobs/Sahi/workspace/logs"/>	
		</sahi>
                <sleep seconds="4"/>
                <antcall target="stopsahi"/>
                <sleep seconds="4"/>
		<antcall target="failsahi"/>		
	</target>
		<target name="failsahi" if="sahi.failed">
		<fail message="Sahi tests failed!"/>
	</target>
		<target name="startsahi" description="start sahi proxy">
		<java classname="net.sf.sahi.Proxy" fork="true" spawn="true" dir="${sahi.home}">
			<!--<env key="MOZ_NO_REMOTE" value="1"/>-->
			<classpath location="${sahi.home}/lib/sahi.jar">
				<fileset dir="${sahi.home}/extlib" includes="**/*.jar"/>
			</classpath>
			<arg value="${sahi.home}" id="basePath"/>
			<arg value="${user.data}" id="userdataPath"/>
		</java>
	</target>
	<target name="stopsahi" description="stop sahi server">
		<sahi stop="true" sahihost="localhost" sahiport="9999"/>
	</target>       
</project>

Note:About profile,on linux please use sahi\$threadNo instead of sahi$threadNo,details please refer to:http://sahi.co.in/forums/viewtopic.php?pid=4655#p4655

Result

logs:

Poc7.png.png

Test Result:

Poc8.png.png

POC for Businise Partner creation

Scripts

Example:

_include("adlogin_test.sah");
_click(_span("z-tree-ico z-tree-root-close[2]"));
_click(_span("z-tree-ico z-tree-tee-close[13]"));
_click(_image("mWindow.png[100]"));
_click(_image("New24.png"));
_click(_image("spacer.gif[4]"));
_setValue(_textbox(5), "PartnerA");
_click(_cell("Credit Hold"));
_click(_image("spacer.gif[6]"));
_click(_cell("Standard Customers"));
_click(_image("Save24.png"));
_click(_div("z-grid-body[1]"));
_click(_link(4));
_click(_link("Log Out"));

Others please refer to "POC for product creation".

Result

Poc9.png.png

Poc10.png.png

Poc11.png.png

Links