This project is a UI automation framework for Salesforce Lightning built using:
- Java
- Selenium WebDriver
- TestNG
- Maven
- Page Object Model (POM) design pattern
The framework automates key Salesforce scenarios such as:
- Login
- Navigation through App Launcher
- Account management (Create / Update / Delete)
This project follows best practices for maintainability, reusability, and scalability.
salesforce-selenium
│── pom.xml
│── README.md
└── src
└── test
└── java
└── com.qa.salesforce
├── base
│ └── BaseTest.java
├── pages
│ ├── LoginPage.java
│ ├── HomePage.java
│ ├── AppLauncherPage.java
│ └── AccountsPage.java
├── flows
│ └── NavigationFlow.java
├── tests
│ ├── AccountTest.java
│ ├── AccountUpdateTest.java
│ └── AccountDeleteTest.java
└── utils
└── WaitUtils.java
The framework follows the Page Object Model (POM):
BaseTest.java
- Initializes WebDriver
- Opens browser
- Performs Salesforce login
- Handles setup and teardown (
@BeforeMethod,@AfterMethod) - All test classes extend this class
Each class represents a Salesforce page and contains:
- Locators
- Actions (click, type, search, etc.)
- No test logic
Classes:
- LoginPage – Handles login actions
- HomePage – Home screen operations
- AppLauncherPage – App Launcher interactions
- AccountsPage – Create, search, update, and delete Accounts
NavigationFlow.java
Purpose:
-
Contains reusable business navigation steps
-
Example:
- Open App Launcher
- Search for "Accounts"
- Navigate to Accounts page
This avoids duplicating navigation logic across tests.
Contains TestNG test classes.
Each class focuses on one functional area:
| Class | Purpose |
|---|---|
| AccountTest | Create a new Account |
| AccountUpdateTest | Update an existing Account |
| AccountDeleteTest | Delete an Account |
Best Practice:
- Tests are independent
- Each test uses reusable Page and Flow methods
- Assertions validate expected behavior
WaitUtils.java
- Explicit wait methods
- Improves stability and avoids Thread.sleep()
- Used across page classes
ConfigReader.java
- Reads values from config.properties
- Provides them to the framework using getter methods
- This allows tests to run without modifying code when environment values change.
config.properties
- This file stores environment specific data such as : URL, username, password, browser ...
- Purpose: # Avoid hardcoding credentials or URLs in the code # Easily switch environments (Dev / QA / UAT) # Improve security and maintainability
mvn test
Maven will:
- Compile the project
- Execute all TestNG tests
- Run them using Surefire plugin
Note: Test execution order is not guaranteed unless a TestNG suite is used.
Defined in pom.xml:
- Selenium Java
- TestNG
- Maven Compiler Plugin
To download dependencies:
mvn clean install
- Page Object Model (POM)
- Separation of concerns
- Reusable navigation flows
- Explicit waits (no hard sleeps)
- Test independence
- Maven project structure
For Account creation:
Test Class → BaseTest (browser + login) → NavigationFlow (go to Accounts) → AccountsPage (create account) → Test Assertion
- TestNG XML suites (ordered execution)
- Data-driven testing (Excel/JSON)
- Screenshot on failure
- Reporting (Extent Reports)
- CI/CD integration (GitHub Actions)
This framework is designed as a scalable starting point for Salesforce UI automation and can be extended to automate other Salesforce objects such as:
- Contacts
- Opportunities
- Leads
The structure allows easy maintenance and collaboration within a QA team.
Before running the project, make sure the following tools are installed on your machine.
This project requires Java 17 (or higher).
Check if Java is installed:
java -versionIf not installed:
-
Download JDK from:
-
Install the JDK.
-
Set environment variables:
Windows
- Create a variable:
JAVA_HOME→ path to your JDK folder - Add
%JAVA_HOME%\binto yourPath
Verify installation:
javac -versionMaven is used to manage dependencies and run the tests.
Check installation:
mvn -versionIf Maven is not installed:
-
Download Maven: https://maven.apache.org/download.cgi
-
Extract it (example:
C:\apache-maven) -
Set environment variables:
Windows
- Create
MAVEN_HOME→ Maven folder path - Add
%MAVEN_HOME%\bintoPath
Verify:
mvn -versionDownload: https://code.visualstudio.com/
Install the following extensions:
- Extension Pack for Java
- TestNG for VS Code
- Maven for Java
Clone the repository:
git clone <https://github.com/mokhtarhalim/salesforce-selenium >
cd salesforce-seleniumOr download the project and open the folder in VS Code.
Update the file:
src/test/resources/config.properties
Example:
url=https://login.salesforce.com
username=your_username
password=your_password
This avoids hardcoding credentials inside the code and allows easy environment changes.
From the project root, run:
mvn clean installThis will:
- Download Selenium dependencies
- Download TestNG
- Compile the project
Execute:
mvn testThe framework will:
- Launch the browser
- Login to Salesforce
- Wait up to 60 seconds for manual MFA verification (if required)
- Execute all TestNG tests
Note: Test execution order is not guaranteed unless a TestNG suite (
testng.xml) is used.