-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestScenario2.java
More file actions
57 lines (41 loc) · 1.77 KB
/
Copy pathTestScenario2.java
File metadata and controls
57 lines (41 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import com.microsoft.playwright.*;
import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class TestScenario2 {
@Test
public void validateSliderValue() {
Playwright playwright = Playwright.create();
Browser browser = playwright.chromium().launch(
new BrowserType.LaunchOptions().setHeadless(false));
BrowserContext context = browser.newContext();
Page page = context.newPage();
// Step 1: Open Selenium Playground
page.navigate("https://www.testmuai.com/selenium-playground/");
// Click "Drag & Drop Sliders"
page.getByText("Drag & Drop Sliders").click();
// Step 2: Locate the slider with default value 15
Locator slider = page.locator("input[value='15']").first();
// Move the slider to 95
page.evaluate(
"(element) => element.value = 95",
slider.elementHandle()
);
// Trigger input/change events so the UI updates
page.evaluate(
"(element) => {" +
"element.dispatchEvent(new Event('input', { bubbles: true }));" +
"element.dispatchEvent(new Event('change', { bubbles: true }));" +
"}",
slider.elementHandle()
);
// Validate the displayed range value
Locator rangeValue = page.locator("#rangeSuccess");
assertEquals("95", rangeValue.textContent().trim());
System.out.println("Slider successfully moved to 95.");
browser.close();
playwright.close();
}
}