IDEMPIERE-92 Implement Selenium testing framework. Added _zk_locator dom attribute to further ease the use of zk selector for the writing of selenium script. Fixed issue with id after a component have change parent.

This commit is contained in:
Heng Sin Low 2013-01-11 18:11:28 +08:00
parent 095c72be64
commit 093bf34f9c
4 changed files with 83 additions and 1 deletions

View File

@ -0,0 +1,72 @@
/******************************************************************************
* Copyright (C) 2013 Heng Sin Low *
* Copyright (C) 2013 Trek Global *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.adempiere.webui;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Desktop;
import org.zkoss.zk.ui.Page;
import org.zkoss.zk.ui.util.UiLifeCycle;
/**
* @author hengsin
*
*/
public class UiLifeCycleListener implements UiLifeCycle {
/**
*
*/
public UiLifeCycleListener() {
}
/* (non-Javadoc)
* @see org.zkoss.zk.ui.util.UiLifeCycle#afterComponentAttached(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Page)
*/
@Override
public void afterComponentAttached(Component comp, Page page) {
}
/* (non-Javadoc)
* @see org.zkoss.zk.ui.util.UiLifeCycle#afterComponentDetached(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Page)
*/
@Override
public void afterComponentDetached(Component comp, Page prevpage) {
}
/* (non-Javadoc)
* @see org.zkoss.zk.ui.util.UiLifeCycle#afterComponentMoved(org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component, org.zkoss.zk.ui.Component)
*/
@Override
public void afterComponentMoved(Component parent, Component child, Component prevparent) {
String locator = child.getWidgetAttribute(AdempiereIdGenerator.ZK_LOCATOR_ATTRIBUTE);
if (locator != null) {
AdempiereIdGenerator.updateZkLocatorAttribute(child);
}
}
/* (non-Javadoc)
* @see org.zkoss.zk.ui.util.UiLifeCycle#afterPageAttached(org.zkoss.zk.ui.Page, org.zkoss.zk.ui.Desktop)
*/
@Override
public void afterPageAttached(Page page, Desktop desktop) {
}
/* (non-Javadoc)
* @see org.zkoss.zk.ui.util.UiLifeCycle#afterPageDetached(org.zkoss.zk.ui.Page, org.zkoss.zk.ui.Desktop)
*/
@Override
public void afterPageDetached(Page page, Desktop prevdesktop) {
}
}

View File

@ -26,6 +26,7 @@ import java.util.Map.Entry;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.base.Core; import org.adempiere.base.Core;
import org.adempiere.webui.AdempiereIdGenerator;
import org.adempiere.webui.AdempiereWebUI; import org.adempiere.webui.AdempiereWebUI;
import org.adempiere.webui.LayoutUtils; import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.component.Borderlayout; import org.adempiere.webui.component.Borderlayout;
@ -247,7 +248,7 @@ DataStatusListener, IADTabpanel, IdSpace
this.getChildren().clear(); this.getChildren().clear();
setId(gridTab.getName()); setId(AdempiereIdGenerator.escapeId(gridTab.getName()));
int AD_Tree_ID = 0; int AD_Tree_ID = 0;
if (gridTab.isTreeTab()) if (gridTab.isTreeTab())

View File

@ -10,6 +10,10 @@
<id-generator-class>org.adempiere.webui.AdempiereIdGenerator</id-generator-class> <id-generator-class>org.adempiere.webui.AdempiereIdGenerator</id-generator-class>
</system-config> </system-config>
<listener>
<listener-class>org.adempiere.webui.UiLifeCycleListener</listener-class>
</listener>
<!-- turn off uuid reuse for selenium testing --> <!-- turn off uuid reuse for selenium testing -->
<library-property> <library-property>
<name>org.zkoss.zk.ui.uuidRecycle.disabled</name> <name>org.zkoss.zk.ui.uuidRecycle.disabled</name>

View File

@ -191,6 +191,11 @@ public class ZkFixture extends SpiderFixture {
} }
} }
public void focus(String locator) {
Widget widget = new Widget(locator);
widget.execute(webDriver, "focus()");
}
protected String getEval(String script) { protected String getEval(String script) {
return String.valueOf(executeJavaScript("return ("+ script+");")); return String.valueOf(executeJavaScript("return ("+ script+");"));
} }