Selenium with Adempiere Integration

Automated Testing Tools are used to assure modifications are always backward compatible and safe for production
Forum rules
This forum is personally pruned to avoid redundant posts. Related topics are moved to the same sub-forum. Language will be corrected for readability.

Selenium with Adempiere Integration

Postby dravuri » Sun Feb 05, 2012 10:56 am

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 ( Sample Code Below )

private static final String DEFAULT_ZK_COMP_PREFIX = "zk_comp_";
private static final String DESKTOP_ID_ATTRIBUTE = "";
public static final String ZK_COMPONENT_PREFIX_ATTRIBUTE = "zk_component_prefix";

public String nextComponentUuid(Desktop desktop, Component comp) {
String prefix = (String) comp.getAttribute(ZK_COMPONENT_PREFIX_ATTRIBUTE);
if (prefix == null || prefix.length() == 0){
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, "_");
prefix = sb.toString();

2.Added Reference to AdempiereIDGenerator in zk.xml

3.Now Made Changes in, 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”
Adempiere Selenium Integration Steps
AddingExtention.png (47.13 KiB) Viewed 8254 times

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
CustomLocatorOnTop.png (27.1 KiB) Viewed 8254 times

7.Now start your Adempiere and start recording the script
PurchaseOrder.png (110.14 KiB) Viewed 8254 times

Next steps will be covered in next post( I can not add more than 3 images )

Posts: 19
Joined: Wed May 18, 2011 10:33 am

Re: Selenium with Adempiere Integration

Postby dravuri » Sun Feb 05, 2012 11:02 am

8 .Here my expectation is when tester( In this my self) entered data in Business Partner widget, selenium IDE should record the widgets new attribute that was added( This step is important to achieve the desired goal )
seleniumrecordsteps.png (44.14 KiB) Viewed 8253 times

9.Now verify the widget with 'FireBug' to check whether our unique attribute is appearing on firebug, Firebug also does not have the ZK attribute mentioned below.
firebug.png (62.3 KiB) Viewed 8253 times

Conclusion: If we can see the “attribute” we have defined for each widget in Adempiere appears on firebug, and if selenium IDE can record this direcly then our Goal will be achieved.

Posts: 19
Joined: Wed May 18, 2011 10:33 am

Re: Selenium with Adempiere Integration

Postby globalqss » Sun Feb 05, 2012 11:59 pm

Thanks Suman, the approach I'm trying to follow is slightly different, look for example this commit: ... 19d0f71adc

With this approach I was able to save a selenium out-of-the-box test like this:

Code: Select all
open   /webui/   
type   id=unqtxtUserId   SuperUser
type   id=unqtxtPassword   S
click   id=zk_comp_28!real   
click   css=img.z-combobox-img   
click   css=#zk_comp_63 > td.z-combo-item-text   
click   //span[@id='unqlstClient!btn']/img   
click   css=#zk_comp_93 > td.z-combo-item-text   
click   //span[@id='unqlstOrganisation!btn']/img   
click   css=#zk_comp_106 > td.z-combo-item-text   
click   //span[@id='unqlstWarehouse!btn']/img   
click   css=#zk_comp_112 > td.z-combo-item-text   
click   id=zk_comp_722!open   
click   id=zk_comp_751!open   
click   id=zk_comp_797!cave   
click   id=unqBtnNew_1!hvig   
type   id=zk_comp_2383   patio
click   id=unqADButtonTab_1_1   
type   id=zk_comp_3339   aza
click   id=unqBtnSave_1!hvig   
click   id=unqADButtonTab_1_0   
click   //table[@id='unqField_1_0_C_Order_DocAction!box']/tbody/tr[2]/td[2]   
click   id=Ok_4155!hvig   
click   id=zk_comp_128   
click   //span[@id='unqField_1_0_C_Order_SalesRep_ID!btn']/img   
click   //span[@id='unqField_1_0_C_Order_SalesRep_ID!btn']/img   
click   //span[@id='unqField_1_0_C_Order_SalesRep_ID!btn']/img   
click   css=#zk_comp_2939 > td.z-combo-item-text   
click   id=unqBtnSave_1!hvig   

Note the idea, unqtxtUserId will be assigned always with such name on every session the user opens, my approach is to drop the "random" suffix that you get on every session for zk components and get unique identifiers for all the zk components.

It's a work ongoing, and there are some that will require some refactoring of code, but if we achieve that, then recording test sessions will be very easy and replicable between different installations.

Note for example that running this test fails precisely on the zk_comp_NN components as on the next session the number changes. So, the work (medium term maybe) will be to identify all those components and assign them unique identifiers from the beginning.

Look that the field unqField_1_0_C_Order_SalesRep_ID is unique and repeatable if you open the windows on the same order, the "1" within the identifier is the number of window - so it works if you open the sales order window first - there is no other way to make this identifier unique as you can open the same window several times in iDempiere.

WDYT? We can work together identifying more components that needs to be "unique-fied" ( :-) new term). The best would be if you fork globalqss361 or iDempiere and work from there.


Carlos Ruiz
Posts: 599
Joined: Thu Dec 29, 2005 4:15 am
Location: Bogotá, Colombia

Return to Quality Assurance

Who is online

Users browsing this forum: No registered users and 1 guest