Testing is always an integral part of SDLC, especially for organizations mainly focusing on Quality while delivering the product. In any application, test cases that are part of regression test suites are usually automated to save manual effort. Salesforce applications have well-built unit tests using Apex classes. However, these may not cover the browser/ mobile browser based UI functional test cases. You need an automation tool.
As a QE, Salesforce was a new platform for me. After I worked on the platform and understood it better, automating different features via UI as well as through APIs gave me tremendous satisfaction and a huge learning experience. This is the first of a 3 part blog series on Automating Salesforce Application Testing Using Selenium WebDriver, based on my firsthand experience from learning this process myself. First, let’s talk about the tools needed to be successful.
Selenium Webdriver is an open-source UI automation tool with lot of capabilities. It can be used to automate any application that is browser based/mobile browser based (stressing more on mobile browser based, as the tool cannot actually test mobile apps, but can test applications that are launched in a mobile browser). Since the Salesforce application is browser based, I chose Selenium WebDriver to develop tests. I was more inclined towards Selenium WebDriver as tests can be written in Java to take advantage of functionality of the Java programming language. Also there are many frameworks that can be used in conjunction with Selenium libraries.
As I talk about different frameworks, I would like to mention the testing framework I used. TestNg is a testing framework used to create and maintain tests. It supports many powerful features and is relatively easy to use. These are some features I used:
- Flexible test configuration.
- Supports a powerful execution model.
- Embeds BeanShell for further flexibility.
- Elegantly handles parameterized tests with the data-provider concept.
- Support multiple instances for same test class.
- My favorite Annotations like [email protected], @BeforeMethod, @AfterMethod, @DataProvider, @Service, @Value, @Autowired, @Test, @ContextConfiguration.
Developed tests are run as part of a continuous integration build and these tests are run on Sauce Labs. Sauce Labs allows users to run tests in the cloud on more than 500 different browser platforms, operating systems and device combinations, providing a comprehensive test infrastructure for automated and manual testing of applications using Selenium. Using Spring Framework designed tests to run in the cloud (Sauce Labs) or on a stand-alone machine, this provides a consistent means of configuring and managing objects also called beans. Bean definitions are maintained in spring.xml and are configured inside any class by loading XML file or using annotations.
My introduction to Sauce Labs has helped resolve many reliability and maintainability issues that are usually seen while running tests on a stand-alone machine. Personally, I always like to run tests in Sauce Labs as I don’t see any conflicts if I am in the same org and minimize Stale element reference exceptions.
In this first installation of my blog series, I shared tools used for automating Salesforce application testing. Successful test automation not only depends on the tools that are being used, but also on developing tests using the capabilities of the tools and overall QA process within the team.
In the second installment of the blog series, I will share my experiences on how I used the above tools to develop tests for the Salesforce application and also the challenges I encountered.
And in the final installment of this blog series, I will share the process I adopted for test data creation and the execution of those tests.
Thanks for reading!
Here are some useful links to the above tools:
Download Selenium Webdriver
Selenium Webdriver Documentation