From 936e40db65b5d506563a51c3aa7c0065eb380edb Mon Sep 17 00:00:00 2001 From: Jayesh Kharode Date: Fri, 18 Aug 2023 16:33:58 +0530 Subject: [PATCH 1/2] MOSIP-28963 --- .../testrig/adminui/testcase/CenterTest.java | 3 +- .../testrig/adminui/testcase/DeviceTest.java | 4 +- .../adminui/testcase/HolidaysTest.java | 4 +- .../testrig/adminui/testcase/MachineTest.java | 3 +- .../testrig/adminui/utility/BaseClass.java | 9 +++-- .../testrig/adminui/utility/Commons.java | 37 ++++++++++++++++++- admintest/src/main/resources/logback.xml | 2 +- 7 files changed, 52 insertions(+), 10 deletions(-) diff --git a/admintest/src/main/java/io/mosip/testrig/adminui/testcase/CenterTest.java b/admintest/src/main/java/io/mosip/testrig/adminui/testcase/CenterTest.java index 80a2bfee..13e14359 100644 --- a/admintest/src/main/java/io/mosip/testrig/adminui/testcase/CenterTest.java +++ b/admintest/src/main/java/io/mosip/testrig/adminui/testcase/CenterTest.java @@ -89,7 +89,8 @@ public void centerCRUD() throws Exception { Commons.click(test,driver,By.cssSelector(".mat-list-item:nth-child(4) > .mat-list-item-content")); Commons.click(test,driver,By.cssSelector(".mat-list-item:nth-child(5) > .mat-list-item-content")); - Commons.enter(test,driver,By.id("holidayDate"),holidayDate); + // Commons.enter(test,driver,By.id("holidayDate"),holidayDate); + Commons.calendar(holidayDate); Commons.click(test,driver, By.id("createExceptionalHoliday")); test.log(Status.INFO, "Click on Exceptional Holiday"); diff --git a/admintest/src/main/java/io/mosip/testrig/adminui/testcase/DeviceTest.java b/admintest/src/main/java/io/mosip/testrig/adminui/testcase/DeviceTest.java index a90597cb..037ca79a 100644 --- a/admintest/src/main/java/io/mosip/testrig/adminui/testcase/DeviceTest.java +++ b/admintest/src/main/java/io/mosip/testrig/adminui/testcase/DeviceTest.java @@ -47,8 +47,8 @@ public void deviceCRUD() throws InterruptedException { test.log(Status.INFO, "Enters MACAddress"); Commons.enter(test,driver, By.id("ipAddress"),"2.2345"); - Commons.enter(test,driver, By.id("validity"),validityDate); - + // Commons.enter(test,driver, By.id("validity"),validityDate); + Commons.calendar(validityDate); Commons.dropdown(test,driver,By.id("deviceSpecId")); // Commons.dropdown(test,driver,By.id("zone")); Commons.dropdown(test,driver,By.id("regCenterId")); diff --git a/admintest/src/main/java/io/mosip/testrig/adminui/testcase/HolidaysTest.java b/admintest/src/main/java/io/mosip/testrig/adminui/testcase/HolidaysTest.java index 72447d40..5cdee458 100644 --- a/admintest/src/main/java/io/mosip/testrig/adminui/testcase/HolidaysTest.java +++ b/admintest/src/main/java/io/mosip/testrig/adminui/testcase/HolidaysTest.java @@ -1,6 +1,7 @@ package io.mosip.testrig.adminui.testcase; import java.io.IOException; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; @@ -48,7 +49,8 @@ public void holidaysCRUD() throws Exception { Commons.enter(test,driver,By.id("holidayName"),data); Commons.enter(test,driver,By.id("holidayDesc"),data); - Commons.enter(test,driver,By.id("holidayDate"),holidayDate); + // Commons.enter(test,driver,By.id("holidayDate"),holidayDate); + Commons.calendar(holidayDate); test.log(Status.INFO, "Click on Enters HolidayDate"); Commons.dropdown(test,driver,By.id("locationCode")); diff --git a/admintest/src/main/java/io/mosip/testrig/adminui/testcase/MachineTest.java b/admintest/src/main/java/io/mosip/testrig/adminui/testcase/MachineTest.java index 1e26ab1f..40f85ad3 100644 --- a/admintest/src/main/java/io/mosip/testrig/adminui/testcase/MachineTest.java +++ b/admintest/src/main/java/io/mosip/testrig/adminui/testcase/MachineTest.java @@ -46,7 +46,8 @@ public void machineCRUD() throws Exception { Commons.enter(test,driver,By.id("macAddress"),"1.2.3.4.5.6"); Commons.enter(test,driver,By.id("ipAddress"),"2.3.4.5.6"); test.log(Status.INFO, "ENter IpAddress"); - Commons.enter(test,driver,By.id("validity"),holidayDateCenter); + // Commons.enter(test,driver,By.id("validity"),holidayDateCenter); + Commons.calendar(holidayDateCenter); Commons.dropdown(test,driver,By.id("machineSpecId")); Commons.enter(test,driver,By.id("publicKey"),publicKey); diff --git a/admintest/src/main/java/io/mosip/testrig/adminui/utility/BaseClass.java b/admintest/src/main/java/io/mosip/testrig/adminui/utility/BaseClass.java index 2b825b01..d798739d 100644 --- a/admintest/src/main/java/io/mosip/testrig/adminui/utility/BaseClass.java +++ b/admintest/src/main/java/io/mosip/testrig/adminui/utility/BaseClass.java @@ -51,7 +51,7 @@ public class BaseClass { private static final Logger logger = Logger.getLogger(TestRunner.class); - protected WebDriver driver; + protected static WebDriver driver; protected Map vars; protected JavascriptExecutor js; protected String langcode; @@ -88,14 +88,17 @@ public void setUp() throws Exception { test=extent.createTest(getCommitId(),getCommitId()); ChromeOptions options = new ChromeOptions(); + String headless=JsonUtil.JsonObjParsing(Commons.getTestData(),"headless"); if(headless.equalsIgnoreCase("yes")) { options.addArguments("--headless=new"); } - WebDriverManager.chromedriver().setup(); - driver=new ChromeDriver(options); + + WebDriverManager.chromedriver().setup(); + driver=new ChromeDriver(options); + // js = (JavascriptExecutor) driver; diff --git a/admintest/src/main/java/io/mosip/testrig/adminui/utility/Commons.java b/admintest/src/main/java/io/mosip/testrig/adminui/utility/Commons.java index 1873c411..743622d2 100644 --- a/admintest/src/main/java/io/mosip/testrig/adminui/utility/Commons.java +++ b/admintest/src/main/java/io/mosip/testrig/adminui/utility/Commons.java @@ -3,12 +3,14 @@ import java.io.IOException; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; +import java.util.List; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.StaleElementReferenceException; import org.openqa.selenium.TimeoutException; import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; import org.testng.Assert; @@ -426,6 +428,39 @@ public static String getPreAppend() return preappend; } - + public static void calendar(String date) { + String a=date.replaceAll("/",""); + String mon=""; + if(a.substring(0,2).equals("10")) { + mon= a.substring(0,2); + }else { + mon=a.substring(0,2).replace("0",""); + } + String d=""; + if(a.substring(2,4).equals("10") || a.substring(2,4).equals("20")||a.substring(2,4).equals("30")) { + d=a.substring(2,4); + }else { + d=a.substring(2,4).replace("0",""); + } + + int month=Integer.parseInt(mon) ; + int day=Integer.parseInt(d); + int year=Integer.parseInt(a.substring(4,8)); + try { + Commons.click(test,driver,By.xpath("//*[@class='mat-datepicker-toggle']//button")); + Thread.sleep(500); + Commons.click(test,driver,By.xpath("//*[@class='mat-calendar-arrow']")); + Thread.sleep(500); + Commons.click(test,driver,By.xpath("//*[text()='"+year+"']")); + Thread.sleep(500); + List cli= driver.findElements(By.xpath("//*[@class='mat-calendar-body-cell-content']")); + cli.get(month-1).click(); + Thread.sleep(500); + Commons.click(test,driver,By.xpath("//*[text()='"+day+"']")); + }catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } } diff --git a/admintest/src/main/resources/logback.xml b/admintest/src/main/resources/logback.xml index 74ba4553..9946619a 100644 --- a/admintest/src/main/resources/logback.xml +++ b/admintest/src/main/resources/logback.xml @@ -19,7 +19,7 @@ - + From 6c59882b9b09152b8a68a230e48c99c9cfde8cd3 Mon Sep 17 00:00:00 2001 From: Jayesh Kharode Date: Thu, 14 Sep 2023 18:21:09 +0530 Subject: [PATCH 2/2] fix jar setup issue --- .../adminui/kernel/util/CommonLibrary.java | 2 +- .../mosip/testrig/adminui/utility/JsonUtil.java | 9 ++++++++- .../mosip/testrig/adminui/utility/Screenshot.java | 15 ++++++++++++++- .../mosip/testrig/adminui/utility/TestRunner.java | 8 +++++--- admintest/src/main/resources/TestData.json | 8 ++++---- .../{Kernel.properties => Kernel11.properties} | 0 6 files changed, 32 insertions(+), 10 deletions(-) rename admintest/src/main/resources/config/{Kernel.properties => Kernel11.properties} (100%) diff --git a/admintest/src/main/java/io/mosip/testrig/adminui/kernel/util/CommonLibrary.java b/admintest/src/main/java/io/mosip/testrig/adminui/kernel/util/CommonLibrary.java index 5e45a767..3384ad69 100644 --- a/admintest/src/main/java/io/mosip/testrig/adminui/kernel/util/CommonLibrary.java +++ b/admintest/src/main/java/io/mosip/testrig/adminui/kernel/util/CommonLibrary.java @@ -29,7 +29,7 @@ public class CommonLibrary extends BaseTestCaseFunc { public String getResourcePath() { - return TestRunner.getGlobalResourcePath() + "/"; + return TestRunner.getResourcePath() + "/"; } public String getResourcePathForKernel() { diff --git a/admintest/src/main/java/io/mosip/testrig/adminui/utility/JsonUtil.java b/admintest/src/main/java/io/mosip/testrig/adminui/utility/JsonUtil.java index 5031afc1..d4b0d4a0 100644 --- a/admintest/src/main/java/io/mosip/testrig/adminui/utility/JsonUtil.java +++ b/admintest/src/main/java/io/mosip/testrig/adminui/utility/JsonUtil.java @@ -124,11 +124,18 @@ public static List JsonObjArrayListParsing(String jsonIdentity, String i public static String readJsonFileText(String document) { String jsonTxt = null; + File f=null; try { - File f = new File(System.getProperty("user.dir") + "\\"+document); + if (TestRunner.checkRunType().equalsIgnoreCase("JAR")) { + f = new File(TestRunner.getResourcePath() + "/" +document); + } else if (TestRunner.checkRunType().equalsIgnoreCase("IDE")) { + + + f = new File(System.getProperty("user.dir") + System.getProperty("path.config")+ "/"+document); + } if (f.exists()) { InputStream is = new FileInputStream(f); jsonTxt = IOUtils.toString(is, "UTF-8"); diff --git a/admintest/src/main/java/io/mosip/testrig/adminui/utility/Screenshot.java b/admintest/src/main/java/io/mosip/testrig/adminui/utility/Screenshot.java index 87034c8b..75def8ca 100644 --- a/admintest/src/main/java/io/mosip/testrig/adminui/utility/Screenshot.java +++ b/admintest/src/main/java/io/mosip/testrig/adminui/utility/Screenshot.java @@ -21,7 +21,20 @@ public class Screenshot { public static String ClickScreenshot(WebDriver driver) throws IOException { TakesScreenshot ss=(TakesScreenshot)driver; File so=ss.getScreenshotAs(OutputType.FILE); - String path=System.getProperty("user.dir")+"/Screenshots/"+System.currentTimeMillis()+".png"; + String path=null; + + if (TestRunner.checkRunType().equalsIgnoreCase("JAR")) { + path = TestRunner.getResourcePath()+"/Screenshots/"+System.currentTimeMillis()+".png"; + } else if (TestRunner.checkRunType().equalsIgnoreCase("IDE")) { + + + path = System.getProperty("user.dir") + System.getProperty("path.config")+ "/Screenshots/"+System.currentTimeMillis()+".png"; + } + + + + + // String path=System.getProperty("user.dir")+"/resources/Screenshots/"+System.currentTimeMillis()+".png"; File des=new File(path); FileHandler.copy(so, des); FileInputStream fis=new FileInputStream(path); diff --git a/admintest/src/main/java/io/mosip/testrig/adminui/utility/TestRunner.java b/admintest/src/main/java/io/mosip/testrig/adminui/utility/TestRunner.java index f2839ba3..c251de24 100644 --- a/admintest/src/main/java/io/mosip/testrig/adminui/utility/TestRunner.java +++ b/admintest/src/main/java/io/mosip/testrig/adminui/utility/TestRunner.java @@ -76,10 +76,12 @@ public static String getGlobalResourcePath() { public static String getResourcePath() { if (checkRunType().equalsIgnoreCase("JAR")) { - return new File(jarUrl).getParentFile().getAbsolutePath(); + return new File(jarUrl).getParentFile().getAbsolutePath().toString()+"/resources/"; } else if (checkRunType().equalsIgnoreCase("IDE")) { - String path = new File(TestRunner.class.getClassLoader().getResource("").getPath()).getAbsolutePath() - .toString(); + String path = System.getProperty("user.dir") + System.getProperty("path.config"); + + // String path = new File(TestRunner.class.getClassLoader().getResource("").getPath()).getAbsolutePath() + // .toString(); if (path.contains("test-classes")) path = path.replace("test-classes", "classes"); return path; diff --git a/admintest/src/main/resources/TestData.json b/admintest/src/main/resources/TestData.json index 61bbc3fb..6b2d0758 100644 --- a/admintest/src/main/resources/TestData.json +++ b/admintest/src/main/resources/TestData.json @@ -19,8 +19,8 @@ "15templateCRUD": "T", "BELOW_ARE_STATIC_KEYWORDS": "We are using this setExcludedGroups to exclude scenarios", "setExcludedGroups": "BU", - "holidayDateCenter": "23/12/2025", - "holidayDate": "13/09/2025", + "holidayDateCenter": "10/12/2025", + "holidayDate": "10/09/2025", "validityDate":"10/12/2026", "loginlang": "sin", "preappend": "0", @@ -28,8 +28,8 @@ "headless": "no", "bulkwait": "10000", "dummyData":"blocklistwordss", - "publicKey": "AAEACwACAHIAIINxl2dEhLP4GpDMjUal1yT9UtduBlILZPKh2hszFGmqABAAFwALCAAAAQABAQDDg75ctP0GxwDUvaKneXZ4wbdfr98beJ9jEdvANZpHdjlXTGkxy3tzqE9NQCd83Vy4fni-mA14kqNdmCjs3AAGJToC86EC_QqG81TeeG-MfQuIbBlc1uDLHAcLypEMkjnubyTKUpfkA7t3lqSRgn0ck5XRwZjjNlF9Gj16P9fEY668oeUUe_3rPM5AkEC9OY21Jkod81etdYWuNBuBCXa0S_7Vx5Y3HfS0mEJnuYlisL-BaQVt_sq6cFFfE-9oMv1sDiXaEwrcSP7e1CikIbqQCtZb4AIkvowUKb_2d_4mi9iwtxa6yomso5Ji36BfQBVwSU8RCe6QCyOfmmkjBXMa", - "signPublicKey": "AAEABAAEAHIAAAAQABQACwgAAAEAAQEAnpLxkf161vM6zIUxD-rEV010TRawgms7-O2p_Qo0t23fDWqYN0AD8PgsEUO8VJ6JkMpowdMtBzyygJDjGB3uPz8LA79WbotuchWOwQdE5jrYrRT1gvZvHIPPI3R1kn7WxmhAFMowV8nX-Ka2FcqQHdqT1vKxGn5cWqk5hptvq4GB_hBJX93kkPJXs2Lt7PyWR2iMjewauAfu1mcxiSy1L-dfhQ9h2DP80oue46Fqe1i9wGNdDOzrLYYZGCgrMJbPxCj-zeDsdnD4z6iCEp8-9qglie92PyJi1_61SlNS9bOLRnX374AjIUyvbL-xx2WSfibjHi9--jeiCmpiasdTag", + "publicKey": "AAEACwACAHIAIINxl2dEhLP4GpDMjUal1yT9UtduBlILZPKh2hszFGmqABAAFwALCAAAAQABAQDFEX4nLppAuHIfGzhYn7DR_3wAQkVnrPSFFaiV9TAvN0WHtH_hweGNNjUGYvyaowwmC8jsazufmnIoPisZIFraVQNWCA6N0RhZF_LisoTYDoQSM-ZbCKPxRTFnemtTwXHxQdlVWGUXst_WZIWC0OTSzJHbBg_iXQW1UOXRJL845GFOKjvOPQiEbOZgmoWslkTIAi9bf-AeWdEYuO3bwPf-T5Xxj_xH2-PTinQA_4itRWSrhG5kEU-zQHWGL72SiGzwOOoPnzZZv2X_9djpWGEz1gyNl5ionns8IfuQrvikSEMxm-E6Z9RfKNhl_rEHgnOR4gl0ju5kg_n9tnuUeXXP", + "signPublicKey": "AAEABAAEAHIAAAAQABQACwgAAAEAAQEArjUwXvR8QvkWcplKOqMhU-tK4YxPHdkkm9IN7azBolMoAs41uR32xp070AW5LfhQokuEskOF_dvRrqHw4JzWMXDRVSpBrW_k-OwLzNfeFvuKQ9JTAXdzKUOXbPgcLY1B5bJe9E7fn-gPKYki35RgwphHraSKaYZ1yELpXiT3KPoWXzDvZE5Lqx317bgMGh2RPkf80alJks-iv-aEPDWlSWE5jr3t68gUYx4r_eixdw6tx1ADGCqK1ZEKCul73ptnR8eWorN1njcxlxUaoECvf3rCEuvfZAprBKSWBEnaFPkfgc9lYSBwtP4YKJHttmPX0Dzc85wa6V17SIwNVEiCsQ", "langcode": [ { "language": "tam", diff --git a/admintest/src/main/resources/config/Kernel.properties b/admintest/src/main/resources/config/Kernel11.properties similarity index 100% rename from admintest/src/main/resources/config/Kernel.properties rename to admintest/src/main/resources/config/Kernel11.properties