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,32 +68,41 @@ 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) {
|
||||||
Component parent = comp.getParent();
|
String parentLocator = parent.getWidgetAttribute(ZK_LOCATOR_ATTRIBUTE);
|
||||||
while(parent != null) {
|
if (parentLocator != null && parentLocator.trim().length() > 0) {
|
||||||
//only include id space owner to ease converting test case to use zk id selector instead of uuid
|
locatorBuilder.insert(0, parentLocator+ " ");
|
||||||
if (parent instanceof IdSpace) {
|
break;
|
||||||
id = parent.getId();
|
}
|
||||||
if (id != null && id.length() > 0) {
|
parent = parent.getParent();
|
||||||
if (id.indexOf(" ") > 0) {
|
}
|
||||||
String widgetName = getWidgetName(parent.getWidgetClass());
|
} else {
|
||||||
locatorBuilder.insert(0, "@"+widgetName+"[id=\'"+id+"\'] ");
|
Component parent = comp.getParent();
|
||||||
|
while(parent != null) {
|
||||||
|
//only include id space owner to ease converting test case to use zk id selector instead of uuid
|
||||||
|
if (parent instanceof IdSpace) {
|
||||||
|
id = parent.getId();
|
||||||
|
if (id != null && id.length() > 0) {
|
||||||
|
if (id.indexOf(" ") > 0) {
|
||||||
|
String widgetName = getWidgetName(parent.getWidgetClass());
|
||||||
|
locatorBuilder.insert(0, "@"+widgetName+"[id=\'"+id+"\'] ");
|
||||||
|
} else {
|
||||||
|
locatorBuilder.insert(0, "$"+id+" ");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
locatorBuilder.insert(0, "$"+id+" ");
|
String attribute = parent.getWidgetAttribute(AdempiereWebUI.WIDGET_INSTANCE_NAME);
|
||||||
}
|
if (attribute != null && attribute.length() > 0) {
|
||||||
} else {
|
String widgetName = getWidgetName(parent.getWidgetClass());
|
||||||
String attribute = parent.getWidgetAttribute(AdempiereWebUI.WIDGET_INSTANCE_NAME);
|
id = widgetName+"0"+attribute;
|
||||||
if (attribute != null && attribute.length() > 0) {
|
locatorBuilder.insert(0, "@"+widgetName+"["+AdempiereWebUI.WIDGET_INSTANCE_NAME+"=\'"+attribute+"\'] ");
|
||||||
String widgetName = getWidgetName(parent.getWidgetClass());
|
} else {
|
||||||
id = widgetName+"0"+attribute;
|
locatorBuilder.insert(0, "@"+getWidgetName(parent.getWidgetClass())+" ");
|
||||||
locatorBuilder.insert(0, "@"+widgetName+"["+AdempiereWebUI.WIDGET_INSTANCE_NAME+"=\'"+attribute+"\'] ");
|
}
|
||||||
} else {
|
|
||||||
locatorBuilder.insert(0, "@"+getWidgetName(parent.getWidgetClass())+" ");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
parent = parent.getParent();
|
||||||
}
|
}
|
||||||
parent = parent.getParent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
comp.setWidgetAttribute(ZK_LOCATOR_ATTRIBUTE, locatorBuilder.toString());
|
comp.setWidgetAttribute(ZK_LOCATOR_ATTRIBUTE, locatorBuilder.toString());
|
||||||
|
@ -154,31 +163,40 @@ 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) {
|
||||||
Component parent = comp.getParent();
|
String parentLocator = parent.getWidgetAttribute(ZK_LOCATOR_ATTRIBUTE);
|
||||||
while(parent != null) {
|
if (parentLocator != null && parentLocator.trim().length() > 0) {
|
||||||
//only include id space owner to ease converting test case to use zk id selector instead of uuid
|
locatorBuilder.insert(0, parentLocator+ " ");
|
||||||
if (parent instanceof IdSpace) {
|
break;
|
||||||
id = parent.getId();
|
}
|
||||||
if (id != null && id.length() > 0) {
|
parent = parent.getParent();
|
||||||
if (id.indexOf(" ") > 0) {
|
}
|
||||||
String widgetName = getWidgetName(parent.getWidgetClass());
|
} else {
|
||||||
locatorBuilder.insert(0, "@"+widgetName+"[id=\'"+id+"\'] ");
|
Component parent = comp.getParent();
|
||||||
|
while(parent != null) {
|
||||||
|
//only include id space owner to ease converting test case to use zk id selector instead of uuid
|
||||||
|
if (parent instanceof IdSpace) {
|
||||||
|
id = parent.getId();
|
||||||
|
if (id != null && id.length() > 0) {
|
||||||
|
if (id.indexOf(" ") > 0) {
|
||||||
|
String widgetName = getWidgetName(parent.getWidgetClass());
|
||||||
|
locatorBuilder.insert(0, "@"+widgetName+"[id=\'"+id+"\'] ");
|
||||||
|
} else {
|
||||||
|
locatorBuilder.insert(0, "$"+id+" ");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
locatorBuilder.insert(0, "$"+id+" ");
|
String attribute = parent.getWidgetAttribute(AdempiereWebUI.WIDGET_INSTANCE_NAME);
|
||||||
}
|
if (attribute != null && attribute.length() > 0) {
|
||||||
} else {
|
String widgetName = getWidgetName(parent.getWidgetClass());
|
||||||
String attribute = parent.getWidgetAttribute(AdempiereWebUI.WIDGET_INSTANCE_NAME);
|
locatorBuilder.insert(0, "@"+widgetName+"["+AdempiereWebUI.WIDGET_INSTANCE_NAME+"=\'"+attribute+"\'] ");
|
||||||
if (attribute != null && attribute.length() > 0) {
|
} else {
|
||||||
String widgetName = getWidgetName(parent.getWidgetClass());
|
locatorBuilder.insert(0, "@"+getWidgetName(parent.getWidgetClass())+" ");
|
||||||
locatorBuilder.insert(0, "@"+widgetName+"["+AdempiereWebUI.WIDGET_INSTANCE_NAME+"=\'"+attribute+"\'] ");
|
}
|
||||||
} else {
|
|
||||||
locatorBuilder.insert(0, "@"+getWidgetName(parent.getWidgetClass())+" ");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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,10 +50,7 @@ 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);
|
AdempiereIdGenerator.updateZkLocatorAttribute(child);
|
||||||
if (locator != null) {
|
|
||||||
AdempiereIdGenerator.updateZkLocatorAttribute(child);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -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())
|
||||||
{
|
{
|
||||||
|
@ -585,9 +586,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
|
||||||
{
|
{
|
||||||
popupMenu.addContextElement((XulElement) editor.getComponent());
|
popupMenu.addContextElement((XulElement) editor.getComponent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
popupMenu.setId(field.getColumnName()+"-popup");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,8 +34,9 @@ public class LogEventInterceptor implements EventInterceptor {
|
||||||
* @see org.zkoss.zk.ui.util.EventInterceptor#beforeProcessEvent(org.zkoss.zk.ui.event.Event)
|
* @see org.zkoss.zk.ui.util.EventInterceptor#beforeProcessEvent(org.zkoss.zk.ui.event.Event)
|
||||||
*/
|
*/
|
||||||
@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