From 74725eca843120ee6f237bfe4da77a64eec68154 Mon Sep 17 00:00:00 2001 From: Jayesh Kharode Date: Wed, 3 Jul 2024 11:30:44 +0530 Subject: [PATCH] MOSIP-33770 Signed-off-by: Jayesh Kharode --- .../residentui/testcase/UpdateMyData.java | 34 ++++--------- .../testcase/VerifyPhoneNumberEmailID.java | 48 +++++++------------ .../testrig/residentui/utility/Commons.java | 17 +++++++ 3 files changed, 41 insertions(+), 58 deletions(-) diff --git a/uitest-resident/src/main/java/io/mosip/testrig/residentui/testcase/UpdateMyData.java b/uitest-resident/src/main/java/io/mosip/testrig/residentui/testcase/UpdateMyData.java index e12a57a7..86e4ab85 100644 --- a/uitest-resident/src/main/java/io/mosip/testrig/residentui/testcase/UpdateMyData.java +++ b/uitest-resident/src/main/java/io/mosip/testrig/residentui/testcase/UpdateMyData.java @@ -1,7 +1,6 @@ package io.mosip.testrig.residentui.testcase; import org.openqa.selenium.By; -import org.testng.Reporter; import org.testng.annotations.Test; import com.aventstack.extentreports.Status; @@ -9,18 +8,16 @@ import io.mosip.testrig.residentui.kernel.util.ConfigManager; import io.mosip.testrig.residentui.utility.BaseClass; import io.mosip.testrig.residentui.utility.Commons; -import io.mosip.testrig.residentui.utility.JsonUtil; import io.mosip.testrig.residentui.utility.MockSMTPListener; import io.mosip.testrig.residentui.utility.TestRunner; @Test(groups = "UMD") public class UpdateMyData extends BaseClass { public void updateMyDataName() throws Exception { - String tempemail1 = ConfigManager.gettempemail1(); LoginTest.loginTest(); test = extent.createTest("updateMyData Test ", "verify Login"); Commons.clickWebelement(test, driver, By.id("uinservices/updatedemographic")); - Commons.enter(test, driver, By.id("fullName"+BaseClass.envsupportlang()), data); + Commons.enter(test, driver, By.id("fullName"+BaseClass.envsupportlang()), Commons.generateRandomAlphabetString()); Commons.dropdown(test, driver, By.id("gender")); test.log(Status.INFO, "Click on gender"); Commons.enter(test, driver, By.id("proofOfIdentityvalue"), data); @@ -29,16 +26,15 @@ public void updateMyDataName() throws Exception { TestRunner.getResourcePath() + "//BulkUploadFiles//tonyId.png"); Thread.sleep(2000); Commons.clickWebelement(test, driver, By.id("previewBtn")); - - test.log(Status.INFO, "Click on submit"); - + test.log(Status.INFO, "Click on submit"); Commons.clickWebelement(test, driver, By.id("submitBtn")); Commons.clickWebelement(test, driver, By.id("confirmUpdateData")); - Commons.clickWebelement(test, driver, By.id("updateMyDataBtn")); - + Commons.clickWebelement(test, driver, By.id("updateMyDataBtn")); test.log(Status.INFO, "Click on Submit"); Commons.clickWebelement(test, driver, By.id("dismissBtn")); } + + public void updateMyDataAddress() throws Exception { test.log(Status.INFO, "Update Address"); @@ -47,7 +43,7 @@ public void updateMyDataAddress() throws Exception { Commons.clickWebelement(test, driver, By.xpath("//div[@id='mat-tab-label-0-1']")); - Commons.enter(test, driver, By.id("addressLine1"+BaseClass.envsupportlang()), data); + Commons.enter(test, driver, By.id("addressLine1"+BaseClass.envsupportlang()), Commons.generateRandomAlphabetString()); Commons.dropdown(test, driver, By.id("Region"+BaseClass.envsupportlang())); Commons.dropdown(test, driver, By.id("Province"+BaseClass.envsupportlang())); Commons.dropdown(test, driver, By.id("City"+BaseClass.envsupportlang())); @@ -74,39 +70,27 @@ public void UpdateDataWithEmail() throws Exception { LoginTest.loginTest(); test.log(Status.INFO, "Update Email"); Commons.click(test, driver, By.id("uinservices/updatedemographic")); - // Commons.click(test,driver, By.xpath("//span[text()='Demographic Data']")); Commons.clickWebelement(test, driver, By.xpath("//div[@id='mat-tab-label-0-2']")); - - Commons.enter(test, driver, By.id("email"), tempemail1); - + Commons.enter(test, driver, By.id("email"), tempemail1); Commons.clickWebelement(test, driver, By.id("sendOTPemail")); String otp = MockSMTPListener.getOtp(tempemail1); System.out.println(otp); -// for(int i=0;i<=otp.length()-1;i++) { -// Commons.enter(driver, By.xpath("//*[@class=\"pincode-input-text\"]["+(i+1)+"]"), Character.toString(otp.charAt(i)));} - - Commons.enter(test, driver, By.id("otp-input"), otp); + Commons.enter(test, driver, By.id("otp-input"), otp); Commons.clickWebelement(test, driver, By.id("submitOtpBtn")); Commons.clickWebelement(test, driver, By.id("dismissBtn")); } public void UpdateDataWithLanguage() throws Exception { - // Lang prefrence LoginTest.loginTest(); test.log(Status.INFO, "Select Language Preference"); Commons.click(test, driver, By.id("uinservices/updatedemographic")); - // Commons.click(test,driver, By.xpath("//span[text()='Demographic Data']")); Commons.clickWebelement(test, driver, By.xpath("//div[@id='mat-tab-label-0-3']")); Commons.dropdown(test, driver, By.id("preferredLang")); Commons.clickWebelement(test, driver, By.id("submit")); } - - - - public void UpdateDataWithoutAddressLine() throws Exception { LoginTest.loginTest(); test = extent.createTest("UpdateDataWithoutAddressLine ", "verify Login"); @@ -124,8 +108,6 @@ public void UpdateDataWithoutAddressLine() throws Exception { test.log(Status.INFO, "file Uploaded"); Thread.sleep(2000); Commons.clickWebelement(test, driver, By.id("previewBtn")); - - Commons.clickWebelement(test, driver, By.id("submitBtn")); Commons.clickWebelement(test, driver, By.id("confirmUpdateData")); Commons.clickWebelement(test, driver, By.id("updateMyDataBtn")); diff --git a/uitest-resident/src/main/java/io/mosip/testrig/residentui/testcase/VerifyPhoneNumberEmailID.java b/uitest-resident/src/main/java/io/mosip/testrig/residentui/testcase/VerifyPhoneNumberEmailID.java index a8e267e3..e1ab291d 100644 --- a/uitest-resident/src/main/java/io/mosip/testrig/residentui/testcase/VerifyPhoneNumberEmailID.java +++ b/uitest-resident/src/main/java/io/mosip/testrig/residentui/testcase/VerifyPhoneNumberEmailID.java @@ -1,5 +1,7 @@ package io.mosip.testrig.residentui.testcase; +import static org.testng.Assert.assertFalse; + import java.io.IOException; import org.openqa.selenium.By; @@ -7,41 +9,35 @@ import io.mosip.testrig.residentui.kernel.util.ConfigManager; import io.mosip.testrig.residentui.utility.Commons; -import io.mosip.testrig.residentui.utility.JsonUtil; import io.mosip.testrig.residentui.utility.MockSMTPListener; import io.mosip.testrig.residentui.utility.ResidentBaseClass; import io.mosip.testrig.residentui.utility.TestRunner; -@Test(groups = "VPNEEI") public class VerifyPhoneNumberEmailID extends ResidentBaseClass { @Test(priority=0) - public void VerifyEmailIDWIthInvalidVid() throws IOException, InterruptedException { + public void VerifyEmailIDAndPhoneWIthInvalidVid() throws IOException, InterruptedException { Thread.sleep(2000); Commons.click(test, driver, By.id("verifyPhoneNumber/EmailID")); Commons.click(test, driver, By.id("emailChannelBtn-button")); Commons.enter(test, driver, By.id("uin"), "6534906793542111"); - // Commons.switchToFrameByIndex(test, driver, 0); - // Commons.click(test, driver, By.id("recaptcha-anchor")); - // driver.switchTo().parentFrame(); Commons.click(test, driver, By.id("sendOtpBtn")); + assertFalse(Commons.isDisplayed(driver,By.id("submitOtpBtn")),"Verify submit otp button with invalid otp"); Commons.click(test, driver, By.id("dismissBtn")); - } - @Test(priority=1) - public void VerifyPhoneWIthInvalidVid() throws IOException, InterruptedException { Thread.sleep(2000); - Commons.click(test, driver, By.id("verifyPhoneNumber/EmailID")); Commons.click(test, driver, By.id("phoneChannelBtn")); Commons.enter(test, driver, By.id("uin"), "6534906793542111"); - // Commons.switchToFrameByIndex(test, driver, 0); - // Commons.click(test, driver, By.id("recaptcha-anchor")); - // driver.switchTo().parentFrame(); Commons.click(test, driver, By.id("sendOtpBtn")); + assertFalse(Commons.isDisplayed(driver,By.id("submitOtpBtn")),"Verify submit otp button with invalid otp"); Commons.click(test, driver, By.id("dismissBtn")); - + Commons.enter(test, driver, By.id("uin"), "6534906793542111"); + Commons.click(test, driver, By.id("sendOtpBtn")); + assertFalse(Commons.isDisplayed(driver,By.id("submitOtpBtn")),"Verify submit otp button with invalid otp"); + } + @Test(priority=2) public void VerifyEmailIDWIthInvalidOtp() throws Exception { String externalemail = ConfigManager.getexternalemail(); @@ -49,44 +45,32 @@ public void VerifyEmailIDWIthInvalidOtp() throws Exception { Commons.click(test, driver, By.id("verifyPhoneNumber/EmailID")); Commons.click(test, driver, By.id("emailChannelBtn-button")); Commons.enter(test, driver, By.id("uin"), TestRunner.perpetualVid); - // Commons.switchToFrameByIndex(test, driver, 0); - // Commons.click(test, driver, By.id("recaptcha-anchor")); - // driver.switchTo().parentFrame(); Thread.sleep(3000); Commons.click(test, driver, By.id("sendOtpBtn")); - // Commons.click(test,driver, By.xpath("//button[text()='Get OTP']")); String otp = MockSMTPListener.getOtp(externalemail); Thread.sleep(3000); Commons.enter(test, driver, By.id("otp-input"), otp + "23"); Commons.click(test, driver, By.id("submitOtpBtn")); Commons.click(test, driver, By.id("dismissBtn")); - } - @Test(priority=3) - public void VerifyEmailIDWIthoutOtp() throws Exception { - String externalemail = ConfigManager.getexternalemail(); - Thread.sleep(2000); - Commons.click(test, driver, By.id("verifyPhoneNumber/EmailID")); + Commons.click(test, driver, By.id("backBtn")); Commons.click(test, driver, By.id("emailChannelBtn-button")); Commons.enter(test, driver, By.id("uin"), TestRunner.perpetualVid); - // Commons.switchToFrameByIndex(test, driver, 0); - // Commons.click(test, driver, By.id("recaptcha-anchor")); - // driver.switchTo().parentFrame(); Thread.sleep(3000); Commons.click(test, driver, By.id("sendOtpBtn")); - + Commons.click(test, driver, By.id("submitOtpBtn")); + assertFalse(Commons.isDisplayed(driver,By.id("dismissBtn")),"Verify submit otp button without enter otp"); } - @Test(priority=4) - public void VerifyEmailID() throws Exception { + + @Test(priority=3) + public void VerifyEmailIDAndPhone() throws Exception { String externalemail = ConfigManager.getexternalemail(); Thread.sleep(2000); Commons.click(test, driver, By.id("verifyPhoneNumber/EmailID")); Commons.click(test, driver, By.id("emailChannelBtn-button")); Commons.enter(test, driver, By.id("uin"), TestRunner.perpetualVid); - Thread.sleep(3000); Commons.click(test, driver, By.id("sendOtpBtn")); - // Commons.click(test,driver, By.xpath("//button[text()='Get OTP']")); String otp = MockSMTPListener.getOtp(externalemail); Thread.sleep(3000); Commons.enter(test, driver, By.id("otp-input"), otp); diff --git a/uitest-resident/src/main/java/io/mosip/testrig/residentui/utility/Commons.java b/uitest-resident/src/main/java/io/mosip/testrig/residentui/utility/Commons.java index 1468e3de..ba37ba09 100644 --- a/uitest-resident/src/main/java/io/mosip/testrig/residentui/utility/Commons.java +++ b/uitest-resident/src/main/java/io/mosip/testrig/residentui/utility/Commons.java @@ -3,6 +3,7 @@ import java.io.IOException; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; +import java.util.Random; import java.util.Set; import java.util.concurrent.TimeUnit; @@ -519,6 +520,22 @@ public static boolean switchWindowByTitle(WebDriver driver,String windowTitle, i } } + public static boolean IsElementEnabled(WebDriver driver, By by) { + new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(by)); + return driver.findElement(by).isEnabled(); + } + public static String generateRandomAlphabetString() { + String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + Random random = new Random(); + StringBuilder stringBuilder = new StringBuilder(15); + + for (int i = 0; i < 15; i++) { + int index = random.nextInt(alphabet.length()); + stringBuilder.append(alphabet.charAt(index)); + } + + return stringBuilder.toString(); + } }