Testing Tools & Frameworks
Comprehensive guide to popular testing tools and frameworks used across the industry
Overview
The testing landscape offers numerous tools and frameworks, each designed for specific testing needs. This comprehensive guide covers the most popular and effective testing tools across different categories, helping you choose the right tools for your testing strategy.
Categories Covered: Web automation frameworks, mobile testing tools, API testing tools, performance testing tools, test management platforms, and CI/CD integration tools.
Web Automation Frameworks
Modern web automation frameworks that power UI testing across different browsers and platforms:
Playwright
Modern Web Automation
Fast, reliable end-to-end testing framework supporting all major browsers with powerful debugging capabilities.
Multi-browser
Auto-wait
Network interception
Mobile testing
JavaScript
Python
Java
C#
Selenium
Web Automation Standard
Industry-standard web automation tool with extensive browser support and large community ecosystem.
Cross-browser
Grid support
Mature ecosystem
Remote execution
Java
Python
C#
JavaScript
Cypress
Developer-Friendly Testing
Next-generation front-end testing tool built for modern web with excellent debugging and real-time reloads.
Time travel
Real-time reloads
Network stubbing
Screenshots/videos
JavaScript
TypeScript
TestCafe
No WebDriver Required
Node.js tool for automating end-to-end web testing without WebDriver, with built-in waiting mechanisms.
No WebDriver
Parallel execution
Live mode
Smart assertions
JavaScript
TypeScript
Framework Comparison
Framework | Learning Curve | Browser Support | Speed | Debugging | Best For |
---|---|---|---|---|---|
Playwright | Medium | Chrome, Firefox, Safari | Very Fast | Excellent | Modern apps, API testing |
Selenium | Medium-High | All major browsers | Medium | Good | Legacy apps, Grid testing |
Cypress | Low-Medium | Chrome-family only | Fast | Excellent | Modern web apps, developers |
TestCafe | Low | All major browsers | Fast | Good | Quick setup, CI/CD |
Code Examples & Setup
Get started with popular testing frameworks using these practical examples:
Playwright Example
// Installation: npm init playwright@latest
// Basic Playwright test
const { test, expect } = require('@playwright/test');
test.describe('E-commerce Application', () => {
test.beforeEach(async ({ page }) => {
await page.goto('https://example-store.com');
});
test('should add product to cart', async ({ page }) => {
// Search for product
await page.fill('[data-testid="search-input"]', 'laptop');
await page.click('[data-testid="search-button"]');
// Select first product
await page.click('[data-testid="product-item"]:first-child');
// Add to cart
await page.click('[data-testid="add-to-cart"]');
// Verify cart count
const cartCount = page.locator('[data-testid="cart-count"]');
await expect(cartCount).toHaveText('1');
});
test('should handle login flow', async ({ page }) => {
await page.click('[data-testid="login-link"]');
// Fill login form
await page.fill('#email', 'user@example.com');
await page.fill('#password', 'password123');
await page.click('#login-button');
// Verify successful login
await expect(page.locator('[data-testid="user-menu"]')).toBeVisible();
await expect(page.locator('[data-testid="welcome-message"]')).toContainText('Welcome');
});
test('should test API and UI together', async ({ page, request }) => {
// API call to create test data
const apiResponse = await request.post('/api/products', {
data: {
name: 'Test Product',
price: 99.99,
category: 'electronics'
}
});
const product = await apiResponse.json();
expect(product.id).toBeDefined();
// Verify product appears in UI
await page.goto(`/product/${product.id}`);
await expect(page.locator('h1')).toContainText('Test Product');
await expect(page.locator('[data-testid="price"]')).toContainText('$99.99');
});
});
// Configuration file: playwright.config.js
module.exports = {
testDir: './tests',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: 'html',
use: {
baseURL: 'http://localhost:3000',
trace: 'on-first-retry',
screenshot: 'only-on-failure',
video: 'retain-on-failure'
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] }
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] }
},
{
name: 'webkit',
use: { ...devices['Desktop Safari'] }
},
{
name: 'Mobile Chrome',
use: { ...devices['Pixel 5'] }
},
{
name: 'Mobile Safari',
use: { ...devices['iPhone 12'] }
}
],
webServer: {
command: 'npm run start',
url: 'http://localhost:3000',
reuseExistingServer: !process.env.CI
}
};
# Installation: pip install playwright
# Setup: playwright install
import pytest
from playwright.sync_api import Page, expect
class TestEcommerceApp:
def test_add_product_to_cart(self, page: Page):
page.goto("https://example-store.com")
# Search for product
page.fill('[data-testid="search-input"]', 'laptop')
page.click('[data-testid="search-button"]')
# Select first product
page.click('[data-testid="product-item"]:first-child')
# Add to cart
page.click('[data-testid="add-to-cart"]')
# Verify cart count
cart_count = page.locator('[data-testid="cart-count"]')
expect(cart_count).to_have_text('1')
def test_login_flow(self, page: Page):
page.goto("https://example-store.com")
page.click('[data-testid="login-link"]')
# Fill login form
page.fill('#email', 'user@example.com')
page.fill('#password', 'password123')
page.click('#login-button')
# Verify successful login
expect(page.locator('[data-testid="user-menu"]')).to_be_visible()
expect(page.locator('[data-testid="welcome-message"]')).to_contain_text('Welcome')
def test_api_and_ui_integration(self, page: Page, request):
# API call to create test data
response = request.post('/api/products', json={
'name': 'Test Product',
'price': 99.99,
'category': 'electronics'
})
product = response.json()
assert product['id'] is not None
# Verify product appears in UI
page.goto(f"/product/{product['id']}")
expect(page.locator('h1')).to_contain_text('Test Product')
expect(page.locator('[data-testid="price"]')).to_contain_text('$99.99')
# Configuration: pytest.ini
"""
[tool:pytest]
testpaths = tests
python_files = test_*.py
python_classes = Test*
python_functions = test_*
addopts = --tb=short --strict-markers
markers =
slow: marks tests as slow
integration: marks tests as integration tests
smoke: marks tests as smoke tests
"""
# Fixtures: conftest.py
import pytest
from playwright.sync_api import Playwright, Browser, BrowserContext, Page
@pytest.fixture(scope="session")
def browser_context_args(browser_context_args):
return {
**browser_context_args,
"viewport": {"width": 1280, "height": 720},
"ignore_https_errors": True,
}
@pytest.fixture(scope="function")
def context(browser: Browser):
context = browser.new_context()
yield context
context.close()
@pytest.fixture(scope="function")
def page(context: BrowserContext):
page = context.new_page()
yield page
page.close()
// Maven dependency in pom.xml
/*
com.microsoft.playwright
playwright
1.40.0
*/
import com.microsoft.playwright.*;
import com.microsoft.playwright.options.*;
import org.junit.jupiter.api.*;
import static org.junit.jupiter.api.Assertions.*;
public class EcommerceAppTest {
private Playwright playwright;
private Browser browser;
private BrowserContext context;
private Page page;
@BeforeAll
void launchBrowser() {
playwright = Playwright.create();
browser = playwright.chromium().launch(new BrowserType.LaunchOptions()
.setHeadless(false)
.setSlowMo(100));
}
@AfterAll
void closeBrowser() {
playwright.close();
}
@BeforeEach
void createContextAndPage() {
context = browser.newContext(new Browser.NewContextOptions()
.setViewportSize(1280, 720));
page = context.newPage();
}
@AfterEach
void closeContext() {
context.close();
}
@Test
void shouldAddProductToCart() {
page.navigate("https://example-store.com");
// Search for product
page.fill("[data-testid=search-input]", "laptop");
page.click("[data-testid=search-button]");
// Select first product
page.click("[data-testid=product-item]:first-child");
// Add to cart
page.click("[data-testid=add-to-cart]");
// Verify cart count
Locator cartCount = page.locator("[data-testid=cart-count]");
assertThat(cartCount).hasText("1");
}
@Test
void shouldHandleLoginFlow() {
page.navigate("https://example-store.com");
page.click("[data-testid=login-link]");
// Fill login form
page.fill("#email", "user@example.com");
page.fill("#password", "password123");
page.click("#login-button");
// Verify successful login
assertThat(page.locator("[data-testid=user-menu]")).isVisible();
assertThat(page.locator("[data-testid=welcome-message]")).containsText("Welcome");
}
@Test
void shouldTestApiAndUiTogether() {
APIRequestContext request = playwright.request().newContext();
// API call to create test data
APIResponse response = request.post("/api/products",
RequestOptions.create().setData(Map.of(
"name", "Test Product",
"price", 99.99,
"category", "electronics"
)));
JsonNode product = new ObjectMapper().readTree(response.body());
assertNotNull(product.get("id"));
// Verify product appears in UI
page.navigate("/product/" + product.get("id").asText());
assertThat(page.locator("h1")).containsText("Test Product");
assertThat(page.locator("[data-testid=price]")).containsText("$99.99");
}
@Test
void shouldHandleMultipleBrowsers() {
// Chrome
Browser chrome = playwright.chromium().launch();
Page chromePage = chrome.newPage();
chromePage.navigate("https://example-store.com");
assertEquals("Example Store", chromePage.title());
chrome.close();
// Firefox
Browser firefox = playwright.firefox().launch();
Page firefoxPage = firefox.newPage();
firefoxPage.navigate("https://example-store.com");
assertEquals("Example Store", firefoxPage.title());
firefox.close();
// Safari
Browser webkit = playwright.webkit().launch();
Page safariPage = webkit.newPage();
safariPage.navigate("https://example-store.com");
assertEquals("Example Store", safariPage.title());
webkit.close();
}
@Test
void shouldTestMobileViewport() {
// Create mobile context
BrowserContext mobileContext = browser.newContext(new Browser.NewContextOptions()
.setViewportSize(375, 667)
.setUserAgent("Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X)"));
Page mobilePage = mobileContext.newPage();
mobilePage.navigate("https://example-store.com");
// Test mobile-specific elements
assertThat(mobilePage.locator("[data-testid=mobile-menu]")).isVisible();
assertThat(mobilePage.locator("[data-testid=desktop-nav]")).isHidden();
mobileContext.close();
}
}
Selenium WebDriver Example
// Maven dependencies
/*
org.seleniumhq.selenium
selenium-java
4.15.0
org.testng
testng
7.8.0
io.github.bonigarcia
webdrivermanager
5.6.2
*/
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.testng.annotations.*;
import io.github.bonigarcia.wdm.WebDriverManager;
// Page Object Model
public class HomePage {
private WebDriver driver;
private WebDriverWait wait;
@FindBy(id = "search-input")
private WebElement searchInput;
@FindBy(id = "search-button")
private WebElement searchButton;
@FindBy(className = "product-item")
private WebElement firstProduct;
@FindBy(id = "add-to-cart")
private WebElement addToCartButton;
@FindBy(className = "cart-count")
private WebElement cartCount;
public HomePage(WebDriver driver) {
this.driver = driver;
this.wait = new WebDriverWait(driver, Duration.ofSeconds(10));
PageFactory.initElements(driver, this);
}
public void searchProduct(String productName) {
wait.until(ExpectedConditions.visibilityOf(searchInput));
searchInput.clear();
searchInput.sendKeys(productName);
searchButton.click();
}
public void selectFirstProduct() {
wait.until(ExpectedConditions.elementToBeClickable(firstProduct));
firstProduct.click();
}
public void addProductToCart() {
wait.until(ExpectedConditions.elementToBeClickable(addToCartButton));
addToCartButton.click();
}
public String getCartCount() {
wait.until(ExpectedConditions.visibilityOf(cartCount));
return cartCount.getText();
}
}
// Test Class
public class EcommerceSeleniumTest {
private WebDriver driver;
private HomePage homePage;
@BeforeClass
public void setupClass() {
WebDriverManager.chromedriver().setup();
}
@BeforeMethod
public void setup() {
ChromeOptions options = new ChromeOptions();
options.addArguments("--start-maximized");
options.addArguments("--disable-notifications");
driver = new ChromeDriver(options);
driver.get("https://example-store.com");
homePage = new HomePage(driver);
}
@AfterMethod
public void teardown() {
if (driver != null) {
driver.quit();
}
}
@Test
public void testProductSearchAndAddToCart() {
// Search for product
homePage.searchProduct("laptop");
// Select first product
homePage.selectFirstProduct();
// Add to cart
homePage.addProductToCart();
// Verify cart count
String cartCount = homePage.getCartCount();
assertEquals("1", cartCount);
}
@Test(dataProvider = "searchTerms")
public void testMultipleProductSearches(String searchTerm, int expectedMinResults) {
homePage.searchProduct(searchTerm);
List products = driver.findElements(By.className("product-item"));
assertTrue(products.size() >= expectedMinResults,
"Expected at least " + expectedMinResults + " products for " + searchTerm);
}
@DataProvider(name = "searchTerms")
public Object[][] searchTermsProvider() {
return new Object[][] {
{"laptop", 5},
{"smartphone", 3},
{"headphones", 2}
};
}
@Test
public void testCrossBrowserCompatibility() {
// Test in different browsers
testInBrowser("chrome");
testInBrowser("firefox");
testInBrowser("edge");
}
private void testInBrowser(String browserName) {
WebDriver testDriver = createDriver(browserName);
try {
testDriver.get("https://example-store.com");
// Basic functionality test
WebElement searchInput = testDriver.findElement(By.id("search-input"));
searchInput.sendKeys("test");
WebElement searchButton = testDriver.findElement(By.id("search-button"));
searchButton.click();
// Verify search works
WebDriverWait wait = new WebDriverWait(testDriver, Duration.ofSeconds(10));
wait.until(ExpectedConditions.presenceOfElementLocated(By.className("search-results")));
assertTrue(testDriver.getCurrentUrl().contains("search"),
"Search functionality should work in " + browserName);
} finally {
testDriver.quit();
}
}
private WebDriver createDriver(String browserName) {
switch (browserName.toLowerCase()) {
case "firefox":
WebDriverManager.firefoxdriver().setup();
return new FirefoxDriver();
case "edge":
WebDriverManager.edgedriver().setup();
return new EdgeDriver();
default:
WebDriverManager.chromedriver().setup();
return new ChromeDriver();
}
}
}
# Installation: pip install selenium webdriver-manager pytest
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager
import pytest
# Page Object Model
class HomePage:
def __init__(self, driver):
self.driver = driver
self.wait = WebDriverWait(driver, 10)
# Locators
self.search_input = (By.ID, "search-input")
self.search_button = (By.ID, "search-button")
self.first_product = (By.CSS_SELECTOR, ".product-item:first-child")
self.add_to_cart_button = (By.ID, "add-to-cart")
self.cart_count = (By.CLASS_NAME, "cart-count")
def search_product(self, product_name):
search_field = self.wait.until(EC.visibility_of_element_located(self.search_input))
search_field.clear()
search_field.send_keys(product_name)
search_btn = self.driver.find_element(*self.search_button)
search_btn.click()
def select_first_product(self):
product = self.wait.until(EC.element_to_be_clickable(self.first_product))
product.click()
def add_product_to_cart(self):
add_btn = self.wait.until(EC.element_to_be_clickable(self.add_to_cart_button))
add_btn.click()
def get_cart_count(self):
cart_element = self.wait.until(EC.visibility_of_element_located(self.cart_count))
return cart_element.text
# Test Configuration
@pytest.fixture
def driver():
# Setup Chrome options
chrome_options = Options()
chrome_options.add_argument("--start-maximized")
chrome_options.add_argument("--disable-notifications")
# Setup driver
service = Service(ChromeDriverManager().install())
driver = webdriver.Chrome(service=service, options=chrome_options)
yield driver
driver.quit()
@pytest.fixture
def home_page(driver):
driver.get("https://example-store.com")
return HomePage(driver)
# Test Cases
class TestEcommerceSelenium:
def test_product_search_and_add_to_cart(self, home_page):
"""Test product search and add to cart functionality"""
# Search for product
home_page.search_product("laptop")
# Select first product
home_page.select_first_product()
# Add to cart
home_page.add_product_to_cart()
# Verify cart count
cart_count = home_page.get_cart_count()
assert cart_count == "1"
@pytest.mark.parametrize("search_term,expected_min_results", [
("laptop", 5),
("smartphone", 3),
("headphones", 2)
])
def test_multiple_product_searches(self, driver, search_term, expected_min_results):
"""Test searches return expected minimum results"""
driver.get("https://example-store.com")
home_page = HomePage(driver)
home_page.search_product(search_term)
# Wait for results and count products
WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.CLASS_NAME, "search-results"))
)
products = driver.find_elements(By.CLASS_NAME, "product-item")
assert len(products) >= expected_min_results, \
f"Expected at least {expected_min_results} products for {search_term}"
def test_cross_browser_compatibility(self):
"""Test functionality across different browsers"""
browsers = ["chrome", "firefox", "edge"]
for browser_name in browsers:
driver = self.create_driver(browser_name)
try:
driver.get("https://example-store.com")
# Basic functionality test
search_input = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, "search-input"))
)
search_input.send_keys("test")
search_button = driver.find_element(By.ID, "search-button")
search_button.click()
# Verify search works
WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.CLASS_NAME, "search-results"))
)
assert "search" in driver.current_url, \
f"Search functionality should work in {browser_name}"
finally:
driver.quit()
def create_driver(self, browser_name):
"""Create driver for specified browser"""
if browser_name.lower() == "firefox":
from webdriver_manager.firefox import GeckoDriverManager
from selenium.webdriver.firefox.service import Service as FirefoxService
service = FirefoxService(GeckoDriverManager().install())
return webdriver.Firefox(service=service)
elif browser_name.lower() == "edge":
from webdriver_manager.microsoft import EdgeChromiumDriverManager
from selenium.webdriver.edge.service import Service as EdgeService
service = EdgeService(EdgeChromiumDriverManager().install())
return webdriver.Edge(service=service)
else: # Default to Chrome
service = Service(ChromeDriverManager().install())
return webdriver.Chrome(service=service)
def test_mobile_responsive_design(self, driver):
"""Test mobile responsive design"""
# Set mobile viewport
driver.set_window_size(375, 667)
driver.get("https://example-store.com")
# Test mobile-specific elements
mobile_menu = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.CLASS_NAME, "mobile-menu"))
)
assert mobile_menu.is_displayed(), "Mobile menu should be visible on mobile viewport"
# Test that desktop nav is hidden
desktop_nav = driver.find_elements(By.CLASS_NAME, "desktop-nav")
if desktop_nav:
assert not desktop_nav[0].is_displayed(), "Desktop nav should be hidden on mobile"
def test_performance_timing(self, driver):
"""Test page load performance"""
driver.get("https://example-store.com")
# Get navigation timing
navigation_start = driver.execute_script("return window.performance.timing.navigationStart")
load_event_end = driver.execute_script("return window.performance.timing.loadEventEnd")
# Calculate page load time
page_load_time = load_event_end - navigation_start
assert page_load_time < 5000, f"Page load time ({page_load_time}ms) should be under 5 seconds"
# Configuration file: pytest.ini
"""
[tool:pytest]
testpaths = tests
python_files = test_*.py
python_classes = Test*
python_functions = test_*
addopts =
--tb=short
--strict-markers
--html=reports/report.html
--self-contained-html
markers =
slow: marks tests as slow
smoke: marks tests as smoke tests
regression: marks tests as regression tests
"""
// NuGet packages:
// Selenium.WebDriver
// Selenium.WebDriver.ChromeDriver
// NUnit
// WebDriverManager
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium.Support.PageObjects;
using NUnit.Framework;
using WebDriverManager;
using WebDriverManager.DriverConfigs.Impl;
// Page Object Model
public class HomePage
{
private IWebDriver driver;
private WebDriverWait wait;
[FindsBy(How = How.Id, Using = "search-input")]
private IWebElement searchInput;
[FindsBy(How = How.Id, Using = "search-button")]
private IWebElement searchButton;
[FindsBy(How = How.CssSelector, Using = ".product-item:first-child")]
private IWebElement firstProduct;
[FindsBy(How = How.Id, Using = "add-to-cart")]
private IWebElement addToCartButton;
[FindsBy(How = How.ClassName, Using = "cart-count")]
private IWebElement cartCount;
public HomePage(IWebDriver driver)
{
this.driver = driver;
this.wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
PageFactory.InitElements(driver, this);
}
public void SearchProduct(string productName)
{
wait.Until(ExpectedConditions.ElementIsVisible(By.Id("search-input")));
searchInput.Clear();
searchInput.SendKeys(productName);
searchButton.Click();
}
public void SelectFirstProduct()
{
wait.Until(ExpectedConditions.ElementToBeClickable(firstProduct));
firstProduct.Click();
}
public void AddProductToCart()
{
wait.Until(ExpectedConditions.ElementToBeClickable(addToCartButton));
addToCartButton.Click();
}
public string GetCartCount()
{
wait.Until(ExpectedConditions.ElementIsVisible(By.ClassName("cart-count")));
return cartCount.Text;
}
}
// Test Class
[TestFixture]
public class EcommerceSeleniumTests
{
private IWebDriver driver;
private HomePage homePage;
[OneTimeSetUp]
public void OneTimeSetup()
{
new DriverManager().SetUpDriver(new ChromeConfig());
}
[SetUp]
public void Setup()
{
var options = new ChromeOptions();
options.AddArguments("--start-maximized", "--disable-notifications");
driver = new ChromeDriver(options);
driver.Navigate().GoToUrl("https://example-store.com");
homePage = new HomePage(driver);
}
[TearDown]
public void Teardown()
{
driver?.Quit();
}
[Test]
public void TestProductSearchAndAddToCart()
{
// Search for product
homePage.SearchProduct("laptop");
// Select first product
homePage.SelectFirstProduct();
// Add to cart
homePage.AddProductToCart();
// Verify cart count
string cartCount = homePage.GetCartCount();
Assert.AreEqual("1", cartCount);
}
[TestCase("laptop", 5)]
[TestCase("smartphone", 3)]
[TestCase("headphones", 2)]
public void TestMultipleProductSearches(string searchTerm, int expectedMinResults)
{
homePage.SearchProduct(searchTerm);
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.ClassName("product-item")));
var products = driver.FindElements(By.ClassName("product-item"));
Assert.GreaterOrEqual(products.Count, expectedMinResults,
$"Expected at least {expectedMinResults} products for {searchTerm}");
}
[Test]
public void TestCrossBrowserCompatibility()
{
var browsers = new[] { "chrome", "firefox", "edge" };
foreach (var browserName in browsers)
{
using (var testDriver = CreateDriver(browserName))
{
testDriver.Navigate().GoToUrl("https://example-store.com");
// Basic functionality test
var searchInput = new WebDriverWait(testDriver, TimeSpan.FromSeconds(10))
.Until(ExpectedConditions.ElementIsVisible(By.Id("search-input")));
searchInput.SendKeys("test");
var searchButton = testDriver.FindElement(By.Id("search-button"));
searchButton.Click();
// Verify search works
new WebDriverWait(testDriver, TimeSpan.FromSeconds(10))
.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.ClassName("search-results")));
Assert.That(testDriver.Url, Does.Contain("search"),
$"Search functionality should work in {browserName}");
}
}
}
private IWebDriver CreateDriver(string browserName)
{
switch (browserName.ToLower())
{
case "firefox":
new DriverManager().SetUpDriver(new FirefoxConfig());
return new FirefoxDriver();
case "edge":
new DriverManager().SetUpDriver(new EdgeConfig());
return new EdgeDriver();
default:
return new ChromeDriver();
}
}
[Test]
public void TestMobileResponsiveDesign()
{
// Set mobile viewport
driver.Manage().Window.Size = new System.Drawing.Size(375, 667);
driver.Navigate().GoToUrl("https://example-store.com");
// Test mobile-specific elements
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
var mobileMenu = wait.Until(ExpectedConditions.ElementIsVisible(By.ClassName("mobile-menu")));
Assert.IsTrue(mobileMenu.Displayed, "Mobile menu should be visible on mobile viewport");
// Test that desktop nav is hidden
var desktopNavs = driver.FindElements(By.ClassName("desktop-nav"));
if (desktopNavs.Count > 0)
{
Assert.IsFalse(desktopNavs[0].Displayed, "Desktop nav should be hidden on mobile");
}
}
[Test]
public void TestPageLoadPerformance()
{
driver.Navigate().GoToUrl("https://example-store.com");
// Get navigation timing
var navigationStart = (long)((IJavaScriptExecutor)driver)
.ExecuteScript("return window.performance.timing.navigationStart");
var loadEventEnd = (long)((IJavaScriptExecutor)driver)
.ExecuteScript("return window.performance.timing.loadEventEnd");
// Calculate page load time
var pageLoadTime = loadEventEnd - navigationStart;
Assert.Less(pageLoadTime, 5000,
$"Page load time ({pageLoadTime}ms) should be under 5 seconds");
}
}
API Testing Tools
Essential tools for testing REST APIs, GraphQL endpoints, and web services:
Postman
API Development Platform
Comprehensive API testing platform with GUI, collections, environments, and team collaboration features.
GUI Interface
Collections
Environments
Team collaboration
REST Assured
Java API Testing
Java DSL for easy testing of REST services with powerful validation and assertion capabilities.
Java DSL
BDD style
JSON/XML validation
Authentication
Java
Requests + Pytest
Python API Testing
Python's requests library combined with pytest for simple yet powerful API testing automation.
Simple syntax
Rich assertions
Fixtures
Parametrization
Python
Newman
CLI API Testing
Command-line companion for Postman, enabling automated API testing in CI/CD pipelines.
CLI execution
CI/CD friendly
Multiple reporters
Environment support
Tool Selection Guidelines
Choose the right testing tools based on your project requirements and constraints:
โ Consider When Selecting Tools
- Team's existing skill set and experience
- Project technology stack and architecture
- CI/CD pipeline integration requirements
- Budget constraints and licensing costs
- Community support and documentation quality
- Long-term maintenance and updates
- Cross-platform compatibility needs
- Reporting and analytics requirements
โ Common Selection Mistakes
- Choosing tools based solely on popularity
- Ignoring learning curve and training costs
- Not considering tool integration capabilities
- Overlooking scalability and performance limits
- Failing to evaluate vendor lock-in risks
- Not testing tools with actual project scenarios
- Ignoring team collaboration features
- Underestimating maintenance overhead
Best Practices for Tool Implementation
- Start Small: Begin with a pilot project to evaluate tools before full adoption
- Standardize Approaches: Establish consistent patterns and practices across teams
- Invest in Training: Ensure team members are properly trained on selected tools
- Create Templates: Develop reusable templates and frameworks for common scenarios
- Implement Gradually: Phase in new tools gradually to minimize disruption
- Monitor and Measure: Track tool effectiveness and ROI over time
- Stay Updated: Keep tools updated and evaluate new options regularly
- Document Everything: Maintain comprehensive documentation for tool usage and configurations
- Plan for Migration: Have strategies for migrating between tools when necessary
- Foster Community: Encourage knowledge sharing and best practice development within teams