Salesforce Console Automation using Selenium

Challenges of Salesforce Automation Testing

One of the most challenging aspects of salesforce automation is handling the console menu in the Application screen. We are utilizing ‘Testing the UI’ approach to automate the Salesforce Application (Summer 16 – API v37.0). Graphical User Interface has been automated using the familiar Selenium Web driver framework. Due to the CSS Pseudo element console development in salesforce, we are not able to inspect the appropriate element using the Fire Bug or any other tool including the browsers default debugging tool. Element identification by id, by xpath, by css selector did not help to trace the element for triggering an action event such as button click.

What is Pseudo element?

A CSS pseudo-element is used to style specified parts of an element.

Pseudo-elements are added to selectors but instead of describing a special state, they allow developer to style certain parts of a document. For example, the ::first-line pseudo-element targets only  the first line of an element specified by the selector.

Pseudo :after element will be generated as follows;


How to overcome the above challenge?

We tried to use Sikuli GUI automation tool, which helps to click the pseudo element based on the X, Y coordinates but it’s not a permanent solution in which if the screen resolution changes, automation script will break while running. We got the final solution to handle the salesforce console of pseudo element using the Actions class.

Actions class has been implemented for handling the SFDC console automation;

Actions actions = new Actions(driver);
WebElement idElement = driver.findElement(“ext-gen33”));
Point point = idElement.getLocation();
int xcord = point.getX();
int xaxis = xcord + 230;
int ycord = point.getY();
int yaxis = ycord – 45;
actions.moveToElement(idElement, xaxis, yaxis);

 About Actions Class

Actions is a user-facing API for emulating complex user gestures. Use this class rather than using the Keyboard or Mouse directly.

Actions(WebDriver driver) – Default constructor – uses the default keyboard, mouse implemented by the driver.

Compatibility testing has been performed with the multiple screen resolutions using the above code snippet and it is working as expected in the different pixels(1600 x 900, 1440 x 900, 1360 x 768, 1280 x 800, 1280 x 720) without any code break-up.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s