Test Overview
This test opens a web page, clicks a button, and verifies the result. It uses Allure annotations to add detailed reporting information.
This test opens a web page, clicks a button, and verifies the result. It uses Allure annotations to add detailed reporting information.
import io.qameta.allure.Description; import io.qameta.allure.Step; import io.qameta.allure.junit4.DisplayName; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; public class AllureReportingTest { private WebDriver driver; @Before public void setUp() { driver = new ChromeDriver(); } @Test @DisplayName("Verify button click changes text") @Description("Open the page, click the button, and check if the text changes as expected.") public void testButtonClickChangesText() { openPage("https://example.com/buttonpage"); clickButton(By.id("change-text-btn")); verifyText(By.id("text-element"), "Text changed!"); } @Step("Open page {url}") public void openPage(String url) { driver.get(url); } @Step("Click button located by {by}") public void clickButton(By by) { WebElement button = driver.findElement(by); button.click(); } @Step("Verify element located by {by} has text '{expectedText}'") public void verifyText(By by, String expectedText) { WebElement element = driver.findElement(by); String actualText = element.getText(); Assert.assertEquals(expectedText, actualText); } @After public void tearDown() { if (driver != null) { driver.quit(); } } }
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | JUnit test runner initializes the test class | - | PASS |
| 2 | Browser opens ChromeDriver | Chrome browser window opens, ready for commands | - | PASS |
| 3 | Navigates to https://example.com/buttonpage | Browser loads the page with a button and a text element | - | PASS |
| 4 | Finds button element by id 'change-text-btn' | Button element is present and visible on the page | - | PASS |
| 5 | Clicks the button | Button click triggers text change on the page | - | PASS |
| 6 | Finds text element by id 'text-element' | Text element is present on the page | - | PASS |
| 7 | Checks if text element's text equals 'Text changed!' | Text element's text is 'Text changed!' | Assert.assertEquals("Text changed!", actualText) | PASS |
| 8 | Test ends and browser closes | Browser window closes, test resources cleaned | - | PASS |