11package io .github .mfaisalkhatri .tests ;
22
33import static com .microsoft .playwright .assertions .PlaywrightAssertions .assertThat ;
4- import static org .testng .Assert .assertEquals ;
54
65import com .microsoft .playwright .Browser ;
76import com .microsoft .playwright .BrowserType ;
87import com .microsoft .playwright .Page ;
98import com .microsoft .playwright .Playwright ;
9+ import com .microsoft .playwright .options .AriaRole ;
1010import io .github .mfaisalkhatri .pages .theinternet .DataTablePage ;
11- import org .testng .annotations .AfterMethod ;
12- import org .testng .annotations .BeforeMethod ;
11+ import org .testng .annotations .AfterTest ;
12+ import org .testng .annotations .BeforeTest ;
1313import org .testng .annotations .Test ;
1414
1515public class DataTableTests {
@@ -18,7 +18,7 @@ public class DataTableTests {
1818 private Page page ;
1919 private DataTablePage dataTablePage ;
2020
21- @ BeforeMethod
21+ @ BeforeTest
2222 public void setup () {
2323 this .playwright = Playwright .create ();
2424 final Browser browser = this .playwright .chromium ()
@@ -29,12 +29,20 @@ public void setup () {
2929 }
3030
3131 @ Test
32- public void testRowNumber () {
32+ public void testRowNumbers () {
3333 this .page .navigate ("https://the-internet.herokuapp.com/tables" );
3434 assertThat (this .dataTablePage .getTotalRowsInTable (this .dataTablePage .tableOne ())).hasCount (4 );
3535 assertThat (this .dataTablePage .getTotalRowsInTable (this .dataTablePage .tableTwo ())).hasCount (4 );
3636 }
3737
38+ @ Test
39+ public void testColumnNumbers () {
40+ this .page .navigate ("https://the-internet.herokuapp.com/tables" );
41+ assertThat (this .dataTablePage .getColumnHeadersOfTable (this .dataTablePage .tableOne ())).hasCount (6 );
42+ assertThat (this .dataTablePage .getColumnHeadersOfTable (this .dataTablePage .tableTwo ())).hasCount (6 );
43+
44+ }
45+
3846 @ Test
3947 public void testPrintTableRecords () {
4048 this .page .navigate ("https://the-internet.herokuapp.com/tables" );
@@ -54,12 +62,25 @@ public void testTableOneColumnHeaders () {
5462 expectedColumnHeaders );
5563 }
5664
65+ @ Test
66+ public void testTableData () {
67+ this .page .navigate ("https://the-internet.herokuapp.com/tables" );
68+ assertThat (this .dataTablePage .getCell (this .dataTablePage .tableOne (), 0 , 0 )).hasText ("Smith" );
69+ assertThat (this .dataTablePage .getCell (this .dataTablePage .tableOne (), 0 , 1 )).hasText ("John" );
70+ assertThat (this .dataTablePage .getCell (this .dataTablePage .tableOne (), 0 , 2 )).hasText ("jsmith@gmail.com" );
71+ assertThat (this .dataTablePage .getCell (this .dataTablePage .tableOne (), 0 , 3 )).hasText ("$50.00" );
72+ assertThat (this .dataTablePage .getCell (this .dataTablePage .tableOne (), 0 , 4 )).hasText (
73+ "http://www.jsmith.com" );
74+ assertThat (this .dataTablePage .getCell (this .dataTablePage .tableOne (), 0 , 5 ).getByRole (AriaRole .LINK ).first ()).hasAttribute ("href" , "#edit" );
75+ assertThat (this .dataTablePage .getCell (this .dataTablePage .tableOne (), 0 , 5 ).getByRole (AriaRole .LINK ).nth (1 )).hasAttribute ("href" , "#delete" );
5776
77+ assertThat (this .dataTablePage .getCell (this .dataTablePage .tableTwo (), 3 , 1 )).hasText ("Tim" );
78+ assertThat (this .dataTablePage .getCell (this .dataTablePage .tableTwo (), 3 , 1 )).hasText ("Tim" );
79+ }
5880
59- @ AfterMethod
81+ @ AfterTest
6082 public void tearDown () {
6183 this .page .close ();
6284 this .playwright .close ();
6385 }
64-
65- }
86+ }
0 commit comments