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) {
|
||||
locatorBuilder.append("@").append(getWidgetName(comp.getWidgetClass()));
|
||||
}
|
||||
|
||||
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+"\'] ");
|
||||
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();
|
||||
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 {
|
||||
locatorBuilder.insert(0, "$"+id+" ");
|
||||
}
|
||||
} else {
|
||||
String attribute = parent.getWidgetAttribute(AdempiereWebUI.WIDGET_INSTANCE_NAME);
|
||||
if (attribute != null && attribute.length() > 0) {
|
||||
String widgetName = getWidgetName(parent.getWidgetClass());
|
||||
id = widgetName+"0"+attribute;
|
||||
locatorBuilder.insert(0, "@"+widgetName+"["+AdempiereWebUI.WIDGET_INSTANCE_NAME+"=\'"+attribute+"\'] ");
|
||||
} else {
|
||||
locatorBuilder.insert(0, "@"+getWidgetName(parent.getWidgetClass())+" ");
|
||||
String attribute = parent.getWidgetAttribute(AdempiereWebUI.WIDGET_INSTANCE_NAME);
|
||||
if (attribute != null && attribute.length() > 0) {
|
||||
String widgetName = getWidgetName(parent.getWidgetClass());
|
||||
id = widgetName+"0"+attribute;
|
||||
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());
|
||||
|
@ -154,31 +163,40 @@ public class AdempiereIdGenerator implements IdGenerator {
|
|||
|
||||
if (id == null || id.length() == 0) {
|
||||
locatorBuilder.append("@").append(getWidgetName(comp.getWidgetClass()));
|
||||
}
|
||||
|
||||
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+"\'] ");
|
||||
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();
|
||||
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 {
|
||||
locatorBuilder.insert(0, "$"+id+" ");
|
||||
}
|
||||
} else {
|
||||
String attribute = parent.getWidgetAttribute(AdempiereWebUI.WIDGET_INSTANCE_NAME);
|
||||
if (attribute != null && attribute.length() > 0) {
|
||||
String widgetName = getWidgetName(parent.getWidgetClass());
|
||||
locatorBuilder.insert(0, "@"+widgetName+"["+AdempiereWebUI.WIDGET_INSTANCE_NAME+"=\'"+attribute+"\'] ");
|
||||
} else {
|
||||
locatorBuilder.insert(0, "@"+getWidgetName(parent.getWidgetClass())+" ");
|
||||
String attribute = parent.getWidgetAttribute(AdempiereWebUI.WIDGET_INSTANCE_NAME);
|
||||
if (attribute != null && attribute.length() > 0) {
|
||||
String widgetName = 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());
|
||||
|
|
|
@ -35,6 +35,7 @@ public class UiLifeCycleListener implements UiLifeCycle {
|
|||
*/
|
||||
@Override
|
||||
public void afterComponentAttached(Component comp, Page page) {
|
||||
AdempiereIdGenerator.updateZkLocatorAttribute(comp);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -49,10 +50,7 @@ public class UiLifeCycleListener implements UiLifeCycle {
|
|||
*/
|
||||
@Override
|
||||
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)
|
||||
|
|
|
@ -571,6 +571,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
|
|||
if (popupMenu != null)
|
||||
{
|
||||
popupMenu.addMenuListener((ContextMenuListener)editor);
|
||||
popupMenu.setId(field.getColumnName()+"-popup");
|
||||
this.appendChild(popupMenu);
|
||||
if (!field.isFieldOnly())
|
||||
{
|
||||
|
@ -586,8 +587,6 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
|
|||
popupMenu.addContextElement((XulElement) editor.getComponent());
|
||||
}
|
||||
}
|
||||
|
||||
popupMenu.setId(field.getColumnName()+"-popup");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,8 @@ public class LogEventInterceptor implements EventInterceptor {
|
|||
*/
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.idempiere.ui.zk.selenium.Widget;
|
|||
import org.idempiere.ui.zk.selenium.Zk;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.interactions.Actions;
|
||||
|
||||
import fitlibrary.annotation.SimpleAction;
|
||||
import fitlibrary.spider.AbstractSpiderFixture;
|
||||
|
@ -219,6 +220,14 @@ public class ZkFixture extends SpiderFixture {
|
|||
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
|
||||
* of milliseconds, subject to the precision and accuracy of system timers
|
||||
|
|
Loading…
Reference in New Issue