How To Configure Browser Automation Through SFDX Selenium

SFDX Selenium combines SFDX – a developer toolset for Salesforce development – and Selenium, a popular open-source framework for automating web browsers.

How To Configure Browser Automation Through SFDX Selenium
Table of contents

It allows developers to write automated tests for Salesforce applications using Selenium's capabilities.

It provides a way to interact with Salesforce user interfaces, perform actions, and validate results, making it a valuable tool for testing and ensuring the quality of Salesforce applications.

Some use cases for browser automation include:

  • UI testing
  • Configuration can be applied via browser automation, which is not supported in metadata API.
👉
The aim of SFDX is to close the gaps in these non-supported metadata use cases. But there are still some gaps. 

That is why Hutte created an open-source command-line tool to help close the gap of applying a configuration in the setup menu  –  “sfdx-browserforce-plugin.”

With other SaaS tools, there is no performing browser in Salesforce orgs.

With Hutte, you can run any script – including any browser automation – in a Docker container on our platform.

Hutte is truly one of the best tools that we use. Product owners, Salesforce solution architects, business analysts — anyone on our team can easily and visually accomplish the tasks that would otherwise take a lot of clicks, time, and coding.

Sebastian Lechner

Product Management Director of IPfolio
Clarivate

Source: Hutte

Hutte browser automation recipe

🍳
To illustrate how you can change your browser automation configuration, Hutte has created a recipe.

This recipe uses the “sfdx-browserforce-plugin” to create the “Setup,” “Company,” “Information,” and “Currency Locale” in a scratch org using browser automation, as this is not supported in the metadata API.

Prerequisites

  • A valid SFDX project
  • A “hutte.yml” file (for example, the default one shown in the “CONFIGURATION” tab).

Step One

Create a “config/change-default-currency-locale.json” file with the following content:

{
  "$schema": "https://raw.githubusercontent.com/amtrack/sfdx-browserforce-plugin/master/src/plugins/schema.json",
  "settings": {
    "companyInformation": {
      "defaultCurrencyIsoCode": "English (Ireland) - EUR"
    }
  }
}

Step Two

  • Edit the “hutte.yml” file in your default branch
  • Add the following lines to the “push_script:”
push_script: |
  sfdx --version
  export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
  echo y | sfdx plugins install sfdx-browserforce-plugin
  export PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
  sfdx browserforce:apply -f config/change-default-currency-locale.json
  sfdx force:source:push -f --loglevel fatal 1>/dev/null

Step Three

  • Create a scratch org
  • Log in to the scratch org
  • Verify that the currency has been changed.

To get to know Hutte better, start your free 30-day trial, or check out our demo below.

Read on if you’d like to discover how to create scratch orgs through Hutte!

Visualize Git with Hutte

At Hutte, we enable you to visually leverage the benefits of Git-based development without needing CLI. We have removed the barriers Git can pose as Hutte is a web UI to SFDX that allows for visual Salesforce version control.

You can also create and manage Salesforce scratch orgs and sandboxes. There is no need for code, which means there is no hassle involved.

Furthermore, you don’t need to install or learn Git, as Hutte’s UI is already integrated into Git hosting tools, like GitLab and Azure.

🔎
From these hosting providers, you can also view the changes you made, including your pull request, in a line-by-line comparison format. 

There is no need to reproduce this data as everything is generated and integrated with Hutte.

Now, let’s get into how to create scratch orgs.

Create scratch orgs in a collaboration-friendly environment

You can create scratch orgs that can be accessed together as a team. Users can create scratch orgs using the “New scratch org” button.

You can choose a Git branch from which you want to create your environment, and you can name it.

Your scratch orgs will be listed in one place, giving you a historic overview or snapshot of your projects, apps, and codebases created in Git. This is a helpful feature, as you and your team ultimately want to contribute to each other’s work.

Without Hutte, you need to rely solely on CLI. With Hutte, you can:

  • Easily make changes to the latest state of your source
  • Implement the new feature
  • Ship it to Git.

If a developer has executed new features and submitted them to Git, instead of manually telling the team that they have provisioned an environment, the team can simply view it on the scratch orgs dashboard.

They will tell the team which branch they added the features to. You can then find the branches by “New scratch orgs.” From there, you can create a scratch org from that branch. It will appear in your list of scratch orgs.
  • You won’t need to run the code locally
  • It won’t block your machine, and it won’t block you
  • It will run asynchronously on Hutte’s infrastructure.

When your scratch org is ready, you won’t have to worry about user creation or any manual steps to build the org. Once logged into the scratch org, you can play around with it without affecting other users’ data.

Hutte essentially empowers users to easily manage and pick their own environments.

Pick a scratch org from the pool

Hutte has a pool of orgs pre-created for you, so you don't need to wait, as you can spin them up visually. Picking a scratch org from the pool speeds up the process even further when you need an environment from the latest state of your source.

💦
You can “Take from the pool,” enter the name of the pool you want to claim, and it will appear in your pool.

You can dimensionate your pool by going to “Settings.” You can also decide how big the pool is and how long it will be.

Hutte’s Jira plugin

🔌
If you use Jira, there will be a work item for it. Hutte’s Jira plugin will then find scratch orgs referencing the same name as your work item (or issue).

As a product manager, you can then leave a comment for the developer who worked on the scratch org you selected. This enables collaboration without any interference or overriding of work already done by a developer.

Browser automation made easy

Even though scratch orgs are intended to be workspaces where individuals can explore and test features in isolation, when you work together to automate web browsers, you can conquer challenges.

🤹‍♂️
Obstacles like configuration management, non-supported metadata, and juggling multiple scratch orgs become more streamlined. 

Plus, teaming up helps you share code, manage dependencies, and optimize your workflows for maximum productivity and efficiency.