Skip to content

Can You Automate Salesforce Tests Using Selenium?

Maria Homann

Maria Homann

In the search for the best automation tool to automate Salesforce, many choose Selenium as their go-to tool. If you too are considering Selenium for Salesforce testing, read on so that you know the challenges that lie ahead, and are equipped to make an informed decision.

Selenium test automation is a popular web-testing tool.

Why?

Firstly, it’s free and open-source. This makes it an obvious starting point to see how test automation can contribute to productivity.

Second, Selenium allows you to drive tests and automate any process in a browser. This opens up test automation to any SaaS applications that run in the browser, including Salesforce!

But Selenium requires coding, and isn’t the best option for teams with limited or no coding capabilities.

Even those who have excellent coders on their team will find that a lot of time goes into setting up and maintaining Selenium tests – time that could have been better spent elsewhere.

Skip ahead to:

  1. Can Selenium be used for Salesforce?
  2. Using Selenium to automate Salesforce: 3 scenarios
  3. How to automate Salesforce testing with Selenium IDE (Salesforce login example)
  4. The challenge of using Selenium IDE for Salesforce
  5. Selenium for Salesforce alternatives

Can Selenium be used for Salesforce?

Yes! As Selenium allows you to automate any process in a browser, and Salesforce runs in the browser, you can use Selenium with Salesforce.

Selenium WebDriver offers a programming interface to interact with web browsers, enabling actions such as button clicks, form filling, page navigation, and data verification on Salesforce pages. Additionally, tools like Selenium IDE (which operates on WebDriver) have record and playback features that speed up the test creation process. 

The difference between IDE and WebDriver is that the latter can build scripts using a record and playback tool, as opposed to writing lines of code as WebDriver requires. The example below illustrates what you would need to code in WebDriver to test that a “leave application request” form is functioning as normal.

Using Selenium to automate Salesforce: 3 scenarios

Below are three scenarios that each explain typical challenges that testers face when trying to use Selenium for Salesforce test automation.

Scenario 1: The myriad of programming languages

A team consisting of one developer (let’s call him Dan), one tester with strong coding skills (Tina), and three testers with little to no coding skills (Teresa, Tom and Tiffany) choose to shift from manual to automated testing and select Selenium as their tool.

First, Dan and Tina are given the task of writing the scripts for their Selenium automated tests. Dan prefers to write his tests with Python, whereas Tina prefers C#.

Time passes, and new projects emerge. Being the most experienced programmer on the team, Dan’s time is reallocated to other projects, where his coding skills are needed. Tina stays on the testing team, and is asked to take over Dan’s scripts.

This is where the first challenge emerges. Tina doesn’t know Python, and therefore is forced to discard Dan’s unfinished tests and write them over in C#. Time is thrown out the window, and Tina is faced with the tedious task, which could have been avoided if they had chosen a no-code tool from the beginning.

Scenario 2: The endless search for broken code

Tina, Teresa, Tom and Tiffany are all testing with Tina’s scripted Selenium tests. It works well, until one day, a test breaks.

Tina tries to troubleshoot the test by searching through all the code. It isn’t easy though; there’s a lot of code to go through, and finding a small issue amonglines and lines of code can be tedious and very time-consuming.

Meanwhile, Tom wants to update another test, as there has been an update in Salesforce causing one of the elements in the test to be invalid. He also must spend a significant amount of time searching through the script – longer than Tina, because he isn’t as experienced with the code.

Once again, a lot of time goes into troubleshooting and maintenance.

Scenario 3: The maintenance monster

Dan, Tina, Teresa, Tom and Tiffany are all given the task of setting up a new series of tests with Selenium.

This time, they all contribute to the creation of tests: Dan and Tina write their own (in their preferred languages), while Teresa, Tom and Tiffany use Selenium’s documentation combined with simple Google searches to put together their tests.

Over time, tests are built up, contributing to an overall test architecture.

Unfortunately, due to the complexity of the combined tests, the testing architecture becomes quite chaotic and a bit of a monster to maintain.

Related reading: How to Build Maintainable and Scalable Test Automation

The team’s manager, Marie, concludes that the time it takes to maintain and rebuild automation scripts supersedes the time saved on automation, and she decides it isn’t worth it anymore.

She wants to find a new, more time-efficient solution that will give a better return on investment over time.

How to automate Salesforce testing with Selenium (Salesforce login example)

In this section you will find information on how to install and set-up Selenium IDE and WebDriver, followed by an example of how you can use Selenium IDE to record a Salesforce Login test case, along with the hidden challenges of using IDE. 

Getting ready to use Selenium for Salesforce

  • Install the programming language bindings compatible with Selenium: You can find all the compatible programming languages, along with the download links on Selenium. This will be required if you use Selenium WebDriver for coding more complex test cases. 
  • Install a browser: You have likely already installed the browser you intend to use for testing. Bear this browser in mind when installing a Driver. 
  • Install a Driver: Install the Driver from Selenium that is compatible with the browser that you are using for testing. Bear in mind that this driver will only work for that browser. 
  • Install a Selenium library: The library you install will depend on the programming language you installed. You can find an overview of the compatible libraries in Selenium’s documentation
  • Download Selenium IDE: Selenium IDE can be used to make use of their record and playback tool. Selenium can be downloaded as a browser extension. 
  • Create a Testing Environment: Use a Salesforce sandbox or a developer org specifically for testing to avoid affecting production data.
  • Set Up Test Users: Create test users with the appropriate permissions needed for your automated tests. This can be done in both Salesforce Classic and Lightning.

Building a test case in Selenium IDE

Step 1: Launch Selenium IDE by clicking on the extension icon

salesforce selenium testing screenshot

Step 2: Insert the Salesforce login link to your Selenium IDE project, and press the record button

salesforce selenium testing screenshot

Step 3: Record steps.salesforce selenium testing screenshot
Step 4: Navigate to Selenium IDE to end the test case after performing your actions.  salesforce selenium testing screenshot

Step 5: Rerun the test case to preview the performance of the test.salesforce selenium testing screenshot

Step 6: Maintenance… This is where things get tricky, and we explain why in the next section.

The challenge of using Selenium IDE for Salesforce

On the face of it, the IDE recorder does speed up the process of creating a test case. While you’re gaining speed in one stage of automation testing, the creation stage. Everything that comes afterwards, from maintenance to scaling to more complicated tests (for example testing end-to-end across applications such as SAP, Oracle or Dynamics365) requires more work than what you gain. 

If you are a tester or managing a team of QA professionals working within Salesforce, using Selenium IDE might seem like a convenient entry point into test automation. However, you’ll quickly encounter significant limitations that make it less suitable for Salesforce environments:

  1. Limited functionality: Selenium IDE offers very basic features and may not fully support the unique complexities of Salesforce applications, such as handling dynamic elements or custom Salesforce components. For example, certain Salesforce Lightning elements may not be easily automated, leading to incomplete or unreliable test coverage.
  2. Fragile record-and-playback: Tests created using Selenium IDE’s record-and-playback functionality are highly prone to breaking whenever there are changes in the Salesforce user interface. Given that Salesforce regularly updates its platform, maintaining these tests can become a burdensome and time-consuming task.
  3. Poor reusability: Reusing recorded sequences across multiple tests in Selenium IDE is challenging. When recording actions on Salesforce, the tool often captures excessive, unnecessary interactions, making it difficult to understand, reuse, or maintain these scripts effectively.
  4. Lack of data-driven testing: Integrating Selenium IDE with external data sources, such as Salesforce reports, Excel files, or databases, for data-driven testing is not feasible. This limitation is critical when testing complex business logic or workflows in Salesforce that rely on varied input data.
  5. Technical expertise required: Despite being marketed as a code-free tool, effective use of Selenium IDE within Salesforce often demands a strong understanding of underlying Selenium WebDriver code, HTML, and the intricacies of the Salesforce platform itself.
  6. Absence of enterprise features: From an enterprise perspective, Selenium IDE lacks essential features for large-scale testing in Salesforce. It does not offer collaborative tools, user management, audit trails, scheduling, or detailed reporting functionalities. Additionally, there’s no dedicated support or service-level agreement (SLA), which can be a significant risk for critical Salesforce projects.
  7. Lightning incompatibilities: If you have migrated to Lightning you may experience difficulties in building test cases. This is because it is difficult to identify elements in the DOM structure. The way to identify elements is through using XPaths which requires expertise in its own right.

For Salesforce testing, it is advisable to consider more robust automation tools that are specifically designed to handle the platform’s complexities and provide enterprise-level capabilities.

Selenium for Salesforce alternatives

Although Selenium checks quite a few boxes up front for teams wanting to automate their Salesforce tests, many find that it requires more of a time investment than initially expected – both in terms of setup and in terms of maintenance.

Here are four alternatives to Selenium for automating the Salesforce application. We included using AI alongside Selenium, which can be a good option for advanced Selenium users, and also included a list of features for each alternative.

Selenium-Alternatives

There is a high risk of testing bottlenecks when using Selenium and other developer-dependent tools to test web-based technologies such as Salesforce, which is the main reason why many opt for more user-friendly, code-free tools.

Watch the video below, to see how fast automation can be set up with a no-code tool compared to code-based Selenium.

When the intention of automating Salesforce tests is also to ensure stable functionality of business-critical processes, such as ensuring that customer details are updated and stored correctly, or that integrations between product websites and Salesforce are verified, it’s critical that tests are always running smoothly, and that testing teams can easily manage, maintain and troubleshoot any failed tests.

It’s important to remember that Selenium is a simple tool that only makes a browser perform certain tasks. It doesn’t offer a whole lot more than that.

For larger businesses and enterprises, where there are a big number of tests, teams with excellent business understanding but low coding skills, and functions like security and collaboration are highly critical, Selenium won’t suffice.

Learn more about codeless Salesforce automation

Learn about Leapwork's automation platform for Salesforce by downloading this solution brief, ordownload our whitepaper on Selenium for Salesforce automation to learn more about Selenium testing, and to see a comparison of Selenium to Leapwork.

New call-to-action