From b91391e642307e135f4f04f97f1d1e01f266d39c Mon Sep 17 00:00:00 2001
From: xuechen5 <xuechen5@illinois.edu>
Date: Fri, 6 Nov 2020 19:53:19 -0600
Subject: [PATCH] Added Selenium test for whole form input and Non-matching
 passwords

---
 .../selenium/PreRegisterPatientTest.java      | 46 +++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/iTrust/test/edu/ncsu/csc/itrust/selenium/PreRegisterPatientTest.java b/iTrust/test/edu/ncsu/csc/itrust/selenium/PreRegisterPatientTest.java
index 0633b19..64380d8 100644
--- a/iTrust/test/edu/ncsu/csc/itrust/selenium/PreRegisterPatientTest.java
+++ b/iTrust/test/edu/ncsu/csc/itrust/selenium/PreRegisterPatientTest.java
@@ -48,6 +48,38 @@ public class PreRegisterPatientTest extends iTrustSeleniumTest {
         
         assertTrue(driver.findElement(By.xpath("//body")).getText().contains("New Pre-registered Patient Information"));
     }
+    
+    public void testPreRegisterPatientSuccessAll() throws Exception {
+        goToPreRegister();
+
+        // Fill the form
+        driver.findElement(By.xpath("//input[@name='firstName']")).sendKeys("fname");
+        driver.findElement(By.xpath("//input[@name='lastName']")).sendKeys("lname");
+        driver.findElement(By.xpath("//input[@name='email']")).sendKeys("name@email.com");
+        driver.findElement(By.xpath("//input[@name='password']")).sendKeys("Password123");
+        driver.findElement(By.xpath("//input[@name='verifyPassword']")).sendKeys("Password123");
+        driver.findElement(By.xpath("//input[@name='streetAddress1']")).sendKeys("1234");
+        driver.findElement(By.xpath("//input[@name='streetAddress2']")).sendKeys("123 ave");
+        driver.findElement(By.xpath("//input[@name='city']")).sendKeys("Urbana C");
+        driver.findElement(By.xpath("//input[@name='zip']")).sendKeys("12345");
+        driver.findElement(By.xpath("//input[@name='phone']")).sendKeys("1234567890");
+        driver.findElement(By.xpath("//input[@name='height']")).sendKeys("6.3");
+        driver.findElement(By.xpath("//input[@name='weight']")).sendKeys("180");
+        driver.findElement(By.xpath("//input[@name='icName']")).sendKeys("ABC");
+        driver.findElement(By.xpath("//input[@name='icAddress1']")).sendKeys("123");
+        driver.findElement(By.xpath("//input[@name='icAddress2']")).sendKeys("123 RD");
+        driver.findElement(By.xpath("//input[@name='icCity']")).sendKeys("Chicago");
+        driver.findElement(By.xpath("//input[@name='icZip']")).sendKeys("54321");
+        driver.findElement(By.xpath("//input[@name='icPhone']")).sendKeys("0001234567");
+        driver.findElement(By.xpath("//input[@id='smoker_yes']")).click();
+        //driver.findElement(By.name("icState")).selectByValue("NC");
+        
+        
+        // Submit
+        driver.findElement(By.id("submit_preregister")).click();
+        
+        assertTrue(driver.findElement(By.xpath("//body")).getText().contains("New Pre-registered Patient Information"));
+    }
 
     public void testMissingElements() {
         goToPreRegister();
@@ -100,4 +132,18 @@ public class PreRegisterPatientTest extends iTrustSeleniumTest {
 
         assertTrue(driver.findElement(By.xpath("//body")).getText().contains("This form has not been validated correctly"));
     }
+    
+    public void testNonMatchPasswords() {
+        goToPreRegister();
+
+        driver.findElement(By.xpath("//input[@name='firstName']")).sendKeys("fname");
+        driver.findElement(By.xpath("//input[@name='lastName']")).sendKeys("lname");
+        driver.findElement(By.xpath("//input[@name='email']")).sendKeys("not-an-email");
+        driver.findElement(By.xpath("//input[@name='password']")).sendKeys("Password123");
+        driver.findElement(By.xpath("//input[@name='verifyPassword']")).sendKeys("Password1234");
+
+        driver.findElement(By.id("submit_preregister")).click();
+
+        assertFalse(driver.findElement(By.xpath("//body")).getText().contains("This form has not been validated correctly"));
+    }
 }
\ No newline at end of file
-- 
GitLab