File tree Expand file tree Collapse file tree
src/test/java/io/github/mfaisalkhatri/tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package io .github .mfaisalkhatri .tests ;
2+
3+ import com .microsoft .playwright .*;
4+ import org .testng .annotations .AfterClass ;
5+ import org .testng .annotations .BeforeClass ;
6+ import org .testng .annotations .Test ;
7+
8+ import static com .microsoft .playwright .assertions .PlaywrightAssertions .assertThat ;
9+
10+ public class RadioButtonTests {
11+
12+ private Playwright playwright ;
13+ private Page page ;
14+
15+
16+ @ BeforeClass
17+ public void setup () {
18+ this .playwright = Playwright .create ();
19+ final Browser browser = playwright .chromium ().launch (new BrowserType .LaunchOptions ().setHeadless (false ).setChannel ("chrome" ));
20+ this .page = browser .newPage ();
21+ }
22+
23+ @ Test
24+ public void testRadioButtonIsChecked () {
25+ page .navigate ("https://www.lambdatest.com/selenium-playground/radiobutton-demo" );
26+ Locator maleRadioBtn = page .getByLabel ("Male" ).first ();
27+ maleRadioBtn .click ();
28+ assertThat (maleRadioBtn ).isChecked ();
29+ }
30+
31+ @ Test
32+ public void testRadioButtonIsNotChecked () {
33+ page .navigate ("https://www.lambdatest.com/selenium-playground/radiobutton-demo" );
34+ Locator femaleRadioBtn = page .getByLabel ("Female" ).first ();
35+ femaleRadioBtn .click ();
36+ assertThat (femaleRadioBtn ).isChecked ();
37+
38+ Locator maleRadioBtn = page .getByLabel ("Male" ).first ();
39+ assertThat (maleRadioBtn ).not ().isChecked ();
40+ }
41+
42+
43+ @ AfterClass
44+ public void tearDown () {
45+ this .page .close ();
46+ this .playwright .close ();
47+ }
48+
49+ }
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
3+ <suite name =" Playwright demo test suite " >
4+ <test name =" Radio buttons demo on Chrome" >
5+ <classes >
6+ <class name =" io.github.mfaisalkhatri.tests.RadioButtonTests" >
7+ <methods >
8+ <include name =" testRadioButtonIsChecked" />
9+ <include name =" testRadioButtonIsNotChecked" />
10+ </methods >
11+ </class >
12+ </classes >
13+ </test >
14+ </suite >
You can’t perform that action at this time.
0 commit comments