Test Overview
This test opens a webpage, finds a button, performs a double click on it, and verifies that the double click action triggered the expected change.
This test opens a webpage, finds a button, performs a double click on it, and verifies that the double click action triggered the expected change.
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.interactions.Actions; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; public class DoubleClickTest { WebDriver driver; @BeforeEach public void setUp() { driver = new ChromeDriver(); } @Test public void testDoubleClick() { driver.get("https://example.com/double-click-test"); WebElement button = driver.findElement(By.id("double-click-btn")); Actions actions = new Actions(driver); actions.doubleClick(button).perform(); WebElement message = driver.findElement(By.id("message")); String text = message.getText(); assertEquals("Double click successful", text); } @AfterEach public void tearDown() { driver.quit(); } }
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts and Chrome browser opens | Browser window is open with a blank page | - | PASS |
| 2 | Navigates to URL https://example.com/double-click-test | Page loads showing a button with id 'double-click-btn' and a message area with id 'message' | - | PASS |
| 3 | Finds the button element by id 'double-click-btn' | Button element is located and ready for interaction | - | PASS |
| 4 | Performs double click action on the button using Actions.doubleClick().perform() | Button receives double click event, triggering page logic | - | PASS |
| 5 | Finds the message element by id 'message' to verify result | Message element is located and contains updated text | Check that message text equals 'Double click successful' | PASS |
| 6 | Assertion verifies the message text is exactly 'Double click successful' | Text matches expected result | assertEquals("Double click successful", text) | PASS |
| 7 | Test ends and browser closes | Browser window is closed | - | PASS |