Skip to main content

Understanding challenges in Salesforce test automation using Selenium

Salesforce test automation with selenium
Posted On: 20 March 2024

Salesforce test automation covers automation testing of Salesforce applications, ensuring continuous testing of all the different pieces that make up this platform. Selenium is an open-source testing framework that can be used to automate Salesforce applications. The following blog will deal with Salesforce test automation challenges using the Selenium testing framework.

Can we use Selenium for Salesforce testing?

Selenium testing is a widely used framework for automating web browsers. It helps with test scripts and execute tests for web applications, allowing developers and testers to automate repetitive tasks, such as clicking buttons, filling out forms, and navigating a website. Selenium testing supports multiple programming languages, and it is particularly popular for testing web applications across various browsers and operating systems.

Automating Salesforce application testing is not limited to stabilizing business-critical processes alone. It should also verify integrations between product websites and Salesforce applications, etc. The scope should further include the smooth running of tests so that testing teams can easily manage, maintain, and troubleshoot any failed tests without glitches.

Selenium is a simple testing framework that only allows a browser to perform specific tasks. For larger businesses and enterprises that use the Salesforce platform, which involves more tests with teams with excellent business understanding but low coding skills and where security and collaboration are highly critical, Selenium won't suffice. Let us consider the following first.

How to use Selenium in Salesforce test automation?

Setup Development Environment:

  • Install Java or any other programming language supported by Selenium.
  • Install an IDE (Integrated Development Environment) like Eclipse, IntelliJ IDEA, or Visual Studio Code.
  • Now, set up Selenium WebDriver with the necessary browser drivers.

Configure Salesforce for Testing:

  • Ensure you have a Salesforce environment (like a sandbox) dedicated to testing.
  • Create test users with appropriate permissions to perform the required operations.

Begin writing Test Cases:

  • Begin by importing the necessary Selenium libraries in your test scripts.
  • Use Selenium to open a web browser and navigate to your Salesforce login page.
  • Automate the login process with test user credentials.
  • Navigate through Salesforce’s User Interface elements using Selenium’s locators (like ID, name, XPath, CSS Selector) to interact with various elements (buttons, fields, menus).

Interact with Salesforce Elements:

  • Utilize Selenium’s commands to perform actions like click, type, select from drop-downs, etc.
  • Since Salesforce uses many dynamic elements and AJAX, it is important to use Selenium’s WebDriverWait or other waiting mechanisms to handle asynchronous behavior and elements that may take time to load.

Data Handling:

  • Automate data entry forms in Salesforce to create or modify records.
  • Retrieve data from Salesforce UI elements to verify if the operations were successful as part of assertions in tests.

Implement Assertions:

  • Use assertions to validate the expected outcomes of your test scripts. For example, after saving a new contact in the Salesforce application, assert that the contact details page displays the correct information.

Run and Debug Tests:

  • Execute your test scripts regularly during development to catch issues early.
  • Debug any failures by analyzing the test logs and taking screenshots of the test execution if necessary.

Continuous Integration and Testing:

  • Integrate your Selenium tests with a CI/CD pipeline (like Jenkins or GitLab CI/CD) to automate test execution during the development lifecycle.
  • Ensure that the test environment is stable and that the tests are reliable for continuous testing.

Reasons to switch from
Selenium to continuous testing

Maintain and Update Tests:

  • Regularly update your test scripts to adapt to the Salesforce application’s UI and functionality changes.
  • Refactor and optimize your test code to improve maintainability and reduce technical debt.

Using Selenium for Salesforce test automation requires a good understanding of Selenium and the Salesforce UI structure. Regular updates to Salesforce may require adjustments in your test scripts, so ongoing maintenance is crucial for long-term success. Despite that-

Should you choose Selenium in Salesforce test automation? Challenges

Scenario 1: Choosing from various programming languages

Say the testing team has a mixed set of coding skills and chooses to shift from manual to automated testing and choose Selenium. The team resources are diverse in their skill set, and each one chooses between Python and C#. Say the most experienced resource shifts to another team over time; challenges emerge.

Scenario 2: Searching for broken codes

Imagine a scenario where the rest of the team is testing with one individual's scripted tests. It might keep working well till one day, a test breaks. Troubleshooting this code involves checking lines of lengthy codes, and finding one minor issue gets cumbersome and time-consuming. Updates in the Salesforce application may make this more complicated.

Scenario 3: Handling maintenance.

Say different resources are assigned the task of setting a new series of tests with Selenium, each adopting a different approach. Over time, these tests form an overall test architecture, but due to the differences in the combined tests, testing can become a mess and challenging to maintain.

Further, here are more Salesforce testing challenges with Selenium.

1. Navigating through Salesforce frames (which have dynamic frames in the front end), which are primarily used to load content in HTML, is an issue. Selenium cannot handle content directly, and hence, it needs the help of the Selenium WebDriver to frame and use additional attributes. Selenium takes a lot of effort to find the right qualities and script accordingly, and it can get further complicated with nested or hidden frames.

2. Executing dynamic content with Salesforce is also difficult as it does not have a fixed ID, name, class, or CSS attribute. It is, therefore, not possible to hard code the locator of the element, and it is not straightforward. Minor UI changes can make the tests flaky, and Selenium could also encounter synchronization issues with element loading.

3. Handling different database-driven tables in Salesforce is another challenge, as the rows are created dynamically and can be controlled by different tabs. Even actions like ticking a checkbox with Selenium get complicated and prone to errors. Selecting the active tab can also be an issue. Further commands such as driver.switch_to.window and send keys may not work reliably.

Salesforce applications can have complexities like Shadow DOM and pop-up windows that cannot be tested with Selenium directly. They demand additional codes. Though most of the challenges of testing Salesforce with Selenium can be handled, scripting consumes a lot of time. This can impact your continuous testing goals for the Salesforce stack.


ACCELQ is a codeless test automation platform that allows testers to generate test cases for Salesforce easily. It is cloud-based and enhances the power of Selenium, making it reliable, scalable, and cost-effective.ACCELQ helps overcome the challenges mentioned above without the need for additional programming. Reach out to us to learn more about our Salesforce test automation solution.

Guljeet Nagpaul

Chief Product Officer at ACCELQ

Guljeet, an experienced leader, served as North America's head for ALM at Mercury Interactive, leading to its acquisition by HP. He played a key role in expanding the ALM portfolio with significant acquisitions. Now at ACCELQ, he sees it as a game-changer in Continuous Testing. As Carnegie Mellon graduate, he oversees ACCELQ's Product Strategy and Marketing.

Discover More

Master QA Automation with ACCELQBlogTest AutomationMaster QA Automation with ACCELQ
21 July 2023

Master QA Automation with ACCELQ

QA automation testing also allows them to focus on complex or advanced test cases that demand human cognition and aptitude.
Top QA Automation testing toolsBlogTest AutomationTop 10 QA Automation Software Testing Tools In 2024
8 May 2024

Top 10 QA Automation Software Testing Tools In 2024

Testers can test software and provide bug-free products with QA automation tools. The blog covers those tools features in 2024.

Get started on your Codeless Test Automation journey

Talk to ACCELQ Team and see how you can get started.

Close Menu