IDEMPIERE-92 - Integrate Selenium. Use widget name and instance name for uuid generation when id is not set. Change WEditor to use the common instanceName widget attribute.

This commit is contained in:
Heng Sin Low 2012-12-17 11:50:14 +08:00
parent 21c2f0c05b
commit 6b1f26159e
3 changed files with 26 additions and 5 deletions

View File

@ -44,6 +44,13 @@ public class AdempiereIdGenerator implements IdGenerator {
public String nextComponentUuid(Desktop desktop, Component comp, ComponentInfo compInfo) {
String prefix = comp.getId();
if (prefix == null || prefix.length() == 0) {
String attribute = comp.getWidgetAttribute(AdempiereWebUI.WIDGET_INSTANCE_NAME);
if (attribute != null && attribute.length() > 0) {
prefix = getWidgetName(comp.getWidgetClass())+"0"+attribute;
}
}
if (prefix == null || prefix.length() == 0) {
prefix = DEFAULT_ZK_COMP_PREFIX;
}
@ -54,8 +61,15 @@ public class AdempiereIdGenerator implements IdGenerator {
//only include id space owner to ease converting test case to use zk id selector instead of uuid
if (parent instanceof IdSpace) {
String id = parent.getId();
if (id != null && id.length() > 0)
if (id != null && id.length() > 0) {
builder.insert(0, id+"_");
} else {
String attribute = parent.getWidgetAttribute(AdempiereWebUI.WIDGET_INSTANCE_NAME);
if (attribute != null && attribute.length() > 0) {
id = getWidgetName(parent.getWidgetClass())+"0"+attribute;
builder.insert(0, id+"_");
}
}
}
parent = parent.getParent();
}
@ -85,6 +99,11 @@ public class AdempiereIdGenerator implements IdGenerator {
return prefix + i;
}
private String getWidgetName(String widgetClass) {
String name = widgetClass.substring(widgetClass.lastIndexOf(".")+1);
return name.toLowerCase();
}
public static String escapeId(String prefix) {
Pattern pattern = Pattern.compile("[^a-zA-Z_0-9]");
Matcher matcher = pattern.matcher(prefix);

View File

@ -22,6 +22,7 @@ import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import org.adempiere.webui.AdempiereWebUI;
import org.adempiere.webui.component.Bandbox;
import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.Datebox;
@ -109,9 +110,10 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
this.setComponent(comp);
this.gridField = gridField;
comp.setWidgetAttribute("columnName", gridField.getColumnName());
if (gridField.getGridTab() != null) {
comp.setWidgetAttribute("qualifiedColumnName", gridField.getGridTab().getTableName()+"."+gridField.getColumnName());
comp.setWidgetAttribute(AdempiereWebUI.WIDGET_INSTANCE_NAME, gridField.getGridTab().getTableName()+"0"+gridField.getColumnName());
} else {
comp.setWidgetAttribute(AdempiereWebUI.WIDGET_INSTANCE_NAME, gridField.getColumnName());
}
this.setMandatory(gridField.isMandatory(false));
this.readOnly = gridField.isReadOnly();

View File

@ -26,7 +26,7 @@ public class SelectTabTest extends AbstractTestCase {
selectTab("$Product_1 $detailPane @tabbox", "Business Partner");
assertEquals("Business Partner", selectedTab("$Product_1 $detailPane @tabbox"));
WebElement element = driver.findElement(Zk.jq("$Product_1 $Product @textbox[columnName=\"Name\"]"));
WebElement element = driver.findElement(Zk.jq("$Product_1 $Product @textbox[instanceName=\"M_Product0Name\"]"));
assertNotNull(element);
}
}