Skip to main content

Web Test Automation with SHAFT

This guide covers everything you need to start automating web browser tests using SHAFT and Selenium WebDriver.

What You Get Out of the Box

  • Auto driver management — Chrome, Firefox, Edge, and Safari. No manual driver downloads.
  • Smart waits — Automatic element synchronization. No Thread.sleep() or WebDriverWait.
  • Fluent API — Chain browser, element, and validation actions in a single statement.
  • Allure reports — Screenshots on failure, execution video, and detailed step logs.
  • Parallel execution — Run tests concurrently with thread-safe drivers.

Choose Your Test Runner

TestNG Setup

Best for: Teams needing flexible test configuration, built-in parallel execution, and data providers.

Project Structure

src/
├── main/resources/properties/
│ └── custom.properties # SHAFT configuration
└── test/java/com/example/
├── pages/ # Page Object classes
│ └── SearchPage.java
└── tests/ # TestNG test classes
└── SearchTest.java

Example: Search Test with Page Object Model

Page Object — SearchPage.java:

public class SearchPage {
private final SHAFT.GUI.WebDriver driver;

// Locators
private final By searchBox = By.name("q");
private final By searchButton = By.cssSelector("button[type='submit']");

public SearchPage(SHAFT.GUI.WebDriver driver) {
this.driver = driver;
}

public SearchPage open() {
driver.browser().navigateToURL("https://duckduckgo.com/");
return this;
}

public SearchPage search(String query) {
driver.element().type(searchBox, query)
.and().element().click(searchButton);
return this;
}

public SearchPage verifyResultsContain(String expected) {
driver.assertThat().browser().title().contains(expected).perform();
return this;
}
}

Test Class — SearchTest.java:

import org.testng.annotations.*;

public class SearchTest {
private SHAFT.GUI.WebDriver driver;

@Test(description = "Verify search returns relevant results")
public void searchReturnsResults() {
new SearchPage(driver)
.open()
.search("SHAFT Engine test automation")
.verifyResultsContain("SHAFT");
}

@BeforeMethod
public void setUp() {
driver = new SHAFT.GUI.WebDriver();
}

@AfterMethod
public void tearDown() {
driver.quit();
}
}

Run Tests

# Run via Maven
mvn test

# Generate and open the Allure report
mvn allure:serve

Essential Properties for Web Testing

Configure browser behavior in src/main/resources/properties/custom.properties:

# Browser — chrome | firefox | microsoftedge | safari
targetBrowserName=chrome

# Run headless (no visible browser window)
headlessExecution=false

# Timeouts (seconds)
browserNavigationTimeout=60
elementIdentificationTimeout=5

# Screenshots & reporting
screenshotParams_whenToTakeAScreenshot=ValidationPointsOnly
createAnimatedGif=true

See the full properties reference →

Cross-Browser Testing

Run the same tests on different browsers without changing code:

# Run on Firefox
mvn test -DtargetBrowserName=firefox

# Run on Edge
mvn test -DtargetBrowserName=microsoftedge

# Run headless
mvn test -DheadlessExecution=true

Cloud Execution

Execute tests on BrowserStack or LambdaTest by setting the execution address:

executionAddress=https://hub.browserstack.com/wd/hub

See the Integrations page → for full cloud setup instructions.