Hi All,
This thread is extension to the discussion i had with Carlos on the last Idempiere weekly meeting. Kindly see the below with steps I have performed. We need improve steps further to achieve the desired end goal.
1.Added Adempiere AdempiereIdGenerator.java ( Sample Code Below )
#####
private static final String DEFAULT_ZK_COMP_PREFIX = "zk_comp_";
private static final String DESKTOP_ID_ATTRIBUTE = "org.adempiere.comp.id";
public static final String ZK_COMPONENT_PREFIX_ATTRIBUTE = "zk_component_prefix";
@Override
public String nextComponentUuid(Desktop desktop, Component comp) {
String prefix = (String) comp.getAttribute(ZK_COMPONENT_PREFIX_ATTRIBUTE);
if (prefix == null || prefix.length() == 0){
prefix = DEFAULT_ZK_COMP_PREFIX;
}
else {
Pattern pattern = Pattern.compile("[^a-zA-Z_0-9]");
Matcher matcher = pattern.matcher(prefix);
StringBuffer sb = new StringBuffer();
while(matcher.find()) {
matcher.appendReplacement(sb, "_");
}
matcher.appendTail(sb);
prefix = sb.toString();
#####
2.Added Reference to AdempiereIDGenerator in zk.xml
####
<system-config>
<id-generator-class>org.adempiere.webui.AdempiereIdGenerator</id-generator-class>
</system-config>
#####
3.Now Made Changes in Weditor.java, to give our own specific attribute to each widget that is going to be rendered on the screen
#####
String gridTabName = gridField.getGridTab() != null
? "_" + gridField.getGridTab().getName() : "";
((HtmlBasedComponent)component).setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "Field_" + gridField.getColumnName() + gridTabName);
#####
4.Created my own “Locator Buildor” for selenium IDE( created new MyNewLocator.js file)
######
LocatorBuilders.add('zk_component_prefix', function(e) {
if (e.hasAttribute('zk_component_prefix')) {
if (e.getAttribute('zk_component_prefix')) {
return '//' + e.nodeName + '[@zk_component_prefix=\'' +
e.getAttribute("zk_component_prefix") + '\']';
}
}
return null;
});
5. Now Associated Locator Builder to selenium IDE, look at “Selenium IDE Extensions”
6.Now Changed the Order of “Locator Builders” , I put my new locator builder on top, Intention in this step, when selenium IDE, starts recording script, it should first identify the widget with newly added zk attribute
7.Now start your Adempiere and start recording the script
Next steps will be covered in next post( I can not add more than 3 images )
Thanks,
Suman