Java · TestNG
CRM with Selenium
A leads table with filters, select-all and bulk assign, a new-lead modal with duplicate checks, an activity log, convert-to-deal, and a Kanban pipeline you can drag cards across.
App under test
📈 SalesPulse
- URL
- /apps/crm
- sales@crm.dev
- Password
- Crm@123
- Stages
- Qualified → Won/Lost
Scenarios to automate
Work top to bottom — each one adds a new technique.
- 1
Table filters
BeginnerCombine lead-search, lead-status-filter and lead-source-filter; assert lead-count and rows.
- 2
Select all & bulk assign
Intermediateselect-all-leads ticks every visible row; bulk-owner + apply-bulk updates owner-<id> cells.
- 3
New lead validation
Intermediatesave-lead with an existing email shows “already exists”; bad phone/value show error-*.
- 4
Activity log
IntermediateSwitch activity-note/call/email, save, and assert the newest activity-item text.
- 5
Convert to deal
Advancedconvert-lead → deal-value + deal-close → lead-status becomes Converted and converted-banner appears.
- 6
Kanban via menu
IntermediateChange move-deal-<company> and verify the card is inside stage-<id> and stage-total-* updates.
- 7
Kanban drag & drop
AdvancedDrag a deal-card onto another stage-* column (HTML5 DnD — dispatch events in Selenium/Cypress).
- 8
Dashboard KPIs
BeginnerWinning a deal changes kpi-won and kpi-win-rate on the dashboard.
Sample Selenium suite
A working starting point that finds elements every way Selenium can — by role, label, text, id, name, CSS, XPath and data-testid — so you practice them all. Pick your language, switch to data-testid only to compare, or try your own in the Locator Playground.
import org.testng.annotations.*;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import java.util.Map;
import org.openqa.selenium.support.ui.*;
import java.time.Duration;
import static org.openqa.selenium.support.ui.ExpectedConditions.*;
// Locators in this suite: By.id ×4 · By.name ×4 · By.linkText ×1 · By.xpath ×6 · By.cssSelector ×4 · data-testid ×10
public class SalesPulsePipelineTest {
static final String BASE = "https://www.practiceqaautomation.com";
WebDriver driver;
WebDriverWait wait;
// Small helpers: every action takes a By and waits for its element first (no Thread.sleep).
By tid(String id) { return By.cssSelector("[data-testid='" + id + "']"); }
WebElement ready(By by) { return centre(wait.until(elementToBeClickable(by))); }
void click(By by) { ready(by).click(); }
WebElement nth(String id, int n) { return centre(wait.until(numberOfElementsToBeMoreThan(tid(id), n)).get(n)); }
void clickNth(String id, int n) { nth(id, n).click(); }
// Scroll to the middle of the screen first: Selenium only scrolls an element to the edge,
// where a sticky header or a fixed bottom bar can cover it (ElementClickInterceptedException).
WebElement centre(WebElement e) {
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView({block: 'center', inline: 'nearest'})", e);
return e;
}
void type(By by, String text) { ready(by).sendKeys(text); }
void select(By by, String value) { new Select(ready(by)).selectByValue(value); }
void check(By by) { WebElement e = ready(by); if (!e.isSelected()) e.click(); }
void expectText(By by, String text) { wait.until(textToBePresentInElementLocated(by, text)); }
void expectVisible(By by) { wait.until(visibilityOfElementLocated(by)); }
void expectNthText(String id, int n, String text) {
wait.until(d -> d.findElements(tid(id)).size() > n && d.findElements(tid(id)).get(n).getText().contains(text));
}
@BeforeMethod
public void setUp() {
ChromeOptions options = new ChromeOptions();
// Turn off Chrome's "Save password?" and "password found in a data breach" pop-ups: after a
// login they take the keyboard and mouse away from the page, so later typing and clicks are lost.
options.setExperimentalOption("prefs", Map.of(
"credentials_enable_service", false,
"profile.password_manager_enabled", false,
"profile.password_manager_leak_detection", false));
driver = new ChromeDriver(options);
wait = new WebDriverWait(driver, Duration.ofSeconds(10));
}
@AfterMethod(alwaysRun = true)
public void tearDown() { driver.quit(); }
@Test
public void addsALeadAndMovesTheDealThroughThePipeline() {
driver.get(BASE + "/apps/crm");
type(By.id("crm-email"), "sales@crm.dev");
type(By.name("crm-password"), "Crm@123");
click(By.xpath("//button[normalize-space()='Sign in']"));
wait.until(urlContains("/apps/crm/dashboard"));
click(By.linkText("Leads"));
click(tid("new-lead"));
type(By.id("lead-name"), "Grace Lee");
type(By.name("lead-company"), "Globex Corp");
type(tid("lead-email"), "grace@globex.com");
type(By.id("lead-phone"), "5550142233");
select(By.name("lead-source"), "linkedin");
type(tid("lead-value"), "45000");
click(By.xpath("//button[normalize-space()='Save lead']"));
expectText(tid("leads-toast"), "created");
expectText(tid("leads-table"), "Globex Corp");
// Newest lead is listed first
clickNth("open-lead", 0);
expectText(tid("lead-title"), "Grace Lee");
click(By.xpath("//button[normalize-space()='Log call']"));
type(By.cssSelector("[aria-label='Activity details']"), "Intro call — interested in the annual plan");
click(By.xpath("//button[normalize-space()='Save call']"));
expectText(tid("activity-timeline"), "annual plan");
click(By.xpath("//button[normalize-space()='Convert to deal']"));
type(By.id("deal-value"), "45000");
select(By.name("deal-close"), "30");
click(By.xpath("//button[normalize-space()='Create deal']"));
expectText(tid("lead-status"), "Converted");
click(tid("view-pipeline"));
expectText(By.cssSelector("[aria-label='Qualified']"), "Globex Corp");
select(By.cssSelector("[aria-label='Move Globex Corp']"), "proposal");
expectText(By.cssSelector("[aria-label='Proposal']"), "Globex Corp");
expectText(tid("stage-total-proposal"), "$212,000");
}
}