IDEMPIERE-92 - Integrate Selenium. Selenium test for Zk6 should depends on zk widget/component id instead of uuid. Added new project that contains the initial sample test cases that created using ztl, selenium ide and selenium web driver + zk jq selector.

This commit is contained in:
Heng Sin Low 2012-12-06 18:29:41 +08:00
parent f0c67833e7
commit bb45a55152
37 changed files with 946 additions and 105 deletions

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="lib" path="lib/selenium-java-2.25.0.jar" sourcepath="lib/selenium-java-srcs.jar"/>
<classpathentry kind="lib" path="lib/junit-4.8.2.jar"/>
<classpathentry kind="lib" path="lib/selenium-firefox-driver-2.25.0.jar"/>
<classpathentry kind="lib" path="lib/selenium-api-2.25.0.jar"/>
<classpathentry kind="lib" path="lib/selenium-support-2.25.0.jar"/>
<classpathentry kind="lib" path="lib/guava-12.0.1.jar"/>
<classpathentry kind="lib" path="lib/json-20080701.jar"/>
<classpathentry kind="lib" path="lib/commons-exec-1.1.jar"/>
<classpathentry kind="lib" path="lib/httpcore-4.1.2.jar"/>
<classpathentry kind="lib" path="lib/httpclient-4.1.2.jar"/>
<classpathentry kind="lib" path="lib/commons-logging-1.1.1.jar"/>
<classpathentry kind="lib" path="lib/ztl/ztl-2.0.0-SNAPSHOT.jar" sourcepath="lib/ztl/ztl-2.0.0-sources.jar"/>
<classpathentry kind="lib" path="lib/selenium-remote-driver-2.25.0.jar"/>
<classpathentry kind="lib" path="lib/ztl/selenium-server-standalone-2.25.0.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>idempiere.zk.selenium</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

View File

@ -0,0 +1,28 @@
config.properties
- configuration file for running Ztl generator and Ztl test
ZtlGenerator.launch
- Eclipse launch configuration for Ztl generator
zk.jq.test
- Example test cases written using Selenium Web Driver and Zk JQ selector
zk.selenese.test
- Example test cases exported from Selenium IDE ( JUnit4 + WebDriver )
zk.ztl.test
- Example test cases generated by Ztl generator
resource/selenese
- selenese test script recorded by Selenium IDE
resource/ztl/zk/ztl/test
- ztl test script
Notes
======
* Mapping between selenese ( the native format created by Selenium IDE recording ) and
web driver export is not one to one. For e.g, the fireEvent command is not needed in
web driver test script.
* You must change the "target" instance variable value to "" in the generated ztl java source

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/idempiere.zk.selenium/lib/ztl/ztl-2.0.0-SNAPSHOT.jar"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry containerPath=&quot;org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6&quot; javaProject=&quot;zk.test&quot; path=&quot;1&quot; type=&quot;4&quot;/&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry id=&quot;org.eclipse.jdt.launching.classpathentry.defaultClasspath&quot;&gt;&#10;&lt;memento exportedEntriesOnly=&quot;false&quot; project=&quot;zk.test&quot;/&gt;&#10;&lt;/runtimeClasspathEntry&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/zk.test/lib/ztl/commons-collections-3.2.1.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/zk.test/lib/ztl/commons-lang-2.4.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/zk.test/lib/ztl/velocity-1.7.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;"/>
</listAttribute>
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.zkoss.ztl.util.ZtlGenerator"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-src resource/ztl -dist src"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="idempiere.zk.selenium"/>
</launchConfiguration>

View File

@ -0,0 +1,11 @@
server=http://127.0.0.1:8080
context-path=/webui
delay=500
action=
timeout=20000
browser=firefox
granularity=1
leniency=1
all=firefox
firefox=firefoxdriver
target=

View File

@ -0,0 +1,8 @@
ztl-2.0.0-SNAPSHOT.jar
- for execution of ztl generator and ztl test cases
selenium-server-standalone-2.25.0.jar
- for execution of ztl test cases
others
- for execution of ztl generator

View File

@ -0,0 +1,131 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://127.0.0.1:8080/" />
<title>login</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">login</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>/webui/</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>id=loginPanel_grdLogin_rowUser_txtUserId</td>
<td>SuperUser</td>
</tr>
<tr>
<td>fireEvent</td>
<td>id=loginPanel_grdLogin_rowUser_txtUserId</td>
<td>blur</td>
</tr>
<tr>
<td>type</td>
<td>id=loginPanel_grdLogin_rowPassword_txtPassword</td>
<td>System</td>
</tr>
<tr>
<td>fireEvent</td>
<td>id=loginPanel_grdLogin_rowPassword_txtPassword</td>
<td>blur</td>
</tr>
<tr>
<td>click</td>
<td>id=loginPanel_grdLogin_rowSelectRole_chkSelectRole-real</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=loginPanel_Ok</td>
<td>10</td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>id=rolePanel_grdChooseRole_rowclient_lstClient-btn</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=rolePanel_grdChooseRole_rowclient_lstClient-btn</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>css=#rolePanel_grdChooseRole_rowclient_lstClient_zk_GardenWorld &gt; td.z-comboitem-text</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td>1000</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=rolePanel_grdChooseRole_rowOrganisation_lstOrganisation-btn</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>css=#rolePanel_grdChooseRole_rowOrganisation_lstOrganisation_HQ &gt; td.z-comboitem-text</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=rolePanel_Ok</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>id=loginUserAndRole</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>id=loginUserAndRole</td>
<td>SuperUser@GardenWorld.HQ/GardenWorld Admin</td>
</tr>
<tr>
<td>click</td>
<td>id=changeRole</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>id=rolePanel_grdChooseRole_rowclient_lstClient</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=rolePanel_grdChooseRole_rowclient_lstClient-btn</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>css=#rolePanel_grdChooseRole_rowclient_lstClient_System_ &gt; td.z-comboitem-text</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=rolePanel_Ok</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td>2000</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>id=loginUserAndRole</td>
<td>SuperUser@System.*/System Administrator</td>
</tr>
</tbody></table>
</body>
</html>

View File

@ -0,0 +1,146 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://127.0.0.1:8080/" />
<title>login</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">login</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>/webui/</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>id=loginPanel_grdLogin_rowUser_txtUserId</td>
<td>SuperUser</td>
</tr>
<tr>
<td>fireEvent</td>
<td>id=loginPanel_grdLogin_rowUser_txtUserId</td>
<td>blur</td>
</tr>
<tr>
<td>type</td>
<td>id=loginPanel_grdLogin_rowPassword_txtPassword</td>
<td>System</td>
</tr>
<tr>
<td>fireEvent</td>
<td>id=loginPanel_grdLogin_rowPassword_txtPassword</td>
<td>blur</td>
</tr>
<tr>
<td>click</td>
<td>id=loginPanel_grdLogin_rowSelectRole_chkSelectRole-real</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=loginPanel_Ok</td>
<td>10</td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>id=rolePanel_grdChooseRole_rowclient_lstClient-btn</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=rolePanel_grdChooseRole_rowclient_lstClient-btn</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>css=#rolePanel_grdChooseRole_rowclient_lstClient_zk_comp_32 &gt; td.z-comboitem-text</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td>1000</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=rolePanel_grdChooseRole_rowOrganisation_lstOrganisation-btn</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>css=#rolePanel_grdChooseRole_rowOrganisation_lstOrganisation_HQ &gt; td.z-comboitem-text</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=rolePanel_Ok</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>id=loginUserAndRole</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>id=loginUserAndRole</td>
<td>SuperUser@GardenWorld.HQ/GardenWorld Admin</td>
</tr>
<tr>
<td>type</td>
<td>id=treeSearchCombo-real</td>
<td>Product</td>
</tr>
<tr>
<td>fireEvent</td>
<td>treeSearchCombo-real</td>
<td>blur</td>
</tr>
<tr>
<td>click</td>
<td>id=findWindow_simpleSearch_btnOk</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=Product_1_BtnNew</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=Product_1_Product_Value</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>id=Product_1_Product_Value</td>
<td>test</td>
</tr>
<tr>
<td>fireEvent</td>
<td>id=Product_1_Product_Value</td>
<td>blur</td>
</tr>
<tr>
<td>type</td>
<td>id=Product_1_Product_Name</td>
<td>test</td>
</tr>
<tr>
<td>fireEvent</td>
<td>id=Product_1_Product_Name</td>
<td>blur</td>
</tr>
<tr>
<td>click</td>
<td>id=Product_1_BtnSave</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>

View File

@ -0,0 +1,111 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://127.0.0.1:8080/" />
<title>login</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">login</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>/webui/</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>id=loginPanel_grdLogin_rowUser_txtUserId</td>
<td>SuperUser</td>
</tr>
<tr>
<td>fireEvent</td>
<td>id=loginPanel_grdLogin_rowUser_txtUserId</td>
<td>blur</td>
</tr>
<tr>
<td>type</td>
<td>id=loginPanel_grdLogin_rowPassword_txtPassword</td>
<td>System</td>
</tr>
<tr>
<td>fireEvent</td>
<td>id=loginPanel_grdLogin_rowPassword_txtPassword</td>
<td>blur</td>
</tr>
<tr>
<td>click</td>
<td>id=loginPanel_grdLogin_rowSelectRole_chkSelectRole-real</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=loginPanel_Ok</td>
<td>10</td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>id=rolePanel_grdChooseRole_rowclient_lstClient-btn</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=rolePanel_grdChooseRole_rowclient_lstClient-btn</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>css=#rolePanel_grdChooseRole_rowclient_lstClient_GardenWorld &gt; td.z-comboitem-text</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td>1000</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=rolePanel_grdChooseRole_rowRole_lstRole-btn</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>css=#rolePanel_grdChooseRole_rowRole_lstRole_GardenWorld_Admin &gt; td.z-comboitem-text</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td>1000</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=rolePanel_grdChooseRole_rowOrganisation_lstOrganisation-btn</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>css=#rolePanel_grdChooseRole_rowOrganisation_lstOrganisation_HQ &gt; td.z-comboitem-text</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=rolePanel_Ok</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>id=loginUserAndRole</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>id=loginUserAndRole</td>
<td>SuperUser@GardenWorld.HQ/GardenWorld Admin</td>
</tr>
</tbody></table>
</body>
</html>

View File

@ -0,0 +1,23 @@
<test tags="login" action="">
<case id="login">
<client>
<![CDATA[
type(jq("$loginPanel $txtUserId"), "SuperUser");
type(jq("$loginPanel $txtPassword"), "System");
click(widget(jq("$loginPanel $chkSelectRole")).$n("real"));
click(jq("$loginPanel $Ok"));
waitResponse();
click(jq("$rolePanel $lstClient ~ .z-combobox-btn"));
click(jq("$rolePanel $lstClient $GardenWorld"));
click(jq("$rolePanel $lstRole ~ .z-combobox-btn"));
click(jq("$rolePanel $lstRole $GardenWorld\\\\ Admin"));
waitResponse();
click(jq("$rolePanel $lstOrganisation ~ .z-combobox-btn"));
click(jq("$rolePanel $lstOrganisation $HQ"));
click(jq("$rolePanel $Ok"));
waitResponse();
verifyEquals("SuperUser@GardenWorld.HQ/GardenWorld Admin", jq("$loginUserAndRole").text());
]]>
</client>
</case>
</test>

View File

@ -0,0 +1,32 @@
package org.idempiere.ui.zk.selenium;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.SearchContext;
import org.openqa.selenium.WebElement;
/**
* utility class to find elements using zk jq selector
* @author hengsin
*
*/
public class Zk extends By {
private String selector;
private Zk(String selector) {
this.selector = selector;
}
@Override
public List<WebElement> findElements(SearchContext context) {
List<WebElement> list = (List<WebElement>) ((JavascriptExecutor)context).executeScript("return jq('" + selector + "').get();");
return list;
}
public static Zk jq(String selector) {
return new Zk(selector);
}
}

View File

@ -0,0 +1,94 @@
package zk.jq.test;
import java.util.concurrent.TimeUnit;
import org.idempiere.ui.zk.selenium.Zk;
import org.junit.*;
import static org.junit.Assert.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
/**
* Web Driver + zk jq selector, doesn't required AdempiereIdGenerator
* @author hengsin
*
*/
public class LoginTest {
private WebDriver driver;
private String baseUrl;
private StringBuffer verificationErrors = new StringBuffer();
@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = "http://127.0.0.1:8080/";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void testLogin() throws Exception {
// open | /webui/ |
driver.get(baseUrl + "/webui/");
// enter user name
driver.findElement(Zk.jq("$loginPanel $txtUserId")).clear();
driver.findElement(Zk.jq("$loginPanel $txtUserId")).sendKeys("SuperUser");
// enter password
driver.findElement(Zk.jq("$loginPanel $txtPassword")).clear();
driver.findElement(Zk.jq("$loginPanel $txtPassword")).sendKeys("System");
// check select role
driver.findElement(Zk.jq("$loginPanel $chkSelectRole ~ input")).click();
// click ok button
driver.findElement(Zk.jq("$loginPanel $Ok")).click();
// wait for role panel
for (int second = 0;; second++) {
if (second >= 60) fail("timeout");
try { if (isElementPresent(Zk.jq("$rolePanel $lstClient"))) break; } catch (Exception e) {}
Thread.sleep(1000);
}
// select GardenWorld client
driver.findElement(Zk.jq("$rolePanel $lstClient ~ .z-combobox-btn")).click();
driver.findElement(Zk.jq("$rolePanel $lstClient $GardenWorld")).click();
// select GardenWorld admin role
driver.findElement(Zk.jq("$rolePanel $lstRole ~ .z-combobox-btn")).click();
//note the 4 \\\\ needed to escape the space character. ugly but it works
driver.findElement(Zk.jq("$rolePanel $lstRole $GardenWorld\\\\ Admin")).click();
// select HQ organization
driver.findElement(Zk.jq("$rolePanel $lstOrganisation ~ .z-combobox-btn")).click();
driver.findElement(Zk.jq("$rolePanel $lstOrganisation $HQ")).click();
// click ok button
driver.findElement(Zk.jq("$rolePanel $Ok")).click();
// wait for home page
for (int second = 0;; second++) {
if (second >= 60) fail("timeout");
try { if (isElementPresent(Zk.jq("$loginUserAndRole"))) break; } catch (Exception e) {}
Thread.sleep(1000);
}
// assert login user and role
assertEquals("SuperUser@GardenWorld.HQ/GardenWorld Admin", driver.findElement(Zk.jq("$loginUserAndRole")).getText());
}
@After
public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}
private boolean isElementPresent(By by) {
try {
driver.findElement(by);
return true;
} catch (NoSuchElementException e) {
return false;
}
}
}

View File

@ -0,0 +1,94 @@
package zk.selenese.test;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
/**
* Generated from selenium ide, required AdempiereIdGenerator
* @author hengsin
*
*/
public class LoginTest {
private WebDriver driver;
private String baseUrl;
private StringBuffer verificationErrors = new StringBuffer();
@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = "http://127.0.0.1:8080/";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void testLogin() throws Exception {
// open | /webui/ |
driver.get(baseUrl + "/webui/");
// type | id=loginPanel_grdLogin_rowUser_txtUserId | SuperUser
driver.findElement(By.id("loginPanel_grdLogin_rowUser_txtUserId")).clear();
driver.findElement(By.id("loginPanel_grdLogin_rowUser_txtUserId")).sendKeys("SuperUser");
// fireEvent | id=loginPanel_grdLogin_rowUser_txtUserId | blur
// not needed for webdriver
// type | id=loginPanel_grdLogin_rowPassword_txtPassword | System
driver.findElement(By.id("loginPanel_grdLogin_rowPassword_txtPassword")).clear();
driver.findElement(By.id("loginPanel_grdLogin_rowPassword_txtPassword")).sendKeys("System");
// fireEvent | id=loginPanel_grdLogin_rowPassword_txtPassword | blur
// not needed for webdriver
// click | id=loginPanel_grdLogin_rowSelectRole_chkSelectRole-real |
driver.findElement(By.id("loginPanel_grdLogin_rowSelectRole_chkSelectRole-real")).click();
// click | loginPanel_Ok | 10
driver.findElement(By.id("loginPanel_Ok")).click();
// waitForElementPresent | id=rolePanel_grdChooseRole_rowclient_lstClient-btn |
for (int second = 0;; second++) {
if (second >= 60) fail("timeout");
try { if (isElementPresent(By.id("rolePanel_grdChooseRole_rowclient_lstClient-btn"))) break; } catch (Exception e) {}
Thread.sleep(1000);
}
// click | id=rolePanel_grdChooseRole_rowclient_lstClient-btn |
driver.findElement(By.id("rolePanel_grdChooseRole_rowclient_lstClient-btn")).click();
// click | css=#rolePanel_grdChooseRole_rowclient_lstClient_GardenWorld > td.z-comboitem-text |
driver.findElement(By.cssSelector("#rolePanel_grdChooseRole_rowclient_lstClient_GardenWorld > td.z-comboitem-text")).click();
Thread.sleep(1000);
// click | id=rolePanel_grdChooseRole_rowRole_lstRole-btn |
driver.findElement(By.id("rolePanel_grdChooseRole_rowRole_lstRole-btn")).click();
// click | css=#rolePanel_grdChooseRole_rowRole_lstRole_GardenWorld_Admin > td.z-comboitem-text |
driver.findElement(By.cssSelector("#rolePanel_grdChooseRole_rowRole_lstRole_GardenWorld_Admin > td.z-comboitem-text")).click();
Thread.sleep(1000);
// click | id=rolePanel_grdChooseRole_rowOrganisation_lstOrganisation-btn |
driver.findElement(By.id("rolePanel_grdChooseRole_rowOrganisation_lstOrganisation-btn")).click();
// click | css=#rolePanel_grdChooseRole_rowOrganisation_lstOrganisation_HQ > td.z-comboitem-text |
driver.findElement(By.cssSelector("#rolePanel_grdChooseRole_rowOrganisation_lstOrganisation_HQ > td.z-comboitem-text")).click();
// click | rolePanel_Ok |
driver.findElement(By.id("rolePanel_Ok")).click();
// waitForElementPresent | loginUserAndRole |
for (int second = 0;; second++) {
if (second >= 60) fail("timeout");
try { if (isElementPresent(By.id("loginUserAndRole"))) break; } catch (Exception e) {}
Thread.sleep(1000);
}
// assertText | loginUserAndRole | SuperUser@GardenWorld.HQ/GardenWorld Admin
assertEquals("SuperUser@GardenWorld.HQ/GardenWorld Admin", driver.findElement(By.id("loginUserAndRole")).getText());
}
@After
public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}
private boolean isElementPresent(By by) {
try {
driver.findElement(by);
return true;
} catch (NoSuchElementException e) {
return false;
}
}
}

View File

@ -0,0 +1,86 @@
/* LoginTest.java
Purpose:
Description:
History:
Dec, 6, 2012 17:09:52 PM
Copyright (C) 2012 Potix Corporation. All Rights Reserved.
This program is distributed under Apache License Version 2.0 in the hope that
it will be useful, but WITHOUT ANY WARRANTY.
*/
package zk.ztl.test;
import org.junit.Test;
import org.zkoss.ztl.Element;
import org.zkoss.ztl.JQuery;
import org.zkoss.ztl.Tags;
import org.zkoss.ztl.Widget;
import org.zkoss.ztl.ZK;
import org.zkoss.ztl.ZKClientTestCase;
import org.zkoss.ztl.util.*;
import org.openqa.selenium.*;
import com.thoughtworks.selenium.Selenium;
import com.thoughtworks.selenium.SeleniumException;
@Tags(tags = "login")
public class LoginTest extends ZKClientTestCase {
public LoginTest() {
target = "";
browsers = getBrowsers("firefox");
_timeout = 20000;
caseID = getClass().getSimpleName();
}
@Test(expected = AssertionError.class)
public void testlogin() {
for (Selenium browser : browsers) {
try {
start(browser);
windowFocus();
windowMaximize();
String zscript = "";
Widget engine = new Widget(new StringBuffer("zk.Desktop._dt"));
// remove all of unnecessary children
if (target.endsWith("/service.zul"))
removeChildren(engine.firstChild());
/** start **/
/** client code **/
type(jq("$loginPanel $txtUserId"), "SuperUser");
type(jq("$loginPanel $txtPassword"), "System");
click(widget(jq("$loginPanel $chkSelectRole")).$n("real"));
click(jq("$loginPanel $Ok"));
waitResponse();
click(jq("$rolePanel $lstClient ~ .z-combobox-btn"));
click(jq("$rolePanel $lstClient $GardenWorld"));
click(jq("$rolePanel $lstRole ~ .z-combobox-btn"));
click(jq("$rolePanel $lstRole $GardenWorld\\\\ Admin"));
waitResponse();
click(jq("$rolePanel $lstOrganisation ~ .z-combobox-btn"));
click(jq("$rolePanel $lstOrganisation $HQ"));
click(jq("$rolePanel $Ok"));
waitResponse();
verifyEquals("SuperUser@GardenWorld.HQ/GardenWorld Admin", jq("$loginUserAndRole").text());
/** end **/
} catch (SeleniumException e) {
ZKSelenium zbrowser = ((ZKSelenium) browser);
ConfigHelper.getInstance().clearCache(zbrowser);
zbrowser.shutdown();
throw e;
} finally {
stop();
}
}
}
}

View File

@ -23,38 +23,52 @@ import org.zkoss.zk.ui.Page;
import org.zkoss.zk.ui.metainfo.ComponentInfo;
import org.zkoss.zk.ui.sys.IdGenerator;
/**
* Id generator for selenium ide recording.
* You don't need this to run ztl or zk jq selector based test script but if would help to
* code or troubleshoot the test script.
*
* DON'T use this for other purpose, you have been warned :)
*
* @author Carlos Ruiz
* @author hengsin
*
*/
public class AdempiereIdGenerator implements IdGenerator {
private static final String DEFAULT_ZK_COMP_PREFIX = "zk_comp_";
private static final String DESKTOP_ID_ATTRIBUTE = "org.adempiere.comp.id";
/* use this to add a component prefix to identify zk component
* if the prefix starts with unq then it will be used as is - if it doesn't then a sequence suffix will be added to guarantee uniqueness
*/
public static final String ZK_COMPONENT_PREFIX_ATTRIBUTE = "zk_component_prefix";
@Override
public String nextComponentUuid(Desktop desktop, Component comp, ComponentInfo compInfo) {
String prefix = (String) comp.getAttribute(ZK_COMPONENT_PREFIX_ATTRIBUTE);
if (prefix == null || prefix.length() == 0)
String prefix = comp.getId();
if (prefix == null || prefix.length() == 0) {
prefix = DEFAULT_ZK_COMP_PREFIX;
else {
Pattern pattern = Pattern.compile("[^a-zA-Z_0-9]");
Matcher matcher = pattern.matcher(prefix);
StringBuffer sb = new StringBuffer();
while(matcher.find()) {
matcher.appendReplacement(sb, "_");
}
matcher.appendTail(sb);
prefix = sb.toString();
if (prefix.startsWith("unq")) { // prefix already guaranteed unique
if (desktop.getComponentByUuidIfAny(prefix) == null) { // but don't trust and look to avoid dups
return prefix;
} else {
prefix = "not" + prefix; // set notunq as the prefix to let dev know something is wrong
}
}
}
StringBuilder builder = new StringBuilder(prefix);
Component parent = comp.getParent();
while(parent != null) {
String id = parent.getId();
if (id != null && id.length() > 0)
builder.insert(0, id+"_");
parent = parent.getParent();
}
prefix = builder.toString();
Pattern pattern = Pattern.compile("[^a-zA-Z_0-9]");
Matcher matcher = pattern.matcher(prefix);
StringBuffer sb = new StringBuffer();
while(matcher.find()) {
matcher.appendReplacement(sb, "_");
}
matcher.appendTail(sb);
prefix = sb.toString();
if (desktop.getComponentByUuidIfAny(prefix) == null) { // look to avoid dups
return prefix;
}
/* add sequence suffix to guarantee uniqueness */
int i = 0;

View File

@ -69,6 +69,7 @@ import org.compiere.util.Util;
import org.zkoss.zk.au.out.AuFocus;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.IdSpace;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
@ -99,7 +100,7 @@ import org.zkoss.zul.impl.XulElement;
* @author Low Heng Sin
*/
public class ADTabpanel extends Div implements Evaluatee, EventListener<Event>,
DataStatusListener, IADTabpanel
DataStatusListener, IADTabpanel, IdSpace
{
public static final String ON_SWITCH_VIEW_EVENT = "onSwitchView";
@ -260,6 +261,8 @@ DataStatusListener, IADTabpanel
this.dataBinder = new GridTabDataBinder(gridTab);
this.getChildren().clear();
setId(gridTab.getName());
int AD_Tree_ID = 0;
if (gridTab.isTreeTab())

View File

@ -28,7 +28,6 @@ import java.util.Properties;
import java.util.logging.Level;
import org.adempiere.base.IServiceHolder;
import org.adempiere.webui.AdempiereIdGenerator;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.action.Actions;
import org.adempiere.webui.action.IAction;
@ -205,10 +204,7 @@ public class ADWindowToolbar extends FToolbar implements EventListener<Event>
{
ToolBarButton btn = new ToolBarButton("");
btn.setName(BTNPREFIX+name);
if (windowNo > 0)
btn.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + btn.getName() + "_" + windowNo);
else
btn.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, btn.getName());
btn.setId(btn.getName());
if (image != null)
btn.setImage("/images/"+image + "24.png");
btn.setTooltiptext(Msg.getMsg(Env.getCtx(),tooltip));
@ -623,6 +619,7 @@ public class ADWindowToolbar extends FToolbar implements EventListener<Event>
}
ToolBarButton btn = createButton(mToolBarButton.getComponentName(), null, tooltiptext);
btn.removeEventListener(Events.ON_CLICK, this);
btn.setId(mToolBarButton.getName());
btn.setDisabled(false);
AImage aImage = Actions.getActionImage(actionId);

View File

@ -19,7 +19,6 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.adempiere.webui.AdempiereIdGenerator;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.component.Label;
import org.adempiere.webui.component.Menupopup;
@ -141,6 +140,7 @@ public class BreadCrumb extends Div implements EventListener<Event> {
messageContainer = new Hbox();
messageContainer.setStyle("float: right; height: 30px;");
messageContainer.setAlign("center");
messageContainer.setId("messages");
appendChild(messageContainer);
altKeyMap.put(KeyEvent.UP, btnPrevious);
@ -161,6 +161,7 @@ public class BreadCrumb extends Div implements EventListener<Event> {
if (clickable) {
BreadCrumbLink a = new BreadCrumbLink();
a.setLabel(label);
a.setId("breadcrumb-"+label);
a.setPathId(id);
a.addEventListener(Events.ON_CLICK, this);
if (layout.getChildren().size() > 1) {
@ -171,6 +172,7 @@ public class BreadCrumb extends Div implements EventListener<Event> {
layout.insertBefore(a, toolbarContainer);
} else {
Label pathLabel = new Label();
pathLabel.setId("breadcrumb-"+label);
pathLabel.setValue(label);
if (layout.getChildren().size() > 1) {
Label symbol = new Label();
@ -272,10 +274,7 @@ public class BreadCrumb extends Div implements EventListener<Event> {
{
ToolBarButton btn = new ToolBarButton("");
btn.setName(BTNPREFIX+name);
if (windowNo > 0)
btn.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + btn.getName() + "_" + windowNo);
else
btn.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, btn.getName());
btn.setId(name);
btn.setImage("/images/"+image + "24.png");
btn.setTooltiptext(Msg.getMsg(Env.getCtx(),tooltip));
btn.setSclass("breadcrumb-toolbar-button");

View File

@ -110,6 +110,8 @@ public class DetailPane extends Panel implements EventListener<Event> {
}
addEventListener(LayoutUtils.ON_REDRAW_EVENT, this);
setId("detailPane");
}
public int getSelectedIndex() {
@ -190,6 +192,7 @@ public class DetailPane extends Panel implements EventListener<Event> {
button = new ToolBarButton();
button.setImage(NEW_IMAGE);
button.setId("BtnNew");
toolbar.appendChild(button);
button.addEventListener(Events.ON_CLICK, new EventListener<Event>() {
@Override
@ -202,6 +205,7 @@ public class DetailPane extends Panel implements EventListener<Event> {
button = new ToolBarButton();
button.setImage(EDIT_IMAGE);
button.setId("BtnEdit");
toolbar.appendChild(button);
button.addEventListener(Events.ON_CLICK, new EventListener<Event>() {
@Override
@ -213,6 +217,7 @@ public class DetailPane extends Panel implements EventListener<Event> {
button = new ToolBarButton();
button.setImage(DELETE_IMAGE);
button.setId("BtnDelete");
toolbar.appendChild(button);
button.addEventListener(Events.ON_CLICK, new EventListener<Event>() {
@Override
@ -226,6 +231,7 @@ public class DetailPane extends Panel implements EventListener<Event> {
if (!tabPanel.getGridTab().isSortTab()) {
button = new ToolBarButton();
button.setImage(PROCESS_IMAGE);
button.setId("BtnProcess");
toolbar.appendChild(button);
button.addEventListener(Events.ON_CLICK, new EventListener<Event>() {
@Override
@ -240,6 +246,7 @@ public class DetailPane extends Panel implements EventListener<Event> {
messageContainer.setPack("end");
messageContainer.setAlign("center");
messageContainer.setSclass("adwindow-detailpane-message");
messageContainer.setId("messages");
toolbar.appendChild(messageContainer);
toolbar.setSclass("adwindow-detailpane-toolbar");

View File

@ -17,7 +17,6 @@ package org.adempiere.webui.apps.form;
import java.util.logging.Level;
import org.adempiere.exceptions.AdempiereException;
import org.adempiere.webui.AdempiereIdGenerator;
import org.adempiere.webui.component.Column;
import org.adempiere.webui.component.ConfirmPanel;
import org.adempiere.webui.component.Grid;
@ -130,45 +129,38 @@ public class WResetPassword implements IFormController, EventListener<Event>, Va
txtOldPassword = new Textbox();
txtOldPassword.setId("txtOldPassword");
txtOldPassword.setType("password");
txtOldPassword.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + txtOldPassword.getId());
txtOldPassword.setCols(25);
txtOldPassword.setWidth("220px");
txtNewPassword = new Textbox();
txtNewPassword.setId("txtNewPassword");
txtNewPassword.setType("password");
txtNewPassword.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + txtNewPassword.getId());
txtNewPassword.setCols(25);
txtNewPassword.setWidth("220px");
txtRetypeNewPassword = new Textbox();
txtRetypeNewPassword.setId("txtRetypeNewPassword");
txtRetypeNewPassword.setType("password");
txtRetypeNewPassword.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + txtNewPassword.getId());
txtRetypeNewPassword.setCols(25);
txtRetypeNewPassword.setWidth("220px");
txtNewEMail = new Textbox();
txtNewEMail.setId("txtNewEMail");
txtNewEMail.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + txtNewEMail.getId());
txtNewEMail.setCols(25);
txtNewEMail.setWidth("220px");
txtRetypeNewEMail = new Textbox();
txtRetypeNewEMail.setId("txtRetypeNewEMail");
txtRetypeNewEMail.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + txtRetypeNewEMail.getId());
txtRetypeNewEMail.setCols(25);
txtRetypeNewEMail.setWidth("220px");
txtNewEMailUser = new Textbox();
txtNewEMailUser.setId("txtNewEMailUser");
txtNewEMailUser.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + txtNewEMailUser.getId());
txtNewEMailUser.setCols(25);
txtNewEMailUser.setWidth("220px");
txtNewEMailUserPW = new Textbox();
txtNewEMailUserPW.setId("txtNewEMailUserPW");
txtNewEMailUserPW.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + txtNewEMailUserPW.getId());
txtNewEMailUserPW.setCols(25);
txtNewEMailUserPW.setWidth("220px");

View File

@ -19,6 +19,7 @@ package org.adempiere.webui.component;
import java.util.List;
import org.zkoss.zk.ui.IdSpace;
import org.zkoss.zul.Comboitem;
/**
@ -27,7 +28,7 @@ import org.zkoss.zul.Comboitem;
* @date Feb 25, 2007
* @version $Revision: 0.10 $
*/
public class Combobox extends org.zkoss.zul.Combobox
public class Combobox extends org.zkoss.zul.Combobox implements IdSpace
{
/**
*
@ -42,6 +43,7 @@ public class Combobox extends org.zkoss.zul.Combobox
public Comboitem appendItem(String label)
{
ComboItem item = new ComboItem(label);
item.setId(label);
item.setParent(this);
return item;
}
@ -62,6 +64,7 @@ public class Combobox extends org.zkoss.zul.Combobox
public void appendItem(String name, Object value) {
ComboItem item = new ComboItem(name, value);
item.setId(name);
this.appendChild(item);
}

View File

@ -22,7 +22,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.adempiere.webui.AdempiereIdGenerator;
import org.adempiere.webui.LayoutUtils;
import org.compiere.util.Env;
import org.compiere.util.Msg;
@ -104,7 +103,6 @@ public final class ConfirmPanel extends Hbox
Button button = new Button();
button.setName("btn"+name);
button.setId(name);
button.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, button.getId());
String text = Msg.translate(Env.getCtx(), name);
if (!name.equals(text))

View File

@ -248,6 +248,7 @@ public class Messagebox extends Window implements EventListener<Event>
this.setSizable(true);
this.setVisible(true);
this.setId(title);
AEnv.showCenterScreen(this);
return returnValue;

View File

@ -18,6 +18,7 @@
package org.adempiere.webui.component;
import org.adempiere.webui.panel.ITabOnCloseHandler;
import org.zkoss.zk.ui.IdSpace;
import org.zkoss.zul.Tab;
/**
@ -26,7 +27,7 @@ import org.zkoss.zul.Tab;
* @date Feb 25, 2007
* @version $Revision: 0.10 $
*/
public class Tabpanel extends org.zkoss.zul.Tabpanel
public class Tabpanel extends org.zkoss.zul.Tabpanel implements IdSpace
{
/**
*

View File

@ -133,6 +133,7 @@ public abstract class TabbedDesktop extends AbstractDesktop {
final ADWindow adWindow = new ADWindow(Env.getCtx(), windowId, query);
final DesktopTabpanel tabPanel = new DesktopTabpanel();
tabPanel.setId(adWindow.getTitle()+"_"+adWindow.getADWindowContent().getWindowNo());
final Tab tab = windowContainer.addWindow(tabPanel, adWindow.getTitle(), true);
tab.setImage(IN_PROGRESS_IMAGE);
tab.setClosable(false);

View File

@ -22,7 +22,6 @@ import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import org.adempiere.webui.AdempiereIdGenerator;
import org.adempiere.webui.component.Bandbox;
import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.Datebox;
@ -109,13 +108,7 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
}
this.setComponent(comp);
String gridTabName = gridField.getGridTab() != null ? gridField.getGridTab().getTabNo() + "_" + gridField.getGridTab().getTableName() : "";
comp.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE,
"unqField_"
+ gridField.getWindowNo()
+ "_" + gridTabName
+ "_" + gridField.getColumnName()
+ (rowIndex >= 0 ? "_" + rowIndex : ""));
comp.setId(gridField.getColumnName()+(rowIndex >= 0 ? "_" + rowIndex : ""));
this.gridField = gridField;
this.setMandatory(gridField.isMandatory(false));
this.readOnly = gridField.isReadOnly();

View File

@ -545,6 +545,7 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
}
}
});
ip.setId(ip.getTitle()+"_"+ip.getWindowNo());
AEnv.showWindow(ip);
}

View File

@ -19,7 +19,6 @@ import java.util.Properties;
import org.adempiere.exceptions.AdempiereException;
import org.adempiere.util.Callback;
import org.adempiere.webui.AdempiereIdGenerator;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.Combobox;
@ -224,7 +223,6 @@ public class ChangePasswordPanel extends Window implements EventListener<Event>
lstSecurityQuestion.setAutocomplete(true);
lstSecurityQuestion.setAutodrop(true);
lstSecurityQuestion.setId("lstSecurityQuestion");
lstSecurityQuestion.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + lstSecurityQuestion.getId());
lstSecurityQuestion.setWidth("220px");
lstSecurityQuestion.getItems().clear();
@ -234,28 +232,24 @@ public class ChangePasswordPanel extends Window implements EventListener<Event>
txtOldPassword = new Textbox();
txtOldPassword.setId("txtOldPassword");
txtOldPassword.setType("password");
txtOldPassword.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + txtOldPassword.getId());
txtOldPassword.setCols(25);
txtOldPassword.setWidth("220px");
txtNewPassword = new Textbox();
txtNewPassword.setId("txtNewPassword");
txtNewPassword.setType("password");
txtNewPassword.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + txtNewPassword.getId());
txtNewPassword.setCols(25);
txtNewPassword.setWidth("220px");
txtRetypeNewPassword = new Textbox();
txtRetypeNewPassword.setId("txtRetypeNewPassword");
txtRetypeNewPassword.setType("password");
txtRetypeNewPassword.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + txtNewPassword.getId());
txtRetypeNewPassword.setCols(25);
txtRetypeNewPassword.setWidth("220px");
txtAnswer = new Textbox();
txtAnswer.setId("txtAnswer");
// txtAnswer.setType("password");
txtAnswer.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + txtAnswer.getId());
txtAnswer.setCols(25);
txtAnswer.setWidth("220px");
}

View File

@ -1305,4 +1305,7 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
return "natural";
}
public int getWindowNo() {
return p_WindowNo;
}
} // Info

View File

@ -31,7 +31,6 @@ import java.util.Locale;
import java.util.Properties;
import java.util.logging.Level;
import org.adempiere.webui.AdempiereIdGenerator;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.Button;
@ -317,7 +316,6 @@ public class LoginPanel extends Window implements EventListener<Event>
txtUserId = new Textbox();
txtUserId.setId("txtUserId");
txtUserId.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + txtUserId.getId());
txtUserId.setCols(25);
txtUserId.setMaxlength(40);
txtUserId.setWidth("220px");
@ -326,7 +324,6 @@ public class LoginPanel extends Window implements EventListener<Event>
txtPassword = new Textbox();
txtPassword.setId("txtPassword");
txtPassword.setType("password");
txtPassword.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + txtPassword.getId());
txtPassword.setCols(25);
// txtPassword.setMaxlength(40);
@ -336,7 +333,6 @@ public class LoginPanel extends Window implements EventListener<Event>
lstLanguage.setAutocomplete(true);
lstLanguage.setAutodrop(true);
lstLanguage.setId("lstLanguage");
lstLanguage.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + lstLanguage.getId());
lstLanguage.addEventListener(Events.ON_SELECT, this);
lstLanguage.setWidth("220px");
@ -354,10 +350,13 @@ public class LoginPanel extends Window implements EventListener<Event>
}
chkRememberMe = new Checkbox(Msg.getMsg(Language.getBaseAD_Language(), "RememberMe"));
chkRememberMe.setId("chkRememberMe");
chkSelectRole = new Checkbox(Msg.getMsg(Language.getBaseAD_Language(), "SelectRole"));
chkSelectRole.setId("chkSelectRole");
btnResetPassword = new ToolBarButton(Msg.getMsg(Language.getBaseAD_Language(), "ForgotMyPassword"));
btnResetPassword.setId("btnResetPassword");
// Make the default language the language of client System
String defaultLanguage = MClient.get(ctx, 0).getAD_Language();

View File

@ -22,7 +22,6 @@ import java.util.Properties;
import org.adempiere.exceptions.AdempiereException;
import org.adempiere.util.Callback;
import org.adempiere.webui.AdempiereIdGenerator;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.ConfirmPanel;
@ -217,7 +216,6 @@ public class ResetPasswordPanel extends Window implements EventListener<Event>
txtEmail = new Textbox();
txtEmail.setId("txtEmail");
txtEmail.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + txtEmail.getId());
txtEmail.setCols(25);
txtEmail.setWidth("220px");
txtEmail.setReadonly(false);
@ -228,7 +226,6 @@ public class ResetPasswordPanel extends Window implements EventListener<Event>
txtUserId = new Textbox();
txtUserId.setId("txtUserId");
txtUserId.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + txtUserId.getId());
txtUserId.setCols(25);
txtUserId.setMaxlength(40);
txtUserId.setWidth("220px");
@ -247,7 +244,6 @@ public class ResetPasswordPanel extends Window implements EventListener<Event>
txtSecurityQuestion = new Textbox();
txtSecurityQuestion.setId("txtSecurityQuestion");
txtSecurityQuestion.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + txtSecurityQuestion.getId());
txtSecurityQuestion.setCols(25);
txtSecurityQuestion.setWidth("220px");
txtSecurityQuestion.setReadonly(true);
@ -256,7 +252,6 @@ public class ResetPasswordPanel extends Window implements EventListener<Event>
txtAnswer = new Textbox();
txtAnswer.setId("txtAnswer");
// txtAnswer.setType("password");
txtAnswer.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + txtAnswer.getId());
txtAnswer.setCols(25);
txtAnswer.setWidth("220px");
txtAnswer.setReadonly(true);

View File

@ -26,7 +26,6 @@ package org.adempiere.webui.panel;
import java.sql.Timestamp;
import java.util.Properties;
import org.adempiere.webui.AdempiereIdGenerator;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.component.ComboItem;
import org.adempiere.webui.component.Combobox;
@ -261,7 +260,6 @@ public class RolePanel extends Window implements EventListener<Event>, Deferrabl
lstRole.setAutocomplete(true);
lstRole.setAutodrop(true);
lstRole.setId("lstRole");
lstRole.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + lstRole.getId());
lstRole.addEventListener(Events.ON_SELECT, this);
lstRole.setWidth("220px");
@ -270,7 +268,6 @@ public class RolePanel extends Window implements EventListener<Event>, Deferrabl
lstClient.setAutocomplete(true);
lstClient.setAutodrop(true);
lstClient.setId("lstClient");
lstClient.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + lstClient.getId());
lstClient.addEventListener(Events.ON_SELECT, this);
lstClient.setWidth("220px");
@ -279,7 +276,6 @@ public class RolePanel extends Window implements EventListener<Event>, Deferrabl
lstOrganisation.setAutocomplete(true);
lstOrganisation.setAutodrop(true);
lstOrganisation.setId("lstOrganisation");
lstOrganisation.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + lstOrganisation.getId());
lstOrganisation.addEventListener(Events.ON_SELECT, this);
lstOrganisation.setWidth("220px");
@ -288,13 +284,13 @@ public class RolePanel extends Window implements EventListener<Event>, Deferrabl
lstWarehouse.setAutocomplete(true);
lstWarehouse.setAutodrop(true);
lstWarehouse.setId("lstWarehouse");
lstWarehouse.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unq" + lstWarehouse.getId());
lstWarehouse.addEventListener(Events.ON_SELECT, this);
lstWarehouse.setWidth("220px");
lstDate = new WDateEditor();
lstDate.setValue(new Timestamp(System.currentTimeMillis()));
lstDate.setValue(new Timestamp(System.currentTimeMillis()));
lstDate.getComponent().setId("loginDate");
btnOk = new Button();
btnOk.setId("btnOk");
@ -318,6 +314,7 @@ public class RolePanel extends Window implements EventListener<Event>, Deferrabl
for(int i = 0; i < m_clientKNPairs.length; i++)
{
ComboItem ci = new ComboItem(m_clientKNPairs[i].getName(), m_clientKNPairs[i].getID());
ci.setId(ci.getLabel());
lstClient.appendChild(ci);
if (m_clientKNPairs[i].getID().equals(initDefault))
lstClient.setSelectedItem(ci);
@ -363,6 +360,7 @@ public class RolePanel extends Window implements EventListener<Event>, Deferrabl
for (int i = 0; i < roleKNPairs.length; i++)
{
ComboItem ci = new ComboItem(roleKNPairs[i].getName(), roleKNPairs[i].getID());
ci.setId(ci.getLabel());
lstRole.appendChild(ci);
if (roleKNPairs[i].getID().equals(initDefault))
lstRole.setSelectedItem(ci);
@ -415,6 +413,7 @@ public class RolePanel extends Window implements EventListener<Event>, Deferrabl
for(int i = 0; i < orgKNPairs.length; i++)
{
ComboItem ci = new ComboItem(orgKNPairs[i].getName(), orgKNPairs[i].getID());
ci.setId(ci.getLabel());
lstOrganisation.appendChild(ci);
if(orgKNPairs[i].getID().equals(initDefault))
lstOrganisation.setSelectedItem(ci);
@ -451,6 +450,7 @@ public class RolePanel extends Window implements EventListener<Event>, Deferrabl
for(int i = 0; i < warehouseKNPairs.length; i++)
{
ComboItem ci = new ComboItem(warehouseKNPairs[i].getName(), warehouseKNPairs[i].getID());
ci.setLabel(ci.getLabel());
lstWarehouse.appendChild(ci);
if(warehouseKNPairs[i].getID().equals(initDefault))
lstWarehouse.setSelectedItem(ci);

View File

@ -20,7 +20,6 @@ package org.adempiere.webui.panel;
import java.util.List;
import java.util.TreeMap;
import org.adempiere.webui.AdempiereIdGenerator;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.AutoComplete;
import org.adempiere.webui.component.Label;
@ -33,6 +32,7 @@ import org.compiere.model.MTreeNode;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.IdSpace;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
@ -54,7 +54,7 @@ import org.zkoss.zul.impl.LabelImageElement;
* @date Mar 3, 2007
* @version $Revision: 0.10 $
*/
public class TreeSearchPanel extends Panel implements EventListener<Event>, TreeDataListener
public class TreeSearchPanel extends Panel implements EventListener<Event>, TreeDataListener, IdSpace
{
/**
*
@ -121,7 +121,7 @@ public class TreeSearchPanel extends Panel implements EventListener<Event>, Tree
cmbSearch = new AutoComplete();
cmbSearch.setAutodrop(true);
cmbSearch.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unqCmbSearch" + "_" + m_windowno + "_" + m_tabno);
cmbSearch.setId("treeSearchCombo");
cmbSearch.addEventListener(Events.ON_CHANGE, this);
cmbSearch.addEventListener(Events.ON_OK, this);

View File

@ -76,7 +76,9 @@ public class UserPanel extends Vbox implements EventListener<Event>
this.appendChild(vbox);
lblUserNameValue.setValue(getUserName() + "@" + getClientName() + "." + getOrgName()+"/"+this.getRoleName());
lblUserNameValue.setStyle("cursor: pointer;");
lblUserNameValue.addEventListener(Events.ON_CLICK, this);
lblUserNameValue.setId("loginUserAndRole");
LayoutUtils.addSclass("desktop-header-font", lblUserNameValue);
LayoutUtils.addSclass("desktop-header-username", lblUserNameValue);
vbox.appendChild(lblUserNameValue);
@ -85,11 +87,12 @@ public class UserPanel extends Vbox implements EventListener<Event>
vbox.appendChild(hbox);
hbox.setAlign("center");
preference.setLabel(Msg.getMsg(Env.getCtx(), "Preference"));
preference.setLabel(Msg.getMsg(Env.getCtx(), "Preference"));
preference.setId("preference");
preference.addEventListener(Events.ON_CLICK, this);
LayoutUtils.addSclass("desktop-header-font", preference);
LayoutUtils.addSclass("link", preference);
preference.setParent(hbox);
preference.setParent(hbox);
Separator sep = new Separator("vertical");
sep.setBar(true);
@ -97,6 +100,7 @@ public class UserPanel extends Vbox implements EventListener<Event>
sep.setParent(hbox);
changeRole.setLabel(Msg.getMsg(Env.getCtx(), "changeRole"));
changeRole.setId("changeRole");
changeRole.addEventListener(Events.ON_CLICK, this);
LayoutUtils.addSclass("desktop-header-font", changeRole);
LayoutUtils.addSclass("link", changeRole);
@ -108,6 +112,7 @@ public class UserPanel extends Vbox implements EventListener<Event>
sep.setParent(hbox);
logout.setLabel(Msg.getMsg(Env.getCtx(),"Logout"));
logout.setId("logout");
logout.addEventListener(Events.ON_CLICK, this);
LayoutUtils.addSclass("desktop-header-font", logout);
LayoutUtils.addSclass("link", logout);

View File

@ -36,7 +36,6 @@ import java.util.Vector;
import java.util.logging.Level;
import java.util.regex.Pattern;
import org.adempiere.webui.AdempiereIdGenerator;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.Column;
@ -238,6 +237,8 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
this.setClosable(false);
this.setSizable(true);
this.setMaximizable(true);
this.setId("findWindow");
}
public boolean initialize()
@ -300,18 +301,21 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
{
Button btnNew = new Button();
btnNew.setName("btnNew");
btnNew.setId("btnNew");
btnNew.setImage("/images/New24.png");
btnNew.addEventListener(Events.ON_CLICK,this);
LayoutUtils.addSclass("action-button", btnNew);
Button btnOk = new Button();
btnOk.setName("btnOkSimple");
btnOk.setId("btnOk");
btnOk.setImage("/images/Ok24.png");
btnOk.addEventListener(Events.ON_CLICK,this);
LayoutUtils.addSclass("action-button", btnOk);
Button btnCancel = new Button();
btnCancel.setName("btnCancel");
btnCancel.setId("btnCancel");
btnCancel.setImage("/images/Cancel24.png");
btnCancel.addEventListener(Events.ON_CLICK,this);
LayoutUtils.addSclass("action-button", btnCancel);
@ -503,11 +507,13 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
btnSave.setImage("/images/Save24.png");
btnSave.addEventListener(Events.ON_CLICK, this);
btnSave.setDisabled(true);
btnSave.setId("btnSave");
// LayoutUtils.addSclass("disableFilter", btnSave);
fQueryName = new Combobox();
fQueryName.setTooltiptext(Msg.getMsg(Env.getCtx(),"QueryName"));
fQueryName.setReadonly(true);
fQueryName.setId("savedQueryCombo");
//user query
userQueries = MUserQuery.get(Env.getCtx(), m_AD_Tab_ID);
@ -544,10 +550,12 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
Tabpanel tabPanel = new Tabpanel();
tabPanel.setStyle("height: 100%; width: 100%");
tabPanel.appendChild(winLookupRecord);
tabPanel.setId("simpleSearch");
winMain.addTab(tabPanel, Msg.getMsg(Env.getCtx(), "Find").replaceAll("&", ""),false, true);
tabPanel = new Tabpanel();
tabPanel.setStyle("height: 100%; width: 100%");
tabPanel.appendChild(winAdvanced);
tabPanel.setId("advancedSearch");
winMain.addTab(tabPanel, Msg.getMsg(Env.getCtx(), "Advanced").replaceAll("&", ""), false, false);
initSimple();
initAdvanced();
@ -564,6 +572,7 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
historyCombo.setAutocomplete(false);
historyCombo.setButtonVisible(true);
historyCombo.setReadonly(true);
historyCombo.setId("historyCombo");
historyCombo.appendItem(" ", "");
historyCombo.appendItem((Msg.getMsg(Env.getCtx(), HISTORY_DAY_ALL)),HISTORY_DAY_ALL);
historyCombo.appendItem((Msg.getMsg(Env.getCtx(), HISTORY_DAY_YEAR)), HISTORY_DAY_YEAR);
@ -687,11 +696,9 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
return;
ListItem listItem = new ListItem();
listItem.setId("Row"+advancedPanel.getItemCount());
listItem.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, listItem.getId());
Listbox listColumn = new Listbox();
listColumn.setId("listColumn"+listItem.getId());
listColumn.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, listColumn.getId());
listColumn.setName("listColumn");
listColumn.setMold("select");
listColumn.setRows(0);
@ -699,7 +706,6 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
Listbox listOperator = new Listbox();
listOperator.setId("listOperator"+listItem.getId());
listOperator.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, listOperator.getId());
listOperator.setName("listOperator");
listOperator.setMold("select");
listOperator.setRows(0);
@ -707,7 +713,6 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
Listbox listAndOr = new Listbox();
listAndOr.setId("listAndOr"+listItem.getId());
listAndOr.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, listAndOr.getId());
listAndOr.setName("listAndOr");
listAndOr.setMold("select");
listAndOr.setRows(0);
@ -715,7 +720,6 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
Listbox listLeftBracket = new Listbox();
listLeftBracket.setId("listLeftBracket"+listItem.getId());
listLeftBracket.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, listLeftBracket.getId());
listLeftBracket.setName("listLeftBracket");
listLeftBracket.setMold("select");
listLeftBracket.setRows(0);
@ -723,7 +727,6 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
Listbox listRightBracket = new Listbox();
listRightBracket.setId("listRightBracket"+listItem.getId());
listRightBracket.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, listRightBracket.getId());
listRightBracket.setName("listRightBracket");
listRightBracket.setMold("select");
listRightBracket.setRows(0);
@ -775,35 +778,28 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
ListCell cellColumn = new ListCell();
cellColumn.appendChild(listColumn);
cellColumn.setId("cellColumn"+listItem.getId());
cellColumn.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, cellColumn.getId());
ListCell cellOperator = new ListCell();
cellOperator.appendChild(listOperator);
cellOperator.setId("cellOperator"+listItem.getId());
cellOperator.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, cellOperator.getId());
ListCell cellQueryFrom = new ListCell();
cellQueryFrom.setId("cellQueryFrom"+listItem.getId());
cellQueryFrom.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, cellQueryFrom.getId());
ListCell cellQueryTo = new ListCell();
cellQueryTo.setId("cellQueryTo"+listItem.getId());
cellQueryTo.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, cellQueryTo.getId());
ListCell cellAndOr = new ListCell();
cellAndOr.appendChild(listAndOr);
cellAndOr.setId("cellAndOr"+listItem.getId());
cellAndOr.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, cellAndOr.getId());
ListCell cellLeftBracket = new ListCell();
cellLeftBracket.appendChild(listLeftBracket);
cellLeftBracket.setId("cellLeftBracket"+listItem.getId());
cellLeftBracket.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, cellLeftBracket.getId());
ListCell cellRightBracket = new ListCell();
cellRightBracket.appendChild(listRightBracket);
cellRightBracket.setId("cellRightBracket"+listItem.getId());
cellRightBracket.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, cellRightBracket.getId());
listItem.appendChild(cellAndOr);
listItem.appendChild(cellLeftBracket);
@ -874,15 +870,6 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
}
} // createFields
/**
* sets the list of values of column and operator listboxes
* @param listColumn column
* @param listOperator operator
**/
private void setValues(Listbox listColumn, Listbox listOperator)
{
setValues(listColumn, listOperator, null);
}
private void setValues(Listbox listColumn, Listbox listOperator, String[] fields)
{
@ -1019,10 +1006,8 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
}
Component componentFrom = getEditorCompQueryFrom(row);
componentFrom.setId("searchFieldFrom"+row.getId());
componentFrom.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, componentFrom.getId());
Component componentTo = getEditorCompQueryTo(row);
componentTo.setId("searchFieldTo"+row.getId());
componentTo.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, componentTo.getId());
Listbox listOp = (Listbox) row.getFellow("listOperator"+row.getId());
String betweenValue = listOp.getSelectedItem().getValue().toString();

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
zk.xml Copyright (C) 2006 Potix Corporation. All Rights Reserved.
-->
<zk>
<!-- id generator for selenium testing -->
<system-config>
<id-generator-class>org.adempiere.webui.AdempiereIdGenerator</id-generator-class>
</system-config>
<!-- turn off uuid reuse for selenium testing -->
<library-property>
<name>org.zkoss.zk.ui.uuidRecycle.disabled</name>
<value>true</value>
</library-property>
</zk>