fix use of user credentials logic
[sdc.git] / ui-ci / src / main / java / org / openecomp / sdc / ci / tests / execute / setup / SetupCDTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.ci.tests.execute.setup;
22
23 import java.io.File;
24 import java.io.FileWriter;
25 import java.io.IOException;
26 import java.util.Arrays;
27 import java.util.Map;
28 import java.util.UUID;
29 import java.util.logging.FileHandler;
30 import java.util.logging.Handler;
31 import java.util.logging.LogManager;
32 import java.util.logging.Logger;
33
34 import org.json.simple.JSONObject;
35 import org.littleshoot.proxy.impl.ClientToProxyConnection;
36 import org.littleshoot.proxy.impl.ProxyToServerConnection;
37 import org.openecomp.sdc.be.model.User;
38 import org.openecomp.sdc.ci.tests.config.UserCredentialsFromFile;
39 import org.openecomp.sdc.ci.tests.execute.setup.ExtentTestManager;
40 import org.openecomp.sdc.ci.tests.api.SomeInterface;
41 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
42 import org.openecomp.sdc.ci.tests.datatypes.UserCredentials;
43 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
44 import org.openecomp.sdc.ci.tests.execute.sanity.OnboardingFlowsUI;
45 import org.openecomp.sdc.ci.tests.execute.setup.ExtentManager.suiteNameXml;
46 import org.openecomp.sdc.ci.tests.pages.HomePage;
47 import org.openecomp.sdc.ci.tests.run.StartTest;
48 import org.openecomp.sdc.ci.tests.utilities.FileHandling;
49 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
50 import org.openecomp.sdc.ci.tests.utilities.RestCDUtils;
51 import org.openecomp.sdc.ci.tests.utils.rest.AutomationUtils;
52 import org.openqa.selenium.By;
53 import org.openqa.selenium.JavascriptExecutor;
54 import org.openqa.selenium.WebDriver;
55 import org.openqa.selenium.WebElement;
56 import org.openqa.selenium.support.ui.ExpectedConditions;
57 import org.openqa.selenium.support.ui.WebDriverWait;
58 import org.slf4j.LoggerFactory;
59 import org.testng.Assert;
60 import org.testng.ITestContext;
61 import org.testng.ITestResult;
62 import org.testng.annotations.AfterMethod;
63 import org.testng.annotations.AfterSuite;
64 import org.testng.annotations.BeforeMethod;
65 import org.testng.annotations.BeforeSuite;
66 import org.testng.annotations.Optional;
67 import org.testng.annotations.Parameters;
68 import org.testng.annotations.Test;
69
70 import com.aventstack.extentreports.ExtentReports;
71 import com.aventstack.extentreports.ExtentTest;
72 import com.aventstack.extentreports.Status;
73
74 import ch.qos.logback.classic.Level;
75 import ch.qos.logback.classic.LoggerContext;
76 import groovyjarjarantlr.Utils;
77 import net.lightbody.bmp.BrowserMobProxyServer;
78 import net.lightbody.bmp.core.har.Har;
79
80 public abstract class SetupCDTest extends DriverFactory {
81         
82 //      private static final String RE_RUN = "ReRun - ";
83         private static final String RE_RUN = "<html><font color=\"red\">ReRun - </font></html>";
84         private static final String WEB_SEAL_PASSWORD = "123123a";
85
86         public SetupCDTest() {
87                 LoggerContext lc = (LoggerContext) LoggerFactory. getILoggerFactory();
88                 lc.getLogger("org.apache").setLevel(Level.INFO);            
89         }
90
91         /**************** CONSTANTS ****************/
92         private static final String CREDENTIALS_FILE = "credentials.yaml";
93         private static final String REPORT_FILE_NAME = "SDC_UI_Extent_Report.html";
94         protected static final String REPORT_FOLDER = "." + File.separator + "ExtentReport" + File.separator;
95         protected static final String SCREENSHOT_FOLDER = REPORT_FOLDER + "screenshots" + File.separator;
96         protected static final String HAR_FILES_FOLDER_NAME = "har_files";
97         protected static final String HAR_FILES_FOLDER = REPORT_FOLDER + HAR_FILES_FOLDER_NAME + File.separator;
98         
99
100         private static final String SHORT_CSV_REPORT_FILE_NAME = "ShortReport.csv";
101         private static final int NUM_OF_ATTEMPTS_TO_REFTRESH = 2;
102         
103
104         /**************** PRIVATES ****************/
105         private static String url;
106         private static boolean uiSimulator;
107         private static boolean localEnv = true;
108         private static OnboardCSVReport csvReport;
109         private final UserCredentialsFromFile credentialsIns = UserCredentialsFromFile.getInstance();
110         
111     protected static ITestContext myContext;
112         
113         
114         /**************** METHODS ****************/
115         public static ExtentTest getExtendTest() {
116                 SomeInterface testManager = new ExtentTestManager(); 
117                 return testManager.getTest();
118         }
119         public static WindowTest getWindowTest(){
120                 return WindowTestManager.getWindowMap();
121         }
122         
123         public OnboardCSVReport getCsvReport() {
124                 return csvReport;
125         }
126         
127         public static String getReportFolder() {
128                 return REPORT_FOLDER;
129         }
130         
131         public static String getScreenshotFolder() {
132                 return SCREENSHOT_FOLDER;
133         }
134         
135         public static String getHarFilesFolder() {
136                 return HAR_FILES_FOLDER;
137         }
138         
139         
140         protected abstract UserRoleEnum getRole();
141         
142         /**************** BEFORE ****************/
143
144         @BeforeSuite(alwaysRun = true)
145         public void setupBeforeSuite(ITestContext context) throws Exception {
146                 RestCDUtils.deleteOnDemand();
147                 myContext=context;
148                 setErrorConfigurationFile();
149                 setUrl();
150                 ExtentManager.initReporter(getReportFolder(), REPORT_FILE_NAME, context);               
151                 csvReport = new OnboardCSVReport(getReportFolder(), SHORT_CSV_REPORT_FILE_NAME);
152         }
153         
154         private static void setErrorConfigurationFile() {
155                 if (!System.getProperty("os.name").contains("Windows")){
156                         String errorConfigurationFilename = getConfig().getErrorConfigurationFile();
157                         errorConfigurationFilename = errorConfigurationFilename.substring(errorConfigurationFilename.lastIndexOf("/") + 1, errorConfigurationFilename.length());
158                         getConfig().setErrorConfigurationFile(FileHandling.getBasePath() + File.separator + "conf" + File.separator + errorConfigurationFilename);
159                         if (new File(getConfig().getErrorConfigurationFile()).exists()){
160                                 System.out.println("Found error-configuration.yaml in : " + getConfig().getErrorConfigurationFile());
161                         }
162                 }
163         }
164         
165         @BeforeMethod(alwaysRun = true )
166         public void setBrowserBeforeTest(java.lang.reflect.Method method, ITestContext context) throws Exception {
167                 
168                 boolean emptyDataProvider = method.getAnnotation(Test.class).dataProvider().isEmpty();
169                 String className = method.getDeclaringClass().getName();
170                 if (emptyDataProvider && !className.contains("ToscaValidationTest") ) {
171                         System.out.println("ExtentReport instance started from BeforeMethod...");
172                         String suiteName = ExtentManager.getSuiteName(context);
173                         if (suiteName.equals(suiteNameXml.TESTNG_FAILED_XML_NAME.getValue())) {
174                                 ExtentTestManager.startTest(RE_RUN + method.getName());
175                         }else{
176                                 ExtentTestManager.startTest(method.getName());
177                         }
178                 
179                         ExtentTestManager.assignCategory(this.getClass());
180                         setBrowserBeforeTest(getRole());
181                 } else {
182                         System.out.println("ExtentReport instance started from Test...");
183                 }
184                 
185                 getConfig().setWindowsDownloadDirectory(getWindowTest().getDownloadDirectory());
186                 
187                 if (getConfig().getCaptureTraffic()){
188                         try{
189                             MobProxy.getPoxyServer().newHar(method.getName() + ".har");
190                         } catch (Throwable e) {
191                                 e.printStackTrace();
192                         }
193                 }               
194         }
195         
196         /**************** AFTER ****************/
197         @AfterMethod(alwaysRun = true)
198         public void quitAfterTest(ITestResult result, ITestContext context) throws Exception {
199                 
200                 try{
201                         ReportAfterTestManager.report(result, context);
202                         GeneralUIUtils.closeErrorMessage();
203                 }
204                 finally{
205                         try {
206                                 if (getConfig().getCaptureTraffic()){
207                                         addTrafficFileToReport(result);                         
208                                 }
209                                 
210                                 if (result.getInstanceName().equals(OnboardingFlowsUI.class.getName())  && result.getStatus() == ITestResult.FAILURE){
211                                         System.out.println("Onboarding test failed, closign browser....");
212                                         getExtendTest().log(Status.INFO, "Onboarding test failed, closing browser....");
213                                         quitDriver();
214                                 }
215                                 else if (!getUser().getRole().toLowerCase().equals(UserRoleEnum.ADMIN.name().toLowerCase())){
216                                         boolean navigateToHomePageSuccess = HomePage.navigateToHomePage();
217                                         if (!navigateToHomePageSuccess){
218                                                 System.out.println("Navigating to homepage failed, reopening driver....");
219                                                 getExtendTest().log(Status.INFO, "Navigating to homepage failed, reopening driver....");
220                                                 quitDriver();
221                                         }
222                                 }
223                                 
224                         } catch (Exception e) {
225                                 e.printStackTrace();
226                                                 getExtendTest().log(Status.ERROR, "Exception:"+ e.toString());
227                         } 
228                         
229                         
230                         
231                 ExtentTestManager.endTest();
232                         String suiteName = ExtentManager.getSuiteName(context);
233 //                      write result to csv file
234                         if((!suiteName.equals(suiteNameXml.TESTNG_FAILED_XML_NAME.getValue())) && (result.getStatus() == ITestResult.SKIP)) {
235                                 addResultToCSV(result, context);
236                         }
237                         if(suiteName.equals(suiteNameXml.TESTNG_FAILED_XML_NAME.getValue()) && !(result.getStatus() == ITestResult.SUCCESS)) {
238                                 addResultToCSV(result, context);
239                         }
240 //              ExtentManager.closeReporter();
241                 FileHandling.cleanCurrentDownloadDir();
242         }
243
244         }
245         public void addResultToCSV(ITestResult result, ITestContext context) {
246 //              String suiteName = ExtentManager.getSuiteName(context);
247                 ExtentTest test = getExtendTest();
248                 com.aventstack.extentreports.model.Test model = test.getModel();
249                 String name = model.getName();
250                 String status = model.getStatus().toString();
251 //              if (suiteName.equals(suiteNameXml.TESTNG_FAILED_XML_NAME.getValue()) && !(result.getStatus() == ITestResult.SUCCESS)) {
252                         getCsvReport().writeRow(result.getInstanceName(), name.replace(RE_RUN,""), status);
253 //              }
254         }
255         
256         public void generateReport4Jenkins(ITestContext context) {
257                 String suiteName = ExtentManager.getSuiteName(context); 
258 //              String outputDirectory = context.getOutputDirectory();
259             JSONObject obj = new JSONObject();
260             String success = Integer.toString(context.getPassedTests().size());
261             String failed = Integer.toString(context.getFailedTests().size());
262             String total = Integer.toString(context.getFailedTests().size()+context.getPassedTests().size());
263         obj.put("projectName", "SDC-ONAP-UI-Automation-"+suiteName);
264         obj.put("projectVersion",  AutomationUtils.getOSVersion());
265         obj.put("platform", "Linux");
266         obj.put("total", total);
267         obj.put("success", success);
268         obj.put("failed", failed);
269         
270         try (FileWriter file = new FileWriter(getReportFolder() + "jenkinsResults.json")) {
271
272             file.write(obj.toJSONString());
273             file.flush();
274
275         } catch (IOException e) {
276             e.printStackTrace();
277         }
278
279         System.out.print(obj);
280                 
281                 
282         }
283         
284         
285         @Parameters({ "eraseAfterTests" })
286         @AfterSuite(alwaysRun = true)   
287         public void afterSuite2(@Optional("true") String eraseAfterTestsReadValue) throws Exception  {
288 //              public void afterSuite() throws Exception  {
289                 
290                 csvReport.closeFile();
291                 generateReport4Jenkins(myContext);
292                 
293                 if (Boolean.parseBoolean(eraseAfterTestsReadValue)){
294                         RestCDUtils.deleteOnDemand();
295                 } else {
296                         System.out.println("Resources will not be deleted according to suite configuration ...");
297                 }
298                 
299                 if (getConfig().getUseBrowserMobProxy()){
300                         MobProxy.getPoxyServer().stop();
301                 }
302         }
303         
304         protected static String setUrl() {
305                 url = getConfig().getUrl();
306                 uiSimulator = getConfig().isUiSimulator();
307                 if (url == null) {
308                         String message = "no URL found";
309                         System.out.println(message);
310                         Assert.fail(message);
311                 } else if (!url.contains("localhost") && !url.contains("192.168.33.10") && !url.contains("127.0.0.1") && !url.contains("192.168.50.5") && !uiSimulator==true) {
312                         localEnv = false;
313                 }
314                 return url;
315         }
316
317
318
319         public static void navigateToUrl(String url) throws Exception {
320                 try {
321                         System.out.println("Deleting cookies...");
322                         deleteCookies();
323
324                         System.out.println("Navigating to URL : " + url);
325                         getDriver().navigate().to(url);
326                         GeneralUIUtils.waitForLoader();
327                         
328                         System.out.println("Zooming out...");
329                         GeneralUIUtils.windowZoomOutUltimate();
330                         
331                 } 
332                 catch (Exception e) {
333                         String msg = "Browser is unreachable";
334                         System.out.println(msg);
335                         getExtendTest().log(Status.ERROR, msg);
336                         Assert.fail(msg);
337                 }
338         }
339         private static void deleteCookies() throws Exception {
340                 getDriver().manage().deleteAllCookies();
341                 Thread.sleep(1000);
342                 
343                 int attempts = 0;
344                 final int max_attempts = 3;
345                 
346                 while (!getDriver().manage().getCookies().isEmpty() && attempts < max_attempts){
347                         getExtendTest().log(Status.INFO, "Trying to delete cookies one more time - " + (attempts + 1) + "/" + max_attempts + "attempts");
348                         String deleteCookiesJS = "document.cookie.split(';').forEach(function(c) { document.cookie = c.replace(/^ +/, '').replace(/=.*/, '=;expires=' + new Date().toUTCString() + ';path=/'); });";
349                         ((JavascriptExecutor) getDriver()).executeScript(deleteCookiesJS);
350                         attempts++;
351                         
352                         if (attempts == max_attempts){
353                                 String msg = "Did not delete cookies, can't login as user " + WindowTestManager.getWindowMap().getUser().getRole();
354                                 System.out.println(msg);
355                                 getExtendTest().log(Status.ERROR, msg);
356                                 Assert.fail(msg);
357                         }
358                 }
359         }
360         
361         protected void loginToSystem(UserRoleEnum role) throws Exception {
362                 UserCredentials credentials = new UserCredentials(role.getUserId(), role.getPassword(), role.getFirstName(), role.getLastName(), role.name());
363                 if (localEnv){
364                         loginToSimulator(role);
365                 }
366                 else{
367                         sendUserAndPasswordKeys(credentials);
368                         WebElement submitButton = GeneralUIUtils.getWebElementBy(By.name("btnSubmit"), 30);
369                         submitButton.click();
370                         WebElement buttonOK = GeneralUIUtils.getWebElementBy(By.name("successOK"), 30);
371                         Assert.assertTrue(buttonOK.isDisplayed(), "OK button is not displayed.");
372                         buttonOK.click();
373                 }
374                 GeneralUIUtils.ultimateWait();                   
375                 getWindowTest().setUser(credentials);
376         }
377
378         private void goToHomePage(UserRoleEnum role) throws Exception {
379                 try {
380                         getWindowTest().setRefreshAttempts(getWindowTest().getRefreshAttempts() == 0 ? NUM_OF_ATTEMPTS_TO_REFTRESH : getWindowTest().getRefreshAttempts());
381                         if (!role.equals(UserRoleEnum.ADMIN)) {
382                                 
383                                 WebElement closeButton = GeneralUIUtils.getClickableButtonBy(By.className("sdc-welcome-close"), 10);
384                                 if (closeButton != null){
385                                         closeButton.click();
386                                 }
387                                 
388                                 if (!GeneralUIUtils.isElementVisibleByTestId(DataTestIdEnum.MainMenuButtons.HOME_BUTTON.getValue()))
389                                 {
390                                         restartBrowser(role);
391                                 }
392                         }
393                 }
394                 catch (Exception e) {
395                         restartBrowser(role);
396                 }
397         }
398         private void restartBrowser(UserRoleEnum role) throws Exception {
399                 getWindowTest().setRefreshAttempts(getWindowTest().getRefreshAttempts() - 1);
400                 if (getWindowTest().getRefreshAttempts() <= 0) {
401                         System.out.println("ERR : Something is wrong with browser!");
402                         Assert.fail("ERR : Something is wrong with browser!");
403                 }
404                 System.out.println("Trying again...");
405                 getExtendTest().log(Status.INFO, "Trying again...");
406                 getExtendTest().log(Status.INFO, String.format("%s attempt(s) left", getWindowTest().getRefreshAttempts() ));
407                 System.out.println(String.format("%s attempt(s) left", getWindowTest().getRefreshAttempts() ));
408
409                 reloginWithNewRole(role);
410         }
411         
412         public void loginToSimulator(UserRoleEnum role){
413                 WebDriver driver = GeneralUIUtils.getDriver();
414                 WebDriverWait wait = new WebDriverWait(driver, 30);
415                 
416                 wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.xpath("//*[@method='" + "post" + "']"))));
417                 
418                 WebElement userIdTextbox = GeneralUIUtils.getWebElementBy(By.name("userId"));
419                 userIdTextbox.sendKeys(role.getUserId());
420                 WebElement passwordTextbox = GeneralUIUtils.getWebElementBy(By.name("password"));
421                 passwordTextbox.sendKeys(WEB_SEAL_PASSWORD);
422                 
423                 wait.until(ExpectedConditions.elementToBeClickable(driver.findElement(By.xpath("//*[@value='" + "Login" + "']")))).click();
424         }
425
426         private void sendUserAndPasswordKeys(UserCredentials userId) {
427                 System.out.println("Login as user : " + userId.getUserId());
428                 WebElement userNameTextbox = GeneralUIUtils.getWebElementBy(By.name("userid"));
429                 userNameTextbox.sendKeys(userId.getUserId());
430                 WebElement passwordTextbox = GeneralUIUtils.getWebElementBy(By.name("password"));
431                 passwordTextbox.sendKeys(userId.getPassword());
432         }
433
434         public void loginWithUser(UserRoleEnum role) {
435                 try {
436                         getExtendTest().log(Status.INFO, String.format("Login as user %s", role.name().toUpperCase()));
437                         loginToSystem(role);
438                         goToHomePage(role);
439                 } catch (Exception e) {
440                         throw new RuntimeException(e);
441                 }
442                 finally{
443                         getWindowTest().setPreviousRole(getWindowTest().getUser().getRole());
444                 }
445         }
446
447         private void setUser(UserRoleEnum role) {
448                 User user = new User();
449                 user.setUserId(role.getUserId());
450                 user.setFirstName(role.getFirstName());
451                 user.setRole(role.name());
452                 user.setLastName(role.getLastName());
453                 
454                 getWindowTest().setUser(user);
455         }
456
457         public User getUser() {
458                 return getWindowTest().getUser();
459         }
460
461         private void setBrowserBeforeTest(UserRoleEnum role) {
462                 System.out.println(String.format("Setup before test as %s.", role.toString().toUpperCase() ));
463                 try {
464                         System.out.println("Previous role is : " + getWindowTest().getPreviousRole() + " ; Current role is : " + role.name());
465                         if (!getWindowTest().getPreviousRole().toLowerCase().equals(role.name().toLowerCase())){
466                                 System.out.println("Roles are different, navigate and login");
467                                 navigateAndLogin(role);
468                         }
469                 } catch (Exception e) {
470                         e.printStackTrace();
471                 }
472         }
473
474         public void navigateAndLogin(UserRoleEnum role) throws Exception {
475                 getWindowTest().setRefreshAttempts(getWindowTest().getRefreshAttempts() != 0 ? getWindowTest().getRefreshAttempts() : 0);
476                 setUser(role);
477                 navigateToUrl(url);
478                 loginWithUser(role);
479                 GeneralUIUtils.ultimateWait();
480         }
481
482         public User getUser(UserRoleEnum role) {
483                 User user = new User();
484                 user.setUserId(role.getUserId());
485                 user.setFirstName(role.getFirstName());
486                 user.setLastName(role.getLastName());
487                 user.setRole(role.name());
488                 return user;
489         }
490
491         protected void reloginWithNewRole(UserRoleEnum role) throws Exception {
492                 System.out.println(String.format("Setup before relogin as %s", role.toString().toUpperCase()));
493                 navigateAndLogin(role);
494         }
495
496         /*public static void setLocalUrl(UserRoleEnum role) {
497                 switch (role) {
498                         case ADMIN: {
499                                 url = "http://localhost:8181/sdc1/proxy-admin1#/dashboard";
500                                 break;
501                         }
502                         case DESIGNER: {
503                                 url = "http://localhost:8181/sdc1/proxy-designer1#/dashboard";
504                                 break;
505                         }
506                         case GOVERNOR: {
507                                 url = "http://localhost:8181/sdc1/proxy-governor1#/dashboard";
508                                 break;
509                         }
510                         case OPS: {
511                                 url = "http://localhost:8181/sdc1/proxy-ops1#/dashboard";
512                                 break;
513                         }
514                         case TESTER: {
515                                 url = "http://localhost:8181/sdc1/proxy-tester1#/dashboard";
516                                 break;
517                         }
518                         case PRODUCT_MANAGER1: {
519                                 url = "http://localhost:8181/sdc1/proxy-pm1#/dashboard";
520                                 break;
521                         }
522                         case PRODUCT_MANAGER2: {
523                                 url = "http://localhost:8181/sdc1/proxy-pm2#/dashboard";
524                                 break;
525                         }
526                         case PRODUCT_STRATEGIST1: {
527                                 url = "http://localhost:8181/sdc1/proxy-ps1#/dashboard";
528                                 break;
529                         }
530                         case PRODUCT_STRATEGIST2: {
531                                 url = "http://localhost:8181/sdc1/proxy-ps2#/dashboard";
532                                 break;
533                         }
534                         default: {
535                                 break;
536                         }
537                 }
538         }*/
539         
540         public void addTrafficFileToReport(ITestResult result) {
541                 try {                           
542                         // Get the HAR data
543                         Har har = MobProxy.getPoxyServer().getHar();
544                         String shortUUID = UUID.randomUUID().toString().split("-")[0];
545                         File harFile = new File(getHarFilesFolder() + result.getName() + shortUUID + ".har");
546                         new File(getHarFilesFolder()).mkdirs();
547
548                         har.writeTo(harFile);
549                         
550                         String pathToFileFromReportDirectory = HAR_FILES_FOLDER_NAME + File.separator + harFile.getName();
551                         ExtentTestActions.addFileToReportAsLink(harFile, pathToFileFromReportDirectory, "File with captured traffic");
552                 } catch (IOException ioe) {
553                         ioe.printStackTrace();
554                 }
555         }
556         
557         /*
558          * * Start section of test in ExtentReport with DataProvider parameters,
559          * should be started from test method, see example in onboardVNFTest
560          */
561         public void setLog(String fromDataProvider) {
562                 
563                 String suiteName = ExtentManager.getSuiteName(myContext);
564                 if (suiteName.equals(suiteNameXml.TESTNG_FAILED_XML_NAME.getValue())) {
565                         ExtentTestManager.startTest(RE_RUN +Thread.currentThread().getStackTrace()[2].getMethodName() + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + fromDataProvider);
566                 }else{
567                         ExtentTestManager.startTest(Thread.currentThread().getStackTrace()[2].getMethodName() + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + fromDataProvider);
568                 }
569                 
570                 
571                 
572                 getWindowTest().setAddedValueFromDataProvider(fromDataProvider);
573                 ExtentTestManager.assignCategory(this.getClass());
574                 setBrowserBeforeTest(getRole());
575         }
576         
577         
578         
579         /**************** MAIN ****************/
580         public static void main(String[] args) {
581                 System.out.println("---------------------");
582                 System.out.println("running test from CLI");
583                 System.out.println("---------------------");
584
585                 String attsdcFilePath = FileHandling.getBasePath() + File.separator + "conf" + File.separator + "attsdc.yaml";
586                 System.setProperty("config.resource", attsdcFilePath);
587                 System.out.println("attsdc.yaml file path is : " + attsdcFilePath);
588                 
589                 String filepath = FileHandling.getBasePath() + File.separator + "Files" + File.separator;
590                 System.setProperty("filePath", filepath);
591                 System.out.println("filePath is : " + System.getProperty("filePath"));
592                 
593                 Object[] testSuitsList = FileHandling.filterFileNamesFromFolder(FileHandling.getBasePath() + File.separator + "testSuites", ".xml");
594                 if (testSuitsList != null) {
595                         System.out.println(String.format("Found %s testSuite(s)", testSuitsList.length));
596                         args = Arrays.copyOf(testSuitsList, testSuitsList.length, String[].class);
597                         StartTest.main(args);
598                 }
599         }
600 }