Author: hansbak
Date: Fri Aug 14 04:22:27 2009 New Revision: 804074 URL: http://svn.apache.org/viewvc?rev=804074&view=rev Log: Excellent contribution from Brett G. Palmer in issue: OFBIZ-2116 Added: ofbiz/trunk/framework/testtools/OFBizSeleniumXmlIntro.pdf (with props) ofbiz/trunk/framework/testtools/config/ ofbiz/trunk/framework/testtools/config/seleniumXml.properties (with props) ofbiz/trunk/framework/testtools/convertSeleniumIDE.bat (with props) ofbiz/trunk/framework/testtools/convertSeleniumIDE.sh (with props) ofbiz/trunk/framework/testtools/dtd/SeleniumXml.xsd (with props) ofbiz/trunk/framework/testtools/lib/ ofbiz/trunk/framework/testtools/lib/httpclient-4.0-beta1.jar (with props) ofbiz/trunk/framework/testtools/lib/httpcore-4.0-beta2.jar (with props) ofbiz/trunk/framework/testtools/lib/httpmime-4.0-beta1.jar (with props) ofbiz/trunk/framework/testtools/lib/json-lib-2.2.3-jdk15.jar (with props) ofbiz/trunk/framework/testtools/lib/ofbiz-testtools.jar (with props) ofbiz/trunk/framework/testtools/lib/selenium-java-client-driver.jar (with props) ofbiz/trunk/framework/testtools/runSeleniumServer.bat (with props) ofbiz/trunk/framework/testtools/runSeleniumServer.sh (with props) ofbiz/trunk/framework/testtools/runSeleniumXml.bat (with props) ofbiz/trunk/framework/testtools/runSeleniumXml.sh (with props) ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/ ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoader.java (with props) ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoop.java (with props) ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/GroovyRunner.java (with props) ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/InitJython.java (with props) ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/JythonRunner.java (with props) ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/RemoteRequest.java (with props) ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/SeleniumIDEConverter.java (with props) ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/SeleniumXml.java (with props) ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/util/ ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/util/TestUtils.java (with props) ofbiz/trunk/framework/testtools/testdef/ ofbiz/trunk/framework/testtools/testdef/seleniumxml/ ofbiz/trunk/framework/testtools/testdef/seleniumxml/example/ ofbiz/trunk/framework/testtools/testdef/seleniumxml/example/example_ajax.xml (with props) ofbiz/trunk/framework/testtools/testdef/seleniumxml/example/example_login.xml (with props) ofbiz/trunk/framework/testtools/testdef/seleniumxml/example/example_new.xml (with props) ofbiz/trunk/framework/testtools/testdef/seleniumxml/example/example_search.xml (with props) ofbiz/trunk/framework/testtools/testdef/seleniumxml/example/example_testsuite.xml (with props) ofbiz/trunk/framework/testtools/testdef/seleniumxml/example/recorded/ ofbiz/trunk/framework/testtools/testdef/seleniumxml/example/recorded/AjaxExample.html (with props) ofbiz/trunk/framework/testtools/testdef/seleniumxml/example/recorded/AjaxExample.xml (with props) ofbiz/trunk/framework/testtools/testdef/seleniumxml/example/recorded/NewExample.html (with props) ofbiz/trunk/framework/testtools/testdef/seleniumxml/example/recorded/NewExample.xml (with props) ofbiz/trunk/framework/testtools/testdef/seleniumxml/example/recorded/NewFeature.html (with props) ofbiz/trunk/framework/testtools/testdef/seleniumxml/example/recorded/NewFeature.xml (with props) Modified: ofbiz/trunk/.classpath ofbiz/trunk/build.xml ofbiz/trunk/framework/testtools/build.xml ofbiz/trunk/framework/testtools/ofbiz-component.xml ofbiz/trunk/framework/webapp/config/url.properties Modified: ofbiz/trunk/.classpath URL: http://svn.apache.org/viewvc/ofbiz/trunk/.classpath?rev=804074&r1=804073&r2=804074&view=diff ============================================================================== --- ofbiz/trunk/.classpath (original) +++ ofbiz/trunk/.classpath Fri Aug 14 04:22:27 2009 @@ -181,5 +181,7 @@ <classpathentry kind="lib" path="framework/webslinger/lib/webslinger-extension-velocity-20090630-3606-466aec2fb8ad.jar"/> <classpathentry kind="lib" path="framework/webslinger/lib/webslinger-extension-wiki-20090630-3606-466aec2fb8ad.jar"/> <classpathentry kind="lib" path="framework/webslinger/lib/webslinger-launcher-20090630-3606-466aec2fb8ad.jar"/> + <classpathentry kind="lib" path="framework/testtools/lib/selenium-server.jar"/> + <classpathentry kind="lib" path="framework/testtools/lib/selenium-java-client-driver.jar"/> <classpathentry kind="output" path="bin"/> </classpath> Modified: ofbiz/trunk/build.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/build.xml?rev=804074&r1=804073&r2=804074&view=diff ============================================================================== --- ofbiz/trunk/build.xml (original) +++ ofbiz/trunk/build.xml Fri Aug 14 04:22:27 2009 @@ -85,6 +85,12 @@ </subant> </target> + <target name="download-selenium" description="Download the selenium files"> + <subant target="install-seleniumxml"> + <filelist dir="." files="framework/testtools/build.xml"/> + </subant> + </target> + <target name="clean-cache" description="Clean the UtilCache file if errors found with old objects in the cache (Java runtime error something like 'local class incompatible')"> <property file="framework/base/config/cache.properties"/> Added: ofbiz/trunk/framework/testtools/OFBizSeleniumXmlIntro.pdf URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/OFBizSeleniumXmlIntro.pdf?rev=804074&view=auto ============================================================================== Binary file - no diff available. Propchange: ofbiz/trunk/framework/testtools/OFBizSeleniumXmlIntro.pdf ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Modified: ofbiz/trunk/framework/testtools/build.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/build.xml?rev=804074&r1=804073&r2=804074&view=diff ============================================================================== --- ofbiz/trunk/framework/testtools/build.xml (original) +++ ofbiz/trunk/framework/testtools/build.xml Fri Aug 14 04:22:27 2009 @@ -30,17 +30,24 @@ <property name="ofbiz.home.dir" value="../.."/> <path id="local.class.path"> - <!-- <fileset dir="${lib.dir}" includes="*.jar"/> --> + <fileset dir="${lib.dir}" includes="*.jar"/> <fileset dir="../base/lib" includes="*.jar"/> + <fileset dir="../base/lib/scripting" includes="*.jar"/> <fileset dir="../base/lib/commons" includes="*.jar"/> - <fileset dir="../base/build/lib" includes="*.jar"/> + <fileset dir="../base/build/lib" includes="*.jar"/> <fileset dir="../entity/lib" includes="*.jar"/> <fileset dir="../entity/build/lib" includes="*.jar"/> <fileset dir="../security/build/lib" includes="*.jar"/> <fileset dir="../service/lib" includes="*.jar"/> <fileset dir="../service/build/lib" includes="*.jar"/> <fileset dir="../minilang/build/lib" includes="*.jar"/> + <fileset dir="../webapp/lib" includes="*.jar"/> </path> + + <target name="init"> + <property name="lib.dir" value="lib"/> + <property name="selenium.lib.dir" value="${lib.dir}"/> + </target> <!-- ================================================================== --> <!-- Compilation of the source files --> @@ -50,6 +57,13 @@ <javac15/> </target> + + <target name="install-seleniumxml" depends="init" description="Download the selenium files"> + <!--mkdir dir="${selenium.lib.dir}"/--> + <get src="http://downloads.sourceforge.net/seleniumxml/selenium-server-1.0-SNAPSHOT-20081126.jar?use_mirror=" + dest="${selenium.lib.dir}/selenium-server.jar" usetimestamp="true" /> + </target> + <!-- ================================================================== --> <!-- Build JavaDoc --> <!-- ================================================================== --> Added: ofbiz/trunk/framework/testtools/config/seleniumXml.properties URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/config/seleniumXml.properties?rev=804074&view=auto ============================================================================== --- ofbiz/trunk/framework/testtools/config/seleniumXml.properties (added) +++ ofbiz/trunk/framework/testtools/config/seleniumXml.properties Fri Aug 14 04:22:27 2009 @@ -0,0 +1,5 @@ +serverHost=localhost +proxyPort=4444 +browser=*firefox +startUrl=http://localhost:8080/ +log4jFile=./config/log4j.properties Propchange: ofbiz/trunk/framework/testtools/config/seleniumXml.properties ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/testtools/config/seleniumXml.properties ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/testtools/config/seleniumXml.properties ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/testtools/convertSeleniumIDE.bat URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/convertSeleniumIDE.bat?rev=804074&view=auto ============================================================================== --- ofbiz/trunk/framework/testtools/convertSeleniumIDE.bat (added) +++ ofbiz/trunk/framework/testtools/convertSeleniumIDE.bat Fri Aug 14 04:22:27 2009 @@ -0,0 +1,16 @@ +set OFBIZ_HOME=../.. +set CP=./build/lib/ofbiz-testtools.jar +set CP=%CP%;./lib/httpclient-4.0-beta1.jar +set CP=%CP%;./lib/selenium-java-client-driver.jar +set CP=%CP%;%OFBIZ_HOME%/framework/base/lib/jdom-1.1.jar +set CP=%CP%;%OFBIZ_HOME%/framework/base/lib/scripting/jython-nooro.jar +set CP=%CP%;%OFBIZ_HOME%/framework/base/lib/junit.jar +set CP=%CP%;%OFBIZ_HOME%/framework/base/lib/commons/commons-lang-2.3.jar +set CP=%CP%;%OFBIZ_HOME%/framework/base/lib/log4j-1.2.15.jar + +rem echo %CP% + +rem For Example: +rem convertSeleniumIDE.bat <recorded_script> <converted_script> + +"%JAVA_HOME%/bin/java.exe" -cp %CP% org.ofbiz.testtools.seleniumxml.SeleniumIDEConverter %1 %2 Propchange: ofbiz/trunk/framework/testtools/convertSeleniumIDE.bat ------------------------------------------------------------------------------ svn:eol-style = CRLF Added: ofbiz/trunk/framework/testtools/convertSeleniumIDE.sh URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/convertSeleniumIDE.sh?rev=804074&view=auto ============================================================================== --- ofbiz/trunk/framework/testtools/convertSeleniumIDE.sh (added) +++ ofbiz/trunk/framework/testtools/convertSeleniumIDE.sh Fri Aug 14 04:22:27 2009 @@ -0,0 +1,24 @@ +#!/bin/sh +export OFBIZ_HOME=../.. +export CP=./build/lib/ofbiz-testtools.jar +export CP=$CP:./lib/httpclient-4.0-beta1.jar +export CP=$CP:./lib/selenium-java-client-driver.jar +export CP=$CP:$OFBIZ_HOME/framework/base/lib/jdom-1.1.jar +export CP=$CP:$OFBIZ_HOME/framework/base/lib/scripting/jython-nooro.jar +export CP=$CP:$OFBIZ_HOME/framework/base/lib/junit.jar +export CP=$CP:$OFBIZ_HOME/framework/base/lib/commons/commons-lang-2.3.jar +export CP=$CP:$OFBIZ_HOME/framework/base/lib/log4j-1.2.15.jar + +# echo $CP + +# For Example: +# convertSeleniumIDE.bat <recorded_script> <converted_script> + +if [ -f "$JAVA_HOME/bin/java" ]; then + JAVA="$JAVA_HOME/bin/java" +else + JAVA=java +fi + +"$JAVA" -cp $CP org.ofbiz.testtools.seleniumxml.SeleniumIDEConverter "$@" +exit 0 Propchange: ofbiz/trunk/framework/testtools/convertSeleniumIDE.sh ------------------------------------------------------------------------------ svn:eol-style = LF Propchange: ofbiz/trunk/framework/testtools/convertSeleniumIDE.sh ------------------------------------------------------------------------------ svn:executable = * Propchange: ofbiz/trunk/framework/testtools/convertSeleniumIDE.sh ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Added: ofbiz/trunk/framework/testtools/dtd/SeleniumXml.xsd URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/dtd/SeleniumXml.xsd?rev=804074&view=auto ============================================================================== --- ofbiz/trunk/framework/testtools/dtd/SeleniumXml.xsd (added) +++ ofbiz/trunk/framework/testtools/dtd/SeleniumXml.xsd Fri Aug 14 04:22:27 2009 @@ -0,0 +1,507 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" + elementFormDefault="qualified"> + <!-- + ================================================== + ========== Element and Attribute definitions for + ========== SeleniumXml project =================== + ================================================== + --> + <xs:group name="AllCommands"><!-- All SeleniumXml command which normally match with the SeleniumRC Java API. --> + <xs:choice> + <xs:element ref="testcase" /> + <xs:element ref="type" /> + <xs:element ref="loadData" /> + <xs:element ref="selectPopup" /> + <xs:element ref="getAllWindowIds" /> + <xs:element ref="captureTextInPage" /> + <xs:element ref="getSelectedLabel" /> + <xs:element ref="getSelectedValue" /> + <xs:element ref="getSelectedId" /> + <xs:element ref="assertContains" /> + <xs:element ref="getHtmlSource" /> + <xs:element ref="getBodyText" /> + <xs:element ref="print" /> + <xs:element ref="waitForPageToLoad" /> + <xs:element ref="getSelectedIds" /> + <xs:element ref="copy" /> + <xs:element ref="append" /> + <xs:element ref="open" /> + <xs:element ref="click" /> + <xs:element ref="select" /> + <xs:element ref="uniqueId" /> + <xs:element ref="randomAlphaString" /> + <xs:element ref="randomString" /> + <xs:element ref="setSpeed" /> + </xs:choice> + </xs:group> + + + <xs:element name="testcase"> + <xs:annotation> + <xs:documentation></xs:documentation> + </xs:annotation> + + <xs:complexType> + <xs:sequence> + <xs:group minOccurs="0" maxOccurs="unbounded" ref="AllCommands"/> + </xs:sequence> + + <xs:attributeGroup ref="attlist.name-value" /> + <xs:attribute name="LABEL" type="xs:string" use="required" /> + </xs:complexType> + </xs:element> + + <xs:element name="type" > + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:attributeGroup ref="attlist.name-value"/> + </xs:complexType> + </xs:element> + <xs:element name="loadData"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:attributeGroup ref="attlist.file"/> + <xs:attributeGroup ref="attlist.loadData"/> + </xs:complexType> + </xs:element> + + <xs:element name="selectPopup"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:attributeGroup ref="attlist.selectPopup"/> + </xs:complexType> + </xs:element> + + <xs:element name="getAllWindowIds"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:attributeGroup ref="attlist.getAllWindowIds"/> + </xs:complexType> + </xs:element> + + <xs:element name="captureTextInPage"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:attributeGroup ref="attlist.captureTextInPage"/> + </xs:complexType> + </xs:element> + + <xs:element name="getSelectedLabel"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:attributeGroup ref="attlist.getSelectedLabel"/> + </xs:complexType> + </xs:element> + + <xs:element name="getSelectedValue"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:group minOccurs="0" maxOccurs="unbounded" ref="AllCommands"/> + <xs:attributeGroup ref="attlist.getSelectedLabel"/> + </xs:complexType> + </xs:element> + + <xs:element name="getSelectedId"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:attributeGroup ref="attlist.getSelectedLabel"/> + </xs:complexType> + </xs:element> + + <xs:element name="assertContains"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:attributeGroup ref="attlist.assertContains"/> + </xs:complexType> + </xs:element> + + <xs:element name="getHtmlSource"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:attributeGroup ref="attlist.out"/> + </xs:complexType> + </xs:element> + + <xs:element name="getBodyText"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:attributeGroup ref="attlist.out"/> + </xs:complexType> + </xs:element> + + <xs:element name="print"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:attributeGroup ref="attlist.print"/> + </xs:complexType> + </xs:element> + + <xs:element name="waitForPageToLoad"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:attributeGroup ref="attlist.print"/> + </xs:complexType> + </xs:element> + + <xs:element name="getSelectedIds"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:attributeGroup ref="attlist.print"/> + </xs:complexType> + </xs:element> + + <xs:element name="copy"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:attributeGroup ref="attlist.copy"/> + </xs:complexType> + </xs:element> + + <xs:element name="append"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:attributeGroup ref="attlist.append"/> + <xs:attributeGroup ref="attlist.out"/> + </xs:complexType> + </xs:element> + + <xs:element name="open"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:attributeGroup ref="attlist.print"/> + </xs:complexType> + </xs:element> + + <xs:element name="click"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:attributeGroup ref="attlist.locator"/> + </xs:complexType> + </xs:element> + + <xs:element name="select"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:attributeGroup ref="attlist.option"/> + <xs:attributeGroup ref="attlist.locator"/> + </xs:complexType> + </xs:element> + + + <xs:element name="uniqueId"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:attributeGroup ref="attlist.out"/> + </xs:complexType> + </xs:element> + + <xs:element name="randomAlphaString"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:attributeGroup ref="attlist.out"/> + <xs:attributeGroup ref="attlist.size-prefix"/> + </xs:complexType> + </xs:element> + + <xs:element name="randomString"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:attributeGroup ref="attlist.out"/> + <xs:attributeGroup ref="attlist.size-prefix"/> + </xs:complexType> + </xs:element> + + <xs:element name="setSpeed"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:attributeGroup ref="attlist.print"/> + </xs:complexType> + </xs:element> + + <!-- +++++++++++++++++++++++++++++++++++++++++++ --> + <!-- Attribute Lists for all Element definitions --> + <!-- +++++++++++++++++++++++++++++++++++++++++++ --> + <xs:attributeGroup name="attlist.file"> + <xs:attribute type="xs:string" name="file" use="optional"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + </xs:attribute> + </xs:attributeGroup> + + <xs:attributeGroup name="attlist.name-value"> + <xs:attribute type="xs:string" name="name" use="required"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + </xs:attribute> + <xs:attribute type="xs:string" name="value" use="required"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + </xs:attribute> + </xs:attributeGroup> + + <xs:attributeGroup name="attlist.loadData"> + <xs:attribute type="xs:string" name="iterations" use="optional"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + </xs:attribute> + </xs:attributeGroup> + + <xs:attributeGroup name="attlist.selectPopup"> + <xs:attribute type="xs:string" name="locator" use="optional"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + </xs:attribute> + <xs:attribute type="xs:string" name="timeout" use="optional"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + </xs:attribute> + </xs:attributeGroup> + + <xs:attributeGroup name="attlist.getAllWindowIds"> + <xs:attribute type="xs:string" name="winIds" use="optional"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + </xs:attribute> + <xs:attribute type="xs:string" name="winNames" use="optional"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + </xs:attribute> + </xs:attributeGroup> + + <xs:attributeGroup name="attlist.captureTextInPage"> + <xs:attribute type="xs:string" name="regex" use="optional"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + </xs:attribute> + <xs:attribute type="xs:string" name="group" use="optional"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + </xs:attribute> + <xs:attribute type="xs:string" name="results" use="optional"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + </xs:attribute> + </xs:attributeGroup> + + <xs:attributeGroup name="attlist.getSelectedLabel"> + <xs:attribute type="xs:string" name="locator" use="optional"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + </xs:attribute> + <xs:attribute type="xs:string" name="out" use="optional"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + </xs:attribute> + </xs:attributeGroup> + + <xs:attributeGroup name="attlist.assertContains"> + <xs:attribute type="xs:string" name="src" use="optional"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + </xs:attribute> + <xs:attribute type="xs:string" name="test" use="optional"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + </xs:attribute> + </xs:attributeGroup> + + <xs:attributeGroup name="attlist.out"> + <xs:attribute type="xs:string" name="out" use="optional"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + </xs:attribute> + </xs:attributeGroup> + + <xs:attributeGroup name="attlist.print"> + <xs:attribute type="xs:string" name="value" use="optional"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + </xs:attribute> + </xs:attributeGroup> + + <xs:attributeGroup name="attlist.copy"> + <xs:attribute type="xs:string" name="to" use="optional"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + </xs:attribute> + <xs:attribute type="xs:string" name="from" use="optional"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + </xs:attribute> + </xs:attributeGroup> + + <xs:attributeGroup name="attlist.append"> + <xs:attribute type="xs:string" name="src1" use="optional"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + </xs:attribute> + <xs:attribute type="xs:string" name="src2" use="optional"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + </xs:attribute> + </xs:attributeGroup> + + <xs:attributeGroup name="attlist.option"> + <xs:attribute type="xs:string" name="option" use="optional"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + </xs:attribute> + </xs:attributeGroup> + + <xs:attributeGroup name="attlist.locator"> + <xs:attribute type="xs:string" name="locator" use="optional"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + </xs:attribute> + </xs:attributeGroup> + + <xs:attributeGroup name="attlist.size-prefix"> + <xs:attribute type="xs:string" name="size" use="optional"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + </xs:attribute> + <xs:attribute type="xs:string" name="prefix" use="optional"> + <xs:annotation> + <xs:documentation> + </xs:documentation> + </xs:annotation> + </xs:attribute> + </xs:attributeGroup> + +</xs:schema> Propchange: ofbiz/trunk/framework/testtools/dtd/SeleniumXml.xsd ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/testtools/dtd/SeleniumXml.xsd ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/testtools/dtd/SeleniumXml.xsd ------------------------------------------------------------------------------ svn:mime-type = text/xsd Added: ofbiz/trunk/framework/testtools/lib/httpclient-4.0-beta1.jar URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/lib/httpclient-4.0-beta1.jar?rev=804074&view=auto ============================================================================== Binary file - no diff available. Propchange: ofbiz/trunk/framework/testtools/lib/httpclient-4.0-beta1.jar ------------------------------------------------------------------------------ svn:executable = * Propchange: ofbiz/trunk/framework/testtools/lib/httpclient-4.0-beta1.jar ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: ofbiz/trunk/framework/testtools/lib/httpcore-4.0-beta2.jar URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/lib/httpcore-4.0-beta2.jar?rev=804074&view=auto ============================================================================== Binary file - no diff available. Propchange: ofbiz/trunk/framework/testtools/lib/httpcore-4.0-beta2.jar ------------------------------------------------------------------------------ svn:executable = * Propchange: ofbiz/trunk/framework/testtools/lib/httpcore-4.0-beta2.jar ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: ofbiz/trunk/framework/testtools/lib/httpmime-4.0-beta1.jar URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/lib/httpmime-4.0-beta1.jar?rev=804074&view=auto ============================================================================== Binary file - no diff available. Propchange: ofbiz/trunk/framework/testtools/lib/httpmime-4.0-beta1.jar ------------------------------------------------------------------------------ svn:executable = * Propchange: ofbiz/trunk/framework/testtools/lib/httpmime-4.0-beta1.jar ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: ofbiz/trunk/framework/testtools/lib/json-lib-2.2.3-jdk15.jar URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/lib/json-lib-2.2.3-jdk15.jar?rev=804074&view=auto ============================================================================== Binary file - no diff available. Propchange: ofbiz/trunk/framework/testtools/lib/json-lib-2.2.3-jdk15.jar ------------------------------------------------------------------------------ svn:executable = * Propchange: ofbiz/trunk/framework/testtools/lib/json-lib-2.2.3-jdk15.jar ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: ofbiz/trunk/framework/testtools/lib/ofbiz-testtools.jar URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/lib/ofbiz-testtools.jar?rev=804074&view=auto ============================================================================== Binary file - no diff available. Propchange: ofbiz/trunk/framework/testtools/lib/ofbiz-testtools.jar ------------------------------------------------------------------------------ svn:executable = * Propchange: ofbiz/trunk/framework/testtools/lib/ofbiz-testtools.jar ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: ofbiz/trunk/framework/testtools/lib/selenium-java-client-driver.jar URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/lib/selenium-java-client-driver.jar?rev=804074&view=auto ============================================================================== Binary file - no diff available. Propchange: ofbiz/trunk/framework/testtools/lib/selenium-java-client-driver.jar ------------------------------------------------------------------------------ svn:executable = * Propchange: ofbiz/trunk/framework/testtools/lib/selenium-java-client-driver.jar ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Modified: ofbiz/trunk/framework/testtools/ofbiz-component.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/ofbiz-component.xml?rev=804074&r1=804073&r2=804074&view=diff ============================================================================== --- ofbiz/trunk/framework/testtools/ofbiz-component.xml (original) +++ ofbiz/trunk/framework/testtools/ofbiz-component.xml Fri Aug 14 04:22:27 2009 @@ -23,11 +23,13 @@ xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/ofbiz-component.xsd"> <!-- define resource loaders; most common is to use the component resource loader --> <resource-loader name="main" type="component"/> + <classpath type="dir" location="config"/> <!-- place the config directory on the classpath to access configuration files --> <classpath type="dir" location="dtd"/> <!-- load single or multiple external libraries --> + <classpath type="jar" location="lib/*"/> <classpath type="jar" location="build/lib/*"/> <!-- service resources: model(s), eca(s) and group definitions --> Added: ofbiz/trunk/framework/testtools/runSeleniumServer.bat URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/runSeleniumServer.bat?rev=804074&view=auto ============================================================================== --- ofbiz/trunk/framework/testtools/runSeleniumServer.bat (added) +++ ofbiz/trunk/framework/testtools/runSeleniumServer.bat Fri Aug 14 04:22:27 2009 @@ -0,0 +1 @@ +java -jar ../../framework/testtools/lib/selenium-server.jar -timeout 240 Propchange: ofbiz/trunk/framework/testtools/runSeleniumServer.bat ------------------------------------------------------------------------------ svn:eol-style = CRLF Added: ofbiz/trunk/framework/testtools/runSeleniumServer.sh URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/runSeleniumServer.sh?rev=804074&view=auto ============================================================================== --- ofbiz/trunk/framework/testtools/runSeleniumServer.sh (added) +++ ofbiz/trunk/framework/testtools/runSeleniumServer.sh Fri Aug 14 04:22:27 2009 @@ -0,0 +1,11 @@ +#!/bin/sh +# location of java executable +if [ -f "$JAVA_HOME/bin/java" ]; then + JAVA="$JAVA_HOME/bin/java" +else + JAVA=java +fi + +"$JAVA" -jar ../../framework/testtools/lib/selenium-server.jar -timeout 240 +exit 0 + Propchange: ofbiz/trunk/framework/testtools/runSeleniumServer.sh ------------------------------------------------------------------------------ svn:eol-style = LF Propchange: ofbiz/trunk/framework/testtools/runSeleniumServer.sh ------------------------------------------------------------------------------ svn:executable = * Propchange: ofbiz/trunk/framework/testtools/runSeleniumServer.sh ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Added: ofbiz/trunk/framework/testtools/runSeleniumXml.bat URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/runSeleniumXml.bat?rev=804074&view=auto ============================================================================== --- ofbiz/trunk/framework/testtools/runSeleniumXml.bat (added) +++ ofbiz/trunk/framework/testtools/runSeleniumXml.bat Fri Aug 14 04:22:27 2009 @@ -0,0 +1,14 @@ +rem set JAVA_HOME=%JDK_15% +set OFBIZ_HOME=../.. +set CP=./build/lib/ofbiz-testtools.jar +set CP=%CP%;./lib/httpclient-4.0-beta1.jar +set CP=%CP%;./lib/selenium-java-client-driver.jar +set CP=%CP%;%OFBIZ_HOME%/framework/base/lib/jdom-1.1.jar +set CP=%CP%;%OFBIZ_HOME%/framework/base/lib/scripting/jython-nooro.jar +set CP=%CP%;%OFBIZ_HOME%/framework/base/lib/junit.jar +set CP=%CP%;%OFBIZ_HOME%/framework/base/lib/commons/commons-lang-2.3.jar +set CP=%CP%;%OFBIZ_HOME%/framework/base/lib/log4j-1.2.15.jar + +echo %CP% + +"%JAVA_HOME%/bin/java.exe" -Dselenium.config=./config/seleniumXml.properties -cp %CP% org.ofbiz.testtools.seleniumxml.SeleniumXml %1 Propchange: ofbiz/trunk/framework/testtools/runSeleniumXml.bat ------------------------------------------------------------------------------ svn:eol-style = CRLF Added: ofbiz/trunk/framework/testtools/runSeleniumXml.sh URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/runSeleniumXml.sh?rev=804074&view=auto ============================================================================== --- ofbiz/trunk/framework/testtools/runSeleniumXml.sh (added) +++ ofbiz/trunk/framework/testtools/runSeleniumXml.sh Fri Aug 14 04:22:27 2009 @@ -0,0 +1,26 @@ +#!/bin/sh +# export JAVA_HOME=$JDK_15 +export OFBIZ_HOME=../.. +export CP=./build/lib/ofbiz-testtools.jar +export CP=$CP:./lib/httpclient-4.0-beta1.jar +export CP=$CP:./lib/selenium-java-client-driver.jar +export CP=$CP:$OFBIZ_HOME/framework/base/lib/jdom-1.1.jar +export CP=$CP:$OFBIZ_HOME/framework/base/lib/scripting/jython-nooro.jar +export CP=$CP:$OFBIZ_HOME/framework/base/lib/junit.jar +export CP=$CP:$OFBIZ_HOME/framework/base/lib/commons/commons-lang-2.3.jar +export CP=$CP:$OFBIZ_HOME/framework/base/lib/log4j-1.2.15.jar + +echo $CP + +if [ -f "$JAVA_HOME/bin/java" ]; then + JAVA="$JAVA_HOME/bin/java" +else + JAVA=java +fi + +"$JAVA" -Dselenium.config=./config/seleniumXml.properties -cp $CP org.ofbiz.testtools.seleniumxml.SeleniumXml $1; + + + + + Propchange: ofbiz/trunk/framework/testtools/runSeleniumXml.sh ------------------------------------------------------------------------------ svn:eol-style = LF Propchange: ofbiz/trunk/framework/testtools/runSeleniumXml.sh ------------------------------------------------------------------------------ svn:executable = * Propchange: ofbiz/trunk/framework/testtools/runSeleniumXml.sh ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Added: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoader.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoader.java?rev=804074&view=auto ============================================================================== --- ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoader.java (added) +++ ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoader.java Fri Aug 14 04:22:27 2009 @@ -0,0 +1,120 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.ofbiz.testtools.seleniumxml; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.jdom.Element; +import org.python.core.PyArray; +import org.python.core.PyDictionary; +import org.python.core.PyList; +import org.python.core.PyObject; +import org.python.util.PythonInterpreter; + +public class DataLoader { + + private String file; + private String iterations; + private SeleniumXml parent; + private SeleniumXml currentTest; + private List children; + + private int currentRowIndx; + + + //Objects initialized from csvreader script. + private PyDictionary fieldNameMap; + private PyList dataList; + private PyList fieldNames; + + + + + public DataLoader(String file, String iterations, SeleniumXml parent, List<Element> children) { + super(); + this.file = file; + this.iterations = iterations; + this.parent = parent; + this.children = children; + initData(); + } + + private void initData() { + // Run the python script + // Read header and get record count + PythonInterpreter interp = InitJython.getInterpreter(); + + Map map = new HashMap(); + map.put("file", this.file); + interp.set("params", map); + interp.exec("from csvreader import CSVReader"); + String cmd = "reader = CSVReader('" + this.file + "')"; + interp.exec(cmd); + this.dataList = (PyList) interp.eval("reader.dataList"); + this.fieldNames = (PyList) interp.eval("reader.fieldNames"); + this.fieldNameMap = (PyDictionary) interp.eval("reader.fieldNameMap"); + //interp.execfile("c:/dev/ag/seleniumxml/plugins/csvreader.py"); + //interp.execfile("c:/dev/ag/seleniumxml/plugins/TestCSVReader.py"); + + //Now get output from script + //this.dataList = (PyArray) map.get("dataList"); + //this.fieldNames = (PyDictionary) map.get("fieldNames"); + + } + + private void next() { + this.currentRowIndx = (this.currentRowIndx + 1) % this.dataList.__len__(); + } + + private void loadData() { + + int size = this.fieldNames.__len__(); + for(int i=0; i<size; i++ ) { + PyObject name = this.fieldNames.__getitem__(i); + PyObject valueList = this.dataList.__getitem__(this.currentRowIndx); + PyObject columnIndx = this.fieldNameMap.__getitem__(name); + Integer convIndx = (Integer) columnIndx.__tojava__(Integer.class); + //int convIndx = Integer.parseInt((String) columnIndx.__tojava__(String.class)); + PyObject value = valueList.__getitem__(convIndx); + this.currentTest.addParam((String) name.__tojava__(String.class), (String) value.__tojava__(String.class)); + } + + } + + public void runTest() { + + //Depending on the iteration instruction repeat the following until complete + int iter = Integer.parseInt(this.iterations); + + //Iterate through entire list of data + if(iter == -1) { + iter = this.dataList.__len__(); + } + + this.currentTest = new SeleniumXml(this.parent); + for( int i=0; i<iter; i++) { + loadData(); + currentTest.runCommands(this.children); + next(); + } + + } +} Propchange: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoader.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoader.java ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoader.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoop.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoop.java?rev=804074&view=auto ============================================================================== --- ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoop.java (added) +++ ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoop.java Fri Aug 14 04:22:27 2009 @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.ofbiz.testtools.seleniumxml; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.jdom.Element; +import org.python.core.PyArray; +import org.python.core.PyDictionary; +import org.python.core.PyList; +import org.python.core.PyObject; +import org.python.util.PythonInterpreter; + +public class DataLoop { + + private String dataListName; + private SeleniumXml parent; + private SeleniumXml currentTest; + private List children; + + private int currentRowIndx; + + + + public DataLoop(String dataListName, SeleniumXml parent, List<Element> children) { + super(); + this.dataListName = dataListName; + this.parent = parent; + this.children = children; + } + + public void runTest() { + + this.currentTest = new SeleniumXml(this.parent); + Map dataMap = this.parent.getMap(); + List dataList = (List)dataMap.get(this.dataListName); + Iterator iter = dataList.iterator(); + while (iter.hasNext()) { + Map mp = (Map)iter.next(); + // TODO, WARNING - these name could collide with names already in the test context + Set eSet = mp.entrySet(); + Iterator iter2 = eSet.iterator(); + while(iter2.hasNext()) { + Map.Entry entry = (Map.Entry)iter2.next(); + String name = (String)entry.getKey(); + Object value = entry.getValue(); + dataMap.put(name, value); + } + currentTest.runCommands(this.children); + } + + } +} Propchange: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoop.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoop.java ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoop.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/GroovyRunner.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/GroovyRunner.java?rev=804074&view=auto ============================================================================== --- ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/GroovyRunner.java (added) +++ ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/GroovyRunner.java Fri Aug 14 04:22:27 2009 @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.ofbiz.testtools.seleniumxml; + +import groovy.lang.Binding; +import groovy.lang.GroovyClassLoader; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.codehaus.groovy.runtime.InvokerHelper; +import org.jdom.Element; +import org.ofbiz.testtools.seleniumxml.util.TestUtils; + +public class GroovyRunner { + + private String urlName; + private SeleniumXml parent; + private SeleniumXml currentTest; + + private int currentRowIndx; + public static GroovyClassLoader groovyClassLoader = new GroovyClassLoader(); + + + public GroovyRunner(String urlName, SeleniumXml parent) { + super(); + this.urlName = urlName; + this.parent = parent; + } + + public void runTest() { + + Map map = this.parent.getMap(); + map.put("url", this.urlName); + try { + String scriptText = TestUtils.readUrlText(this.urlName); + Class scriptClass = groovyClassLoader.parseClass(scriptText); + + Binding binding = new Binding(); + binding.setVariable("context", map); + binding.setVariable("seleniumXml", this.parent); + InvokerHelper.createScript(scriptClass, binding).run(); + } catch(MalformedURLException e) { + System.out.println("Scriptrunner, runTest, MalformedURLException error: " + e.getMessage()); + } catch(IOException e) { + System.out.println("Scriptrunner, runTest, IOException error: " + e.getMessage()); + } + + + } + +} Propchange: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/GroovyRunner.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/GroovyRunner.java ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/GroovyRunner.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/InitJython.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/InitJython.java?rev=804074&view=auto ============================================================================== --- ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/InitJython.java (added) +++ ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/InitJython.java Fri Aug 14 04:22:27 2009 @@ -0,0 +1,77 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.ofbiz.testtools.seleniumxml; + +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + + +import org.apache.log4j.Logger; + +import org.python.core.PySystemState; +import org.python.util.PythonInterpreter; + +/** + * + */ +public class InitJython { + +// public Logger logger = Logger.getLogger(InitJython.class.getName()); + + private static PythonInterpreter SINGLETON; + + /** Only allow creation through the factory method */ + protected InitJython() { +// logger.setLevel(Level.DEBUG); + } + + /** + * getInterpreter initializes the Python environment the first time. It then issues a + * new Interpreter for each request. + * @return PythonInterpreter + */ + public static PythonInterpreter getInterpreter() { + + if (SINGLETON == null) { + synchronized (InitJython.class) { + Properties props = System.getProperties(); + //String ofbizHome = props.getProperty("ofbiz.home"); + + Properties pyProps = new Properties(); + + if( props.getProperty("python.home") == null) { + //pyProps.setProperty("python.home", "c:/devtools/jython2.2rc2"); + pyProps.setProperty("python.home", "c:/devtools/Python24"); + } + + //Debug.logInfo(props.toString(), module); + ClassLoader loader = Thread.currentThread().getContextClassLoader(); + PySystemState.initialize(props, pyProps, new String[0], loader); + + SINGLETON = new PythonInterpreter(); + + SINGLETON.exec("import sys"); + SINGLETON.exec("sys.path.append(\"c:/dev/ag/seleniumXml/plugins\")"); + } + } + + return SINGLETON; + } +} Propchange: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/InitJython.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/InitJython.java ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/InitJython.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/JythonRunner.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/JythonRunner.java?rev=804074&view=auto ============================================================================== --- ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/JythonRunner.java (added) +++ ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/JythonRunner.java Fri Aug 14 04:22:27 2009 @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.ofbiz.testtools.seleniumxml; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.jdom.Element; +import org.ofbiz.testtools.seleniumxml.util.TestUtils; +import org.python.core.PyArray; +import org.python.core.PyDictionary; +import org.python.core.PyList; +import org.python.core.PyObject; +import org.python.util.PythonInterpreter; + +public class JythonRunner { + + private String urlName; + private SeleniumXml parent; + private SeleniumXml currentTest; + + private int currentRowIndx; + + + public JythonRunner(String urlName, SeleniumXml parent) { + super(); + this.urlName = urlName; + this.parent = parent; + } + + public void runTest() { + + PythonInterpreter interp = InitJython.getInterpreter(); + + Map map = this.parent.getMap(); + map.put("url", this.urlName); + try { + String scriptText = TestUtils.readUrlText(this.urlName); + interp.set("context", map); + interp.exec(scriptText); + } catch(MalformedURLException e) { + System.out.println("Scriptrunner, runTest, MalformedURLException error: " + e.getMessage()); + } catch(IOException e) { + System.out.println("Scriptrunner, runTest, IOException error: " + e.getMessage()); + } + + + } + +} Propchange: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/JythonRunner.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/JythonRunner.java ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/JythonRunner.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/RemoteRequest.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/RemoteRequest.java?rev=804074&view=auto ============================================================================== --- ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/RemoteRequest.java (added) +++ ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/RemoteRequest.java Fri Aug 14 04:22:27 2009 @@ -0,0 +1,333 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.ofbiz.testtools.seleniumxml; + +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.http.Header; +import org.apache.http.HttpEntity; +import org.apache.http.HttpHost; +import org.apache.http.HttpRequest; +import org.apache.http.HttpResponse; +import org.apache.http.HttpVersion; +import org.apache.http.auth.AuthScope; +import org.apache.http.auth.UsernamePasswordCredentials; +import org.apache.http.client.CookieStore; +import org.apache.http.client.HttpResponseException; +import org.apache.http.client.ResponseHandler; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.params.HttpClientParams; +import org.apache.http.client.protocol.ClientContext; +import org.apache.http.conn.ClientConnectionManager; +import org.apache.http.conn.scheme.PlainSocketFactory; +import org.apache.http.conn.scheme.Scheme; +import org.apache.http.conn.scheme.SchemeRegistry; +import org.apache.http.conn.scheme.SocketFactory; +import org.apache.http.cookie.Cookie; +import org.apache.http.impl.client.BasicCookieStore; +import org.apache.http.impl.client.BasicResponseHandler; +import org.apache.http.impl.client.DefaultConnectionKeepAliveStrategy; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager; +import org.apache.http.message.BasicHttpRequest; +import org.apache.http.params.BasicHttpParams; +import org.apache.http.params.HttpParams; +import org.apache.http.params.HttpProtocolParams; +import org.apache.http.protocol.BasicHttpContext; +import org.apache.http.protocol.HttpContext; +import org.apache.http.util.EntityUtils; +import org.jdom.Element; + +import net.sf.json.JSONException; +import net.sf.json.JSONObject; + + +public class RemoteRequest { + + public static final String module = RemoteRequest.class.getName(); + + /** + * The default parameters. + * Instantiated in {@link #setup setup}. + */ + private static HttpParams defaultParameters = null; + + /** + * The scheme registry. + * Instantiated in {@link #setup setup}. + */ + private static SchemeRegistry supportedSchemes; + final private static String JsonHandleMode = "JSON_HANDLE"; + final private static String HttpHandleMode = "HTTP_HANDLE"; + + private SeleniumXml parent; + private SeleniumXml currentTest; + private List <Element>children; + private Map <String, Object> inMap; + private Map <String, String> outMap; + private String requestUrl; + private String host; + private String responseHandlerMode; + + private int currentRowIndx; + + static { + + supportedSchemes = new SchemeRegistry(); + + // Register the "http" protocol scheme, it is required + // by the default operator to look up socket factories. + SocketFactory sf = PlainSocketFactory.getSocketFactory(); + supportedSchemes.register(new Scheme("http", sf, 80)); + + // prepare parameters + HttpParams params = new BasicHttpParams(); + HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); + HttpProtocolParams.setContentCharset(params, "UTF-8"); + HttpProtocolParams.setUseExpectContinue(params, true); + //HttpClientParams.setAuthenticating(params, true); + defaultParameters = params; + + } + public RemoteRequest(SeleniumXml parent, List<Element> children, String requestUrl, String hostString, String responseHandlerMode) { + super(); + this.parent = parent; + this.requestUrl = requestUrl; + this.host = hostString; + this.children = children; + this.responseHandlerMode = (HttpHandleMode.equals(responseHandlerMode)) ? HttpHandleMode : JsonHandleMode; + initData(); + } + + private void initData() { + + this.inMap = new HashMap(); + this.outMap = new HashMap(); + String nm, name, value, fieldName = null; + for(Element elem: this.children) { + nm = elem.getName(); + if (nm.equals("param-in")) { + name = elem.getAttributeValue("name"); + value = this.parent.replaceParam(elem.getAttributeValue("value")); + this.inMap.put(name, value); + } else if (nm.equals("param-out")) { + name = elem.getAttributeValue("result-name"); + fieldName = elem.getAttributeValue("field-name"); + if (fieldName == null || fieldName.length() == 0) { + fieldName = name; + } + this.outMap.put(name, fieldName); + } + } + return; + } + + public void runTest() { + + ClientConnectionManager ccm = + new ThreadSafeClientConnManager(defaultParameters, supportedSchemes); + // new SingleClientConnManager(getParams(), supportedSchemes); + + DefaultHttpClient client = new DefaultHttpClient(ccm, defaultParameters); + client.setKeepAliveStrategy(new DefaultConnectionKeepAliveStrategy()); + + //HttpContext clientContext = client. + //HttpHost target = new HttpHost(this.host, 80, "http"); + HttpEntity entity = null; + ResponseHandler <String> responseHandler = null; + try { + BasicHttpContext localContext = new BasicHttpContext(); + // Create a local instance of cookie store + CookieStore cookieStore = new BasicCookieStore(); + localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore); + //this.login(client, localContext); + String paramString2 = "USERNAME=" + this.parent.getUserName() + + "&PASSWORD=" + this.parent.getPassword(); + String thisUri2 = this.host + "/eng/control/login?" + paramString2; + HttpGet req2 = new HttpGet ( thisUri2 ); + req2.setHeader("Connection","Keep-Alive"); + HttpResponse rsp = client.execute(req2, localContext); + + Header sessionHeader = null; + Header[] headers = rsp.getAllHeaders(); + for (int i=0; i<headers.length; i++) { + Header hdr = headers[i]; + String headerValue = hdr.getValue(); + if (headerValue.startsWith("JSESSIONID")) { + sessionHeader = hdr; + } + System.out.println(headers[i]); + System.out.println(hdr.getName() + " : " + hdr.getValue()); + } + + List<Cookie> cookies = cookieStore.getCookies(); + System.out.println("cookies.size(): " + cookies.size()); + for (int i = 0; i < cookies.size(); i++) { + System.out.println("Local cookie(0): " + cookies.get(i)); + } + if (HttpHandleMode.equals(this.responseHandlerMode)) { + + } else { + responseHandler = new JsonResponseHandler(this); + } + String paramString = urlEncodeArgs(this.inMap, false); + String sessionHeaderValue = sessionHeader.getValue(); + int pos1 = sessionHeaderValue.indexOf("="); + int pos2 = sessionHeaderValue.indexOf(";"); + String sessionId = sessionHeaderValue.substring(pos1 + 1, pos2); + System.out.println("sessionId: " + sessionId); + String thisUri = this.host + this.requestUrl + ";jsessionid=" + sessionId + "?" + paramString; + //String thisUri = this.host + this.requestUrl + "?" + paramString; + System.out.println("thisUri: " + thisUri); + HttpGet req = new HttpGet ( thisUri ); + System.out.println("sessionHeader: " + sessionHeader); + req.setHeader(sessionHeader); + + String responseBody = client.execute( req, responseHandler, localContext); + /* + entity = rsp.getEntity(); + + System.out.println("----------------------------------------"); + System.out.println(rsp.getStatusLine()); + Header[] headers = rsp.getAllHeaders(); + for (int i=0; i<headers.length; i++) { + System.out.println(headers[i]); + } + System.out.println("----------------------------------------"); + + if (entity != null) { + System.out.println(EntityUtils.toString(rsp.getEntity())); + } + */ + } catch(HttpResponseException e) { + System.out.println(e.getMessage()); + } catch(IOException e) { + System.out.println(e.getMessage()); + } finally { + // If we could be sure that the stream of the entity has been + // closed, we wouldn't need this code to release the connection. + // However, EntityUtils.toString(...) can throw an exception. + + // if there is no entity, the connection is already released + try { + if (entity != null) + entity.consumeContent(); // release connection gracefully + } catch(IOException e) { + System.out.println("in 'finally' " + e.getMessage()); + } + + } + return; + } + + private void login(DefaultHttpClient client, BasicHttpContext localContext) throws IOException{ + + String paramString = "USERNAME=" + this.parent.getUserName() + + "&PASSWORD=" + this.parent.getPassword(); + String thisUri = this.host + "/eng/control/login?" + paramString; + HttpGet req = new HttpGet ( thisUri ); + req.setHeader("Connection","Keep-Alive"); + client.execute(req, localContext); + + //client.getCredentialsProvider().setCredentials(new AuthScope("localhost", 8080), + // new UsernamePasswordCredentials(this.parent.getUserName(), this.parent.getPassword())); + + return; + } + /** URL Encodes a Map of arguements */ + public static String urlEncodeArgs(Map<String, ? extends Object> args, boolean useExpandedEntites) { + StringBuilder buf = new StringBuilder(); + if (args != null) { + for (Map.Entry<String, ? extends Object> entry: args.entrySet()) { + String name = entry.getKey(); + Object value = entry.getValue(); + String valueStr = null; + if (name != null && value != null) { + if (value instanceof String) { + valueStr = (String) value; + } else { + valueStr = value.toString(); + } + + if (valueStr != null && valueStr.length() > 0) { + if (buf.length() > 0) { + if (useExpandedEntites) { + buf.append("&"); + } else { + buf.append("&"); + } + } + try { + buf.append(URLEncoder.encode(name, "UTF-8")); + } catch (UnsupportedEncodingException e) { + //Debug.logError(e, module); + } + buf.append('='); + try { + buf.append(URLEncoder.encode(valueStr, "UTF-8")); + } catch (UnsupportedEncodingException e) { + // Debug.logError(e, module); + } + } + } + } + } + return buf.toString(); + } + + public class JsonResponseHandler extends BasicResponseHandler { + + private RemoteRequest parentRemoteRequest; + + public JsonResponseHandler(RemoteRequest parentRemoteRequest) { + super(); + this.parentRemoteRequest = parentRemoteRequest; + } + public String handleResponse(org.apache.http.HttpResponse response) + throws HttpResponseException, IOException { + + String bodyString = super.handleResponse(response); + JSONObject jsonObject = null; + try { + jsonObject = JSONObject.fromObject( bodyString ); + } catch(JSONException e) { + throw new HttpResponseException(0, e.getMessage()); + } + Set<Map.Entry<String, String>> paramSet = this.parentRemoteRequest.outMap.entrySet(); + Iterator<Map.Entry<String, String>> paramIter = paramSet.iterator(); + Map parentDataMap = this.parentRemoteRequest.parent.getMap(); + while (paramIter.hasNext()) { + Map.Entry<String, String> paramPair = paramIter.next(); + if (jsonObject.containsKey(paramPair.getKey())) { + Object obj = jsonObject.get(paramPair.getKey()); + parentDataMap.put(paramPair.getKey(), obj); + } + } + return bodyString; + } + + } +} Propchange: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/RemoteRequest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/RemoteRequest.java ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/RemoteRequest.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/SeleniumIDEConverter.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/SeleniumIDEConverter.java?rev=804074&view=auto ============================================================================== --- ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/SeleniumIDEConverter.java (added) +++ ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/SeleniumIDEConverter.java Fri Aug 14 04:22:27 2009 @@ -0,0 +1,183 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.ofbiz.testtools.seleniumxml; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.xml.parsers.ParserConfigurationException; + +import org.jdom.Document; +import org.jdom.Element; +import org.jdom.JDOMException; +import org.jdom.Namespace; +import org.jdom.Attribute; +import org.jdom.filter.ElementFilter; +import org.jdom.input.SAXBuilder; +import org.jdom.output.Format; +import org.jdom.output.XMLOutputter; +import org.jdom.xpath.XPath; +import org.xml.sax.SAXException; + +public class SeleniumIDEConverter { + + private Document ideFile; + private Element xmlDestRoot; + + private Namespace ns = Namespace.getNamespace("http://www.w3.org/1999/xhtml"); + private Map root; + + public void convert(String ideFile, String xmlFile) throws JDOMException, IOException, SAXException, ParserConfigurationException { + + readInputFile(ideFile); + + convertIDECommands(); + + createSeleniumXml(xmlFile); + } + + + private void readInputFile(String input) throws JDOMException, IOException, SAXException, ParserConfigurationException { + + File xmlFile = new File(input); + SAXBuilder builder = new SAXBuilder(); + this.ideFile = builder.build(xmlFile); + + //this.root = new HashMap(); + //this.root.put("doc", freemarker.ext.dom.NodeModel.parse(xmlFile)); + } + + + private void convertIDECommands() throws JDOMException { + + //XPath path = XPath.newInstance("html/body/table/tbody"); + Element root = this.ideFile.getRootElement(); + + this.xmlDestRoot = new Element("testcase"); + + //TODO: there must be a better way to do this with JDom + Element e1 = root.getChild("body",ns); + Element e2 = e1.getChild("table",ns); + Element e3 = e2.getChild("tbody",ns); + List<Element> list = e3.getChildren("tr", ns); + List<Element> commands = root.getChild("body",ns).getChild("table",ns).getChild("tbody",ns).getChildren("tr", ns); + for(Element elem: commands) { + processIDECommand(elem); + } + + } + + private void processIDECommand(Element elem) throws JDOMException { + + + List<Element> cmd = elem.getChildren("td", ns); + Element cmdElem = cmd.get(0); + + String cmdToCompare = cmdElem.getValue(); + System.out.println("Checking for cmd: " + cmdToCompare); + if("clickAndWait".compareTo(cmdElem.getValue()) == 0 ) { + System.out.println("Found clickAndWait"); + this.xmlDestRoot.addContent( buildCommand("click", "locator", cmd.get(1).getValue(), null, null) ); + this.xmlDestRoot.addContent( buildCommand("waitForPageToLoad", "value", "10000", null, null) ); + + } else if("type".compareTo( cmdElem.getValue()) == 0 ) { + System.out.println("Found type"); + this.xmlDestRoot.addContent ( buildCommand("type", "name", cmd.get(1).getValue(), "value", cmd.get(2).getValue()) ); + + } else if("select".compareTo(cmdElem.getValue()) == 0 ) { + System.out.println("Found select"); + this.xmlDestRoot.addContent( buildCommand("select", "locator", cmd.get(1).getValue(), "option", cmd.get(2).getValue()) ); + + } else if("open".compareTo(cmdElem.getValue()) == 0 ) { + System.out.println("Found open"); + this.xmlDestRoot.addContent( buildCommand("open", "value", cmd.get(1).getValue(), null, null) ); + + } else if("click".compareTo(cmdElem.getValue()) == 0 ) { + Element newCmd = new Element("click"); + newCmd.setAttribute("locator", cmd.get(1).getValue()); + this.xmlDestRoot.addContent(newCmd); + + } else if("doubleClick".compareTo(cmdElem.getValue()) == 0 ) { + Element newCmd = new Element("doubleClick"); + newCmd.setAttribute("locator", cmd.get(1).getValue()); + this.xmlDestRoot.addContent(newCmd); + + } else { + System.out.println("WARNING: No definition for " + cmdElem.getValue() + " defaulting to us 'reflection'."); + Element newCmd = new Element(cmdElem.getValue()); + //List attributes = cmdElem.getAttributes(); + int size = cmd.size()-1; + for(int i=1; i<size; i++ ) { + String paramValue = cmd.get(i).getValue(); + System.out.println("param" + (i) + " :" + paramValue); + newCmd.setAttribute("param" + (i), paramValue ); + } + this.xmlDestRoot.addContent(newCmd); + } + + } + + private Element buildCommand(String name, String attrib1, String value1, String attrib2, String value2 ) { + + Element newCmd = new Element(name); + if(attrib1 != null) { + newCmd.setAttribute(attrib1, value1); + } + if(attrib2 != null) { + newCmd.setAttribute(attrib2, value2); + } + return newCmd; + } + private void createSeleniumXml(String outputFile) { + + try { + FileOutputStream out = new FileOutputStream(outputFile); + XMLOutputter serializer = new XMLOutputter( Format.getPrettyFormat()); + serializer.output(this.xmlDestRoot, out); + out.flush(); + out.close(); + } catch (IOException e) { + System.err.println(e); + } + } + /** + * @param args + */ + public static void main(String[] args) { + // TODO Auto-generated method stub + if(args.length != 2) { + System.out.println("Please include the source and destination file paths."); + } else { + SeleniumIDEConverter sel = new SeleniumIDEConverter(); + try { + sel.convert(args[0], args[1]); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + +} Propchange: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/SeleniumIDEConverter.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/SeleniumIDEConverter.java ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/testtools/src/org/ofbiz/testtools/seleniumxml/SeleniumIDEConverter.java ------------------------------------------------------------------------------ svn:mime-type = text/plain |
Free forum by Nabble | Edit this page |