Added: ofbiz/branches/executioncontext20090812/framework/testtools/dtd/SeleniumXml.xsd
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/testtools/dtd/SeleniumXml.xsd?rev=805519&view=auto ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/testtools/dtd/SeleniumXml.xsd (added) +++ ofbiz/branches/executioncontext20090812/framework/testtools/dtd/SeleniumXml.xsd Tue Aug 18 18:10:44 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> Added: ofbiz/branches/executioncontext20090812/framework/testtools/runSeleniumServer.bat URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/testtools/runSeleniumServer.bat?rev=805519&view=auto ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/testtools/runSeleniumServer.bat (added) +++ ofbiz/branches/executioncontext20090812/framework/testtools/runSeleniumServer.bat Tue Aug 18 18:10:44 2009 @@ -0,0 +1 @@ +java -jar ../../framework/testtools/lib/selenium-server.jar -timeout 240 Added: ofbiz/branches/executioncontext20090812/framework/testtools/runSeleniumServer.sh URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/testtools/runSeleniumServer.sh?rev=805519&view=auto ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/testtools/runSeleniumServer.sh (added) +++ ofbiz/branches/executioncontext20090812/framework/testtools/runSeleniumServer.sh Tue Aug 18 18:10:44 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 + Added: ofbiz/branches/executioncontext20090812/framework/testtools/runSeleniumXml.bat URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/testtools/runSeleniumXml.bat?rev=805519&view=auto ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/testtools/runSeleniumXml.bat (added) +++ ofbiz/branches/executioncontext20090812/framework/testtools/runSeleniumXml.bat Tue Aug 18 18:10:44 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 Added: ofbiz/branches/executioncontext20090812/framework/testtools/runSeleniumXml.sh URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/testtools/runSeleniumXml.sh?rev=805519&view=auto ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/testtools/runSeleniumXml.sh (added) +++ ofbiz/branches/executioncontext20090812/framework/testtools/runSeleniumXml.sh Tue Aug 18 18:10:44 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; + + + + + Modified: ofbiz/branches/executioncontext20090812/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoader.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoader.java?rev=805519&r1=805518&r2=805519&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoader.java (original) +++ ofbiz/branches/executioncontext20090812/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoader.java Tue Aug 18 18:10:44 2009 @@ -31,40 +31,40 @@ public class DataLoader { - private String file; - private String iterations; - private SeleniumXml parent; - private SeleniumXml currentTest; - private List children; + private String file; + private String iterations; + private SeleniumXml parent; + private SeleniumXml currentTest; + private List children; - private int currentRowIndx; + private int currentRowIndx; - //Objects initialized from csvreader script. - private PyDictionary fieldNameMap; - private PyList dataList; - private PyList fieldNames; + //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(); - } + 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(); + 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); + 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); @@ -78,43 +78,43 @@ //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(); - } + 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(); + } - } + } } Modified: ofbiz/branches/executioncontext20090812/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoop.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoop.java?rev=805519&r1=805518&r2=805519&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoop.java (original) +++ ofbiz/branches/executioncontext20090812/framework/testtools/src/org/ofbiz/testtools/seleniumxml/DataLoop.java Tue Aug 18 18:10:44 2009 @@ -35,23 +35,23 @@ 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; - } + 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() { + public void runTest() { - this.currentTest = new SeleniumXml(this.parent); + this.currentTest = new SeleniumXml(this.parent); Map dataMap = this.parent.getMap(); List dataList = (List)dataMap.get(this.dataListName); Iterator iter = dataList.iterator(); @@ -60,14 +60,14 @@ // TODO, WARNING - these name could collide with names already in the test context Set eSet = mp.entrySet(); Iterator iter2 = eSet.iterator(); - while(iter2.hasNext()) { + 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); - } - - } + currentTest.runCommands(this.children); + } + + } } Modified: ofbiz/branches/executioncontext20090812/framework/testtools/src/org/ofbiz/testtools/seleniumxml/GroovyRunner.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/testtools/src/org/ofbiz/testtools/seleniumxml/GroovyRunner.java?rev=805519&r1=805518&r2=805519&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/testtools/src/org/ofbiz/testtools/seleniumxml/GroovyRunner.java (original) +++ ofbiz/branches/executioncontext20090812/framework/testtools/src/org/ofbiz/testtools/seleniumxml/GroovyRunner.java Tue Aug 18 18:10:44 2009 @@ -37,21 +37,21 @@ public class GroovyRunner { - private String urlName; - private SeleniumXml parent; - private SeleniumXml currentTest; - - private int currentRowIndx; + 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 GroovyRunner(String urlName, SeleniumXml parent) { + super(); + this.urlName = urlName; + this.parent = parent; + } - public void runTest() { + public void runTest() { Map map = this.parent.getMap(); map.put("url", this.urlName); @@ -63,13 +63,13 @@ binding.setVariable("context", map); binding.setVariable("seleniumXml", this.parent); InvokerHelper.createScript(scriptClass, binding).run(); - } catch(MalformedURLException e) { + } catch (MalformedURLException e) { System.out.println("Scriptrunner, runTest, MalformedURLException error: " + e.getMessage()); - } catch(IOException e) { + } catch (IOException e) { System.out.println("Scriptrunner, runTest, IOException error: " + e.getMessage()); } - - } + + } } Modified: ofbiz/branches/executioncontext20090812/framework/testtools/src/org/ofbiz/testtools/seleniumxml/InitJython.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/testtools/src/org/ofbiz/testtools/seleniumxml/InitJython.java?rev=805519&r1=805518&r2=805519&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/testtools/src/org/ofbiz/testtools/seleniumxml/InitJython.java (original) +++ ofbiz/branches/executioncontext20090812/framework/testtools/src/org/ofbiz/testtools/seleniumxml/InitJython.java Tue Aug 18 18:10:44 2009 @@ -33,45 +33,45 @@ */ 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; +// 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; } } Modified: ofbiz/branches/executioncontext20090812/framework/testtools/src/org/ofbiz/testtools/seleniumxml/JythonRunner.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/testtools/src/org/ofbiz/testtools/seleniumxml/JythonRunner.java?rev=805519&r1=805518&r2=805519&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/testtools/src/org/ofbiz/testtools/seleniumxml/JythonRunner.java (original) +++ ofbiz/branches/executioncontext20090812/framework/testtools/src/org/ofbiz/testtools/seleniumxml/JythonRunner.java Tue Aug 18 18:10:44 2009 @@ -38,20 +38,20 @@ 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; - } + 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() { + public void runTest() { PythonInterpreter interp = InitJython.getInterpreter(); @@ -61,13 +61,13 @@ String scriptText = TestUtils.readUrlText(this.urlName); interp.set("context", map); interp.exec(scriptText); - } catch(MalformedURLException e) { + } catch (MalformedURLException e) { System.out.println("Scriptrunner, runTest, MalformedURLException error: " + e.getMessage()); - } catch(IOException e) { + } catch (IOException e) { System.out.println("Scriptrunner, runTest, IOException error: " + e.getMessage()); } - - } + + } } Modified: ofbiz/branches/executioncontext20090812/framework/testtools/src/org/ofbiz/testtools/seleniumxml/RemoteRequest.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/testtools/src/org/ofbiz/testtools/seleniumxml/RemoteRequest.java?rev=805519&r1=805518&r2=805519&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/testtools/src/org/ofbiz/testtools/seleniumxml/RemoteRequest.java (original) +++ ofbiz/branches/executioncontext20090812/framework/testtools/src/org/ofbiz/testtools/seleniumxml/RemoteRequest.java Tue Aug 18 18:10:44 2009 @@ -167,7 +167,7 @@ String paramString2 = "USERNAME=" + this.parent.getUserName() + "&PASSWORD=" + this.parent.getPassword(); String thisUri2 = this.host + "/eng/control/login?" + paramString2; - HttpGet req2 = new HttpGet ( thisUri2 ); + HttpGet req2 = new HttpGet (thisUri2); req2.setHeader("Connection","Keep-Alive"); HttpResponse rsp = client.execute(req2, localContext); @@ -202,11 +202,11 @@ 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 ); + HttpGet req = new HttpGet (thisUri); System.out.println("sessionHeader: " + sessionHeader); req.setHeader(sessionHeader); - String responseBody = client.execute( req, responseHandler, localContext); + String responseBody = client.execute(req, responseHandler, localContext); /* entity = rsp.getEntity(); @@ -222,9 +222,9 @@ System.out.println(EntityUtils.toString(rsp.getEntity())); } */ - } catch(HttpResponseException e) { + } catch (HttpResponseException e) { System.out.println(e.getMessage()); - } catch(IOException e) { + } catch (IOException e) { System.out.println(e.getMessage()); } finally { // If we could be sure that the stream of the entity has been @@ -235,7 +235,7 @@ try { if (entity != null) entity.consumeContent(); // release connection gracefully - } catch(IOException e) { + } catch (IOException e) { System.out.println("in 'finally' " + e.getMessage()); } @@ -248,7 +248,7 @@ String paramString = "USERNAME=" + this.parent.getUserName() + "&PASSWORD=" + this.parent.getPassword(); String thisUri = this.host + "/eng/control/login?" + paramString; - HttpGet req = new HttpGet ( thisUri ); + HttpGet req = new HttpGet (thisUri); req.setHeader("Connection","Keep-Alive"); client.execute(req, localContext); @@ -312,8 +312,8 @@ String bodyString = super.handleResponse(response); JSONObject jsonObject = null; try { - jsonObject = JSONObject.fromObject( bodyString ); - } catch(JSONException e) { + jsonObject = JSONObject.fromObject(bodyString); + } catch (JSONException e) { throw new HttpResponseException(0, e.getMessage()); } Set<Map.Entry<String, String>> paramSet = this.parentRemoteRequest.outMap.entrySet(); Modified: ofbiz/branches/executioncontext20090812/framework/testtools/src/org/ofbiz/testtools/seleniumxml/SeleniumIDEConverter.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/testtools/src/org/ofbiz/testtools/seleniumxml/SeleniumIDEConverter.java?rev=805519&r1=805518&r2=805519&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/testtools/src/org/ofbiz/testtools/seleniumxml/SeleniumIDEConverter.java (original) +++ ofbiz/branches/executioncontext20090812/framework/testtools/src/org/ofbiz/testtools/seleniumxml/SeleniumIDEConverter.java Tue Aug 18 18:10:44 2009 @@ -42,142 +42,142 @@ public class SeleniumIDEConverter { - private Document ideFile; - private Element xmlDestRoot; + private Document ideFile; + private Element xmlDestRoot; - private Namespace ns = Namespace.getNamespace("http://www.w3.org/1999/xhtml"); - private Map root; + 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 { + 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(); - } - } - } + 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(); + } + } + } } |
Free forum by Nabble | Edit this page |