Skip to content

Commit

Permalink
Merge pull request mosip#725 from jayesh12234/develop
Browse files Browse the repository at this point in the history
MOSIP-33770
  • Loading branch information
aranaravi authored Jul 3, 2024
2 parents dc41198 + 4dd7c29 commit 4b025f5
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 58 deletions.
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
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;

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);
Expand All @@ -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");
Expand All @@ -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()));
Expand All @@ -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");
Expand All @@ -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"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,92 +1,76 @@
package io.mosip.testrig.residentui.testcase;

import static org.testng.Assert.assertFalse;

import java.io.IOException;

import org.openqa.selenium.By;
import org.testng.annotations.Test;

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();
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);
// 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
}

}

0 comments on commit 4b025f5

Please sign in to comment.