2222package io .testerra .report .test .pages .report .sideBarPages ;
2323
2424import eu .tsystems .mms .tic .testframework .pageobjects .Check ;
25+ import eu .tsystems .mms .tic .testframework .pageobjects .PreparedLocator ;
2526import eu .tsystems .mms .tic .testframework .pageobjects .UiElement ;
2627import eu .tsystems .mms .tic .testframework .report .Status ;
2728import io .testerra .report .test .pages .AbstractReportPage ;
2829import io .testerra .report .test .pages .ReportSidebarPageType ;
2930import io .testerra .report .test .pages .report .methodReport .AbstractReportMethodPage ;
30- import io .testerra .report .test .pages .report .methodReport .ReportDependenciesTab ;
3131import io .testerra .report .test .pages .report .methodReport .ReportDetailsTab ;
32- import io .testerra .report .test .pages .report .methodReport .ReportSessionsTab ;
3332import io .testerra .report .test .pages .report .methodReport .ReportStepsTab ;
3433import org .openqa .selenium .By ;
3534import org .openqa .selenium .WebDriver ;
@@ -54,7 +53,7 @@ public class ReportTestsPage extends AbstractReportPage {
5453 private final String tableRowsLocator = "//tbody//tr" ;
5554 private final UiElement tableRows = pageContent .find (By .xpath (tableRowsLocator ));
5655
57- private final String methodLinkLocator = "//tbody//tr//td//a[ text()='%s']" ;
56+ PreparedLocator preparedMethodLinkLocator = LOCATE . prepare ( "//a[contains(@route-href, 'method') and text()='%s']" ) ;
5857 private final UiElement tableHead = pageContent .find (By .xpath (".//thead" ));
5958
6059 public void checkPriorityMessagesPreviewForTest (String methodName , String [] priorityMessages ) {
@@ -93,20 +92,16 @@ public int index() {
9392 }
9493 }
9594
96-
9795 public ReportTestsPage (WebDriver driver ) {
9896 super (driver );
9997 }
10098
101- public List <UiElement > getColumnWithoutHead (int columnNumber ) {
99+ private List <UiElement > getColumnWithoutHead (final int columnNumber ) {
102100 List <UiElement > column = new ArrayList <>();
103- for (UiElement row : tableRows .list ().stream ().collect (Collectors .toList ())) {
104- column .add (row .find (By .xpath ("//td" )).list ().stream ().collect (Collectors .toList ()).get (columnNumber ));
105- }
101+ tableRows .list ().forEach (row -> column .add (row .find (By .xpath ("//td[" + (columnNumber + 1 ) + "]" ))));
106102 return column ;
107103 }
108104
109-
110105 public List <UiElement > getColumnWithoutHead (TestsTableEntry tableEntry ) {
111106 return getColumnWithoutHead (tableEntry .index ());
112107 }
@@ -137,13 +132,19 @@ public void pageLoaded() {
137132 verifyReportPage (ReportSidebarPageType .TESTS );
138133 }
139134
140-
141- public void assertMethodColumnContainsCorrectMethods (String filter ) {
135+ public void assertMethodColumnMatchesFilter (String filter ) {
142136 getColumnWithoutHead (TestsTableEntry .METHOD )
143137 .forEach (uiElement -> uiElement .expect ().text ().contains (filter ).is (true ,
144138 String .format ("Every found method [%s] should contain: %s" , uiElement .expect ().text ().getActual (), filter )));
145139 }
146140
141+ public void assertMethodColumnContainsCorrectMethods (List <String > methodNames ) {
142+ getColumnWithoutHead (TestsTableEntry .METHOD ).forEach (uiElement -> {
143+ String methodFromTable = uiElement .find (By .tagName ("a" )).waitFor ().text ().getActual ();
144+ Assert .assertTrue (methodNames .contains (methodFromTable ), String .format ("Testmethod %s should not shown with the given filter." , methodFromTable ));
145+ });
146+ }
147+
147148 public void assertClassColumnContainsCorrectClasses (String expectedClass ) {
148149 getColumnWithoutHead (TestsTableEntry .CLASS )
149150 .forEach (uiElement -> uiElement .expect ().text ().is (expectedClass , String .format (
@@ -235,15 +236,6 @@ public ReportStepsTab navigateToStepsTab(final String methodName, final Status s
235236 return createPage (ReportStepsTab .class );
236237 }
237238
238- public ReportSessionsTab navigateToSessionsTab (final String methodName , final Status status ) {
239-
240- final String methodNameLinkLocator = tableRowsLocator .concat ("[.//a[text()= '" + status .title + "']]//a[text()= '" + methodName + "']" );
241- final UiElement methodNameLink = find (By .xpath (methodNameLinkLocator ));
242- methodNameLink .click ();
243-
244- return createPage (ReportSessionsTab .class );
245- }
246-
247239 public ReportDetailsTab navigateToDetailsTab (final String methodName , final Status status ) {
248240
249241 final String methodNameLinkLocator = tableRowsLocator .concat ("[.//a[text()= '" + status .title + "']]//a[text()= '" + methodName + "']" );
@@ -253,54 +245,27 @@ public ReportDetailsTab navigateToDetailsTab(final String methodName, final Stat
253245 return createPage (ReportDetailsTab .class );
254246 }
255247
256- public ReportDependenciesTab navigateToDependenciesTab (final String methodName , final Status status ) {
257-
258- final String methodNameLinkLocator = tableRowsLocator .concat ("[.//a[text()= '" + status .title + "']]//a[text()= '" + methodName + "']" );
259- final UiElement methodNameLink = find (By .xpath (methodNameLinkLocator ));
260- methodNameLink .click ();
261-
262- return createPage (ReportDependenciesTab .class );
263- }
264-
265248 public <T extends AbstractReportMethodPage > T navigateToMethodDetails (final Class <T > reportPageClass , String methodName ) {
266- UiElement subElement = pageContent .find (By . xpath ( String . format ( methodLinkLocator , methodName ) ));
249+ UiElement subElement = pageContent .find (this . preparedMethodLinkLocator . with ( methodName ));
267250 subElement .click ();
268251
269252 return createPage (reportPageClass );
270253 }
271254
272255 public ReportStepsTab navigateToStepsTab (String methodName ) {
273-
274- UiElement subElement = pageContent .find (By .xpath (String .format (methodLinkLocator , methodName )));
256+ UiElement subElement = pageContent .find (this .preparedMethodLinkLocator .with (methodName ));
275257 subElement .click ();
276258
277259 return createPage (ReportStepsTab .class );
278260 }
279261
280- public ReportSessionsTab navigateToSessionsTab (String methodName ) {
281-
282- UiElement subElement = pageContent .find (By .xpath (String .format (methodLinkLocator , methodName )));
283- subElement .click ();
284-
285- return createPage (ReportSessionsTab .class );
286- }
287-
288262 public ReportDetailsTab navigateToDetailsTab (String methodName ) {
289-
290- UiElement subElement = pageContent .find (By .xpath (String .format (methodLinkLocator , methodName )));
263+ UiElement subElement = pageContent .find (this .preparedMethodLinkLocator .with (methodName ));
291264 subElement .click ();
292265
293266 return createPage (ReportDetailsTab .class );
294267 }
295268
296- public ReportDependenciesTab navigateToDependenciesTab (String methodName ) {
297-
298- UiElement subElement = pageContent .find (By .xpath (String .format (methodLinkLocator , methodName )));
299- subElement .click ();
300-
301- return createPage (ReportDependenciesTab .class );
302- }
303-
304269 public ReportTestsPage clickConfigurationMethodsSwitch () {
305270 configurationMethodsSwitch .click ();
306271 return createPage (ReportTestsPage .class );
@@ -337,4 +302,4 @@ public ReportTestsPage selectTestStatus(Status status) {
337302 public ReportTestsPage selectClassName (String label ) {
338303 return selectDropBoxElement (this .testClassSelect , label , ReportTestsPage .class );
339304 }
340- }
305+ }
0 commit comments