Skip to main content

Web testing

Start here when you want one browser test that opens a page, performs an action, asserts a result, and leaves screenshot/report evidence.

import com.shaft.driver.SHAFT;
import org.openqa.selenium.By;
import org.testng.annotations.*;

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

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

@Test
public void search() {
driver.browser().navigateToURL("https://duckduckgo.com/")
.and().element().type(By.name("q"), "SHAFT Engine")
.and().assertThat().title().contains("DuckDuckGo");
}

@AfterMethod(alwaysRun = true)
public void closeBrowser() {
driver.quit();
}
}

Use the GUI actions reference for locators, browser actions, elements, waits, validations, accessibility, and network mocking. For browser traffic that should be captured and replayed later, see UI and API contract replay.

Run and inspect evidence

Run the generated or copied test from the project root:

mvn test

The report includes browser steps, screenshots, logs, and assertion results under allure-results and the generated Allure report under the project target output. If the browser never opens, check Java/Maven first, then browser installation, then targetBrowserName and headlessExecution.

Locator strategy

Use the most user-facing locator that is stable enough for the product:

  1. Prefer semantic locators such as visible text, labels, placeholders, and ARIA names.
  2. Use SHAFT.GUI.Locator when you need a precise composed locator.
  3. Keep waits and retries as evidence-backed safety nets, not as a substitute for a stable locator.
  4. Use SHAFT Heal only after deterministic locator strategies cannot survive expected UI changes.

Playwright backend

Use SHAFT.GUI.Playwright when a test should run through Microsoft Playwright instead of Selenium/Appium WebDriver. Both backends implement SHAFT.GUI.Driver, so setup code can choose the backend per test class.

private SHAFT.GUI.Driver driver;

@BeforeMethod
public void openBrowser() {
driver = new SHAFT.GUI.Playwright();
}

See the Playwright Backend reference for configuration, native Playwright access, tracing, and the WebDriver-to-Playwright mapping tree.