IDEMPIERE-92 Implement Selenium testing framework. Added context click support. Improvement to AdempiereIdGenerator for better determination of _zk_locator. Modify LogEventInterceptor to help the writing of fitnesse selenium script.
This commit is contained in:
parent
318f9d8745
commit
02e8b95c9c
|
@ -68,8 +68,16 @@ public class AdempiereIdGenerator implements IdGenerator {
|
||||||
|
|
||||||
if (id == null || id.length() == 0) {
|
if (id == null || id.length() == 0) {
|
||||||
locatorBuilder.append("@").append(getWidgetName(comp.getWidgetClass()));
|
locatorBuilder.append("@").append(getWidgetName(comp.getWidgetClass()));
|
||||||
|
Component parent = comp.getParent();
|
||||||
|
while(parent != null) {
|
||||||
|
String parentLocator = parent.getWidgetAttribute(ZK_LOCATOR_ATTRIBUTE);
|
||||||
|
if (parentLocator != null && parentLocator.trim().length() > 0) {
|
||||||
|
locatorBuilder.insert(0, parentLocator+ " ");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
parent = parent.getParent();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
Component parent = comp.getParent();
|
Component parent = comp.getParent();
|
||||||
while(parent != null) {
|
while(parent != null) {
|
||||||
//only include id space owner to ease converting test case to use zk id selector instead of uuid
|
//only include id space owner to ease converting test case to use zk id selector instead of uuid
|
||||||
|
@ -95,6 +103,7 @@ public class AdempiereIdGenerator implements IdGenerator {
|
||||||
}
|
}
|
||||||
parent = parent.getParent();
|
parent = parent.getParent();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
comp.setWidgetAttribute(ZK_LOCATOR_ATTRIBUTE, locatorBuilder.toString());
|
comp.setWidgetAttribute(ZK_LOCATOR_ATTRIBUTE, locatorBuilder.toString());
|
||||||
|
|
||||||
|
@ -154,8 +163,16 @@ public class AdempiereIdGenerator implements IdGenerator {
|
||||||
|
|
||||||
if (id == null || id.length() == 0) {
|
if (id == null || id.length() == 0) {
|
||||||
locatorBuilder.append("@").append(getWidgetName(comp.getWidgetClass()));
|
locatorBuilder.append("@").append(getWidgetName(comp.getWidgetClass()));
|
||||||
|
Component parent = comp.getParent();
|
||||||
|
while(parent != null) {
|
||||||
|
String parentLocator = parent.getWidgetAttribute(ZK_LOCATOR_ATTRIBUTE);
|
||||||
|
if (parentLocator != null && parentLocator.trim().length() > 0) {
|
||||||
|
locatorBuilder.insert(0, parentLocator+ " ");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
parent = parent.getParent();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
Component parent = comp.getParent();
|
Component parent = comp.getParent();
|
||||||
while(parent != null) {
|
while(parent != null) {
|
||||||
//only include id space owner to ease converting test case to use zk id selector instead of uuid
|
//only include id space owner to ease converting test case to use zk id selector instead of uuid
|
||||||
|
@ -180,6 +197,7 @@ public class AdempiereIdGenerator implements IdGenerator {
|
||||||
}
|
}
|
||||||
parent = parent.getParent();
|
parent = parent.getParent();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
comp.setWidgetAttribute(ZK_LOCATOR_ATTRIBUTE, locatorBuilder.toString());
|
comp.setWidgetAttribute(ZK_LOCATOR_ATTRIBUTE, locatorBuilder.toString());
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ public class UiLifeCycleListener implements UiLifeCycle {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void afterComponentAttached(Component comp, Page page) {
|
public void afterComponentAttached(Component comp, Page page) {
|
||||||
|
AdempiereIdGenerator.updateZkLocatorAttribute(comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -49,11 +50,8 @@ public class UiLifeCycleListener implements UiLifeCycle {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void afterComponentMoved(Component parent, Component child, Component prevparent) {
|
public void afterComponentMoved(Component parent, Component child, Component prevparent) {
|
||||||
String locator = child.getWidgetAttribute(AdempiereIdGenerator.ZK_LOCATOR_ATTRIBUTE);
|
|
||||||
if (locator != null) {
|
|
||||||
AdempiereIdGenerator.updateZkLocatorAttribute(child);
|
AdempiereIdGenerator.updateZkLocatorAttribute(child);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.zkoss.zk.ui.util.UiLifeCycle#afterPageAttached(org.zkoss.zk.ui.Page, org.zkoss.zk.ui.Desktop)
|
* @see org.zkoss.zk.ui.util.UiLifeCycle#afterPageAttached(org.zkoss.zk.ui.Page, org.zkoss.zk.ui.Desktop)
|
||||||
|
|
|
@ -571,6 +571,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
|
||||||
if (popupMenu != null)
|
if (popupMenu != null)
|
||||||
{
|
{
|
||||||
popupMenu.addMenuListener((ContextMenuListener)editor);
|
popupMenu.addMenuListener((ContextMenuListener)editor);
|
||||||
|
popupMenu.setId(field.getColumnName()+"-popup");
|
||||||
this.appendChild(popupMenu);
|
this.appendChild(popupMenu);
|
||||||
if (!field.isFieldOnly())
|
if (!field.isFieldOnly())
|
||||||
{
|
{
|
||||||
|
@ -586,8 +587,6 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
|
||||||
popupMenu.addContextElement((XulElement) editor.getComponent());
|
popupMenu.addContextElement((XulElement) editor.getComponent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
popupMenu.setId(field.getColumnName()+"-popup");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,8 @@ public class LogEventInterceptor implements EventInterceptor {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Event beforeProcessEvent(Event event) {
|
public Event beforeProcessEvent(Event event) {
|
||||||
System.out.println("beforeProcessEvent, event="+event.getName()+",target="+event.getTarget());
|
String locator = event.getTarget() != null ? event.getTarget().getWidgetAttribute("_zk_locator") : "";
|
||||||
|
System.out.println("beforeProcessEvent, event="+event.getName()+",target="+event.getTarget()+",locator="+locator);
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.idempiere.ui.zk.selenium.Widget;
|
||||||
import org.idempiere.ui.zk.selenium.Zk;
|
import org.idempiere.ui.zk.selenium.Zk;
|
||||||
import org.openqa.selenium.By;
|
import org.openqa.selenium.By;
|
||||||
import org.openqa.selenium.WebElement;
|
import org.openqa.selenium.WebElement;
|
||||||
|
import org.openqa.selenium.interactions.Actions;
|
||||||
|
|
||||||
import fitlibrary.annotation.SimpleAction;
|
import fitlibrary.annotation.SimpleAction;
|
||||||
import fitlibrary.spider.AbstractSpiderFixture;
|
import fitlibrary.spider.AbstractSpiderFixture;
|
||||||
|
@ -219,6 +220,14 @@ public class ZkFixture extends SpiderFixture {
|
||||||
return widget.eval(webDriver, command);
|
return widget.eval(webDriver, command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SimpleAction(wiki = "|''<i>context click</i>''|zk locator|", tooltip = "Open context menu")
|
||||||
|
public void contextClick(String locator) {
|
||||||
|
Widget widget = new Widget(locator);
|
||||||
|
WebElement element = widget.findElement(webDriver);
|
||||||
|
Actions actions = new Actions(webDriver);
|
||||||
|
actions.contextClick(element).build().perform();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Causes the currently executing thread to sleep for the specified number
|
* Causes the currently executing thread to sleep for the specified number
|
||||||
* of milliseconds, subject to the precision and accuracy of system timers
|
* of milliseconds, subject to the precision and accuracy of system timers
|
||||||
|
|
Loading…
Reference in New Issue