OpKey Blog

Test Automation and Salesforce - Part 2

Pallavi Sharma 10.03.2017

Challenge 1 - Lightning UI Controls

A few swift moves of my sword and I successfully cleared yet another level of my assassins creed game. One addictive game I must tell you! Anyways this article is about the sales force new UI. It seems like   sales force new lightning UI is trying hard to push our automation effort years back, but fight we must for our dignity. J . The new Lightning UI is built using the ‘Aura open source framework’ which is different than what the classic sales force apps used.  Although the new lightning UI brings forth an enthralling end user experience across devices, it makes the automation an arduous task.  One of the key challenges which we face is –“Dynamic ID

Whats Dynamic about this “ID”

Every object of the lightning UI has some physical properties and value associated with those properties. Generally we identify the object using these physical attributes, out of which ID is one of the most commonly used attribute. ID attribute is also one of the fastest attribute used by Selenium to recognize an element on a webpage. And generally if an object has an ID property it is chosen as the property of choice when saving the object. We can no longer rely on this with Sales force lightning controls and it's time to change our test automation strategy.

In the new lightning UI, the ID property for an object is dynamic thus it changes it value with every page load, making it ineffective for object recognition. We need to find a way where we are able to recognize such objects. One of the solutions is to identify the object based on its neighboring objects whose property value doesn’t undergo frequent changes.  Let us take a real world scenario to understand the solution

Real World Scenario

A few months back, my close friend shifted her home and I was invited for a housewarming party. The address she gave was that it was 2 blocks away from a popular joint in a street. Since the place was still getting changed, and revamped as residents were moving in, no wonder the address she told me on phone didn’t matched the reality. So I called her again and informed her I am lost. She asked me to come to the house, where in the right there was a big children play area. And I could reach within few minutes and spent a wonderful evening. Now I won’t forget that her house is right of a children’s play area. So my point of interest which is my friend’s house is identified in relation to the children’s play area, and the house is in right of the play area.

Solution With OpKey

On similar lines, in OpKey we have something called as Relational API. This API helps us identify the dynamic object on screen using the rightOf, leftOf, aboveOf, bottonOf  or withinOf with respect to a Pivot Object. The pivot object is usually an object whose property value doesn’t changes. Once we identify a pivot object, we use the SetPivot checkbox to make it a pivot. Then we come back to our object of interest. In here we will find an addition of a few properties which tell us about the pivot object, in reference to which we are going to identify our main object.

Here is details on how we do it

Step1: Identify the Pivot on your screen

While we are capturing the properties of the objects on a web page, we identify an object whose properties are not dynamic, and select the ‘Set Pivot’ option for it. Generally for Salesforce Form elements, we can use the labels as pivot.

 

Once an object is set as pivot, when we go back to fetching other objects in that page, four new properties are added – 

relationType, pivotObject, pivotIndex and pivotPriority. These properties are now used to identify pur dynamic object of interest.

For example in the above screenshot, we selected that the relationType of the object is that it is belowOf heading “Create Account” .

Conclusion

So in this article we saw how OpKey facilitates us to overcome some of the challenges thrown by the new lightning UI for automation. So while you guys explore OpKey and its cool feature to test Salesforce from here – www.opkey.com, I go back to fighting my way to move a level up in the assassin creed game. Have I told you guys it is one addictive game! 

Recent Posts

Free Trial