Ejemplo n.º 1
0
 private void TypesOfSchool() throws IOException {
   // Click Type of School
   driver.findElement(By.cssSelector("strong")).click();
   // Click Private
   driver.findElement(By.id("edit-public-private-private")).click();
   // Move School Size Slider
   // TODO Slider not working properly
   WebElement Slider1 = driver.findElement(By.id("population_jq_slider"));
   Actions moveSlider1 = new Actions(driver);
   Action action1 = moveSlider1.dragAndDropBy(Slider1, 0, 10).build();
   action1.perform();
   // Select Religious Affiliation
   new Select(driver.findElement(By.id("edit-religious-affiliation")))
       .selectByVisibleText("Church of Christ");
   // Move Tuition Range Slider
   // TODO Slider not working properly
   WebElement Slider2 = driver.findElement(By.id("tuition_range_jq_slider"));
   Actions moveSlider2 = new Actions(driver);
   Action action2 = moveSlider2.dragAndDropBy(Slider2, 0, 10).build();
   action2.perform();
   // Click Apply
   driver.findElement(By.id("edit-type-of-school-apply-filter")).click();
   // Check Result Received or Not
   try {
     assertTrue(
         func.isTextPresent(driver.findElement(By.className("search-total-results")).getText()));
   } catch (Error e) {
     verificationErrors.append(e.toString());
   }
   // Click All Selections
   driver.findElement(By.linkText("Clear All Selections")).click();
 }
Ejemplo n.º 2
0
 private void AreaOfStudy() throws IOException, InterruptedException {
   // Click Area of School
   driver
       .findElement(
           By.xpath(
               "//ul[@class='vertical-tabs-list']/li/a/strong[contains(text(), \"Area of Study\")]"))
       .click();
   // Select One Area Study
   new Select(driver.findElement(By.id("edit-area-of-study-parent")))
       .selectByVisibleText("Area, Ethnic, Cultural, and Gender Studies");
   // Wait For Another Select List To Load
   Thread.sleep(5000);
   // Select Subareas of Study
   new Select(driver.findElement(By.xpath("//div[@id='child-area-of-study-wrapper']//select")))
       .selectByVisibleText("Area, Ethnic, Cultural, and Gender Studies, Other");
   // Click Apply
   driver.findElement(By.id("edit-area-of-study-apply-filter")).click();
   // Check Result Received or Not
   try {
     assertTrue(
         func.isTextPresent(driver.findElement(By.className("search-total-results")).getText()));
   } catch (Error e) {
     verificationErrors.append(e.toString());
   }
   // Click All Selections
   driver.findElement(By.linkText("Clear All Selections")).click();
 }
Ejemplo n.º 3
0
 private void Location() throws IOException {
   // Click Location
   driver
       .findElement(
           By.xpath(
               "//ul[@class='vertical-tabs-list']/li/a/strong[contains(text(), \"Location\")]"))
       .click();
   // Click West Checkbox
   // TODO Do not use number in Locator
   driver.findElement(By.xpath("//fieldset[6]/div/div[4]/div/div[3]/input")).click();
   // Click South Checkbox
   // TODO Do not use number in Locator
   driver.findElement(By.xpath("//fieldset[6]/div/div[4]/div/div[6]/input")).click();
   // Click Apply
   driver.findElement(By.id("edit-location-apply-filter")).click();
   // Check Result Received or Not
   try {
     assertTrue(
         func.isTextPresent(driver.findElement(By.className("search-total-results")).getText()));
   } catch (Error e) {
     verificationErrors.append(e.toString());
   }
   // Click All Selections
   driver.findElement(By.linkText("Clear All Selections")).click();
 }
Ejemplo n.º 4
0
 private void ActivitiesOfInterest() throws IOException {
   // Click Activities of Interest
   driver
       .findElement(
           By.xpath(
               "//ul[@class='vertical-tabs-list']/li/a/strong[contains(text(), \"Activities of Interest\")]"))
       .click();
   // Click Student Newspaper Checkbox
   // TODO Do not use number in locator
   driver.findElement(By.xpath("//div[11]/input")).click();
   // Click TV Station Checkbox
   // TODO Do not use number in locator
   driver.findElement(By.xpath("//div[13]/input")).click();
   // Click Apply
   driver.findElement(By.id("edit-activities-interests-apply-filter")).click();
   // Check Result Received or Not
   try {
     assertTrue(
         func.isTextPresent(driver.findElement(By.className("search-total-results")).getText()));
   } catch (Error e) {
     verificationErrors.append(e.toString());
   }
   // Click All Selections
   driver.findElement(By.linkText("Clear All Selections")).click();
 }
Ejemplo n.º 5
0
  @Test
  public void testGotoFinalReview() throws Exception {

    // Goto Final Review page
    driver.findElement(By.xpath("//a[contains(text(), 'Final Review')]")).click();
    try {
      assertEquals(
          "Final Review", driver.findElement(By.xpath("//*[@id='container']/h3")).getText());
    } catch (Error e) {
      screenShots.takeScreenShot("gotoFinalReview");
      verificationErrors.append(e.toString());
    }

    Thread.sleep(300);
    // Find where the warning is displayed and scroll it into view, then screenshot it.
    // We look for 'Scholarship and Sponsorship' since the warning is in the 'Qualifications' area
    // and the scrolling is causing a heading right where we scroll to and covers it.
    WebElement elem =
        driver.findElement(By.xpath("//h4[contains(text(), 'Scholarship and Sponsorship')]"));
    ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", elem);
    Thread.sleep(300);
    screenShots.takeScreenShot("FinalReviewWarnMsgNoQualifEntrd");

    // Go back to application
    driver.findElement(By.cssSelector("#link_to_application > span")).click();
  }
Ejemplo n.º 6
0
 private void SpecialNeeds() throws IOException {
   // Click Special Needs
   driver
       .findElement(
           By.xpath(
               "//ul[@class='vertical-tabs-list']/li/a/strong[contains(text(), \"Special Needs\")]"))
       .click();
   // Select Special Needs
   Select SpecialNeeds = new Select(driver.findElement(By.id("edit-special-needs")));
   // Select Learning Center
   SpecialNeeds.selectByVisibleText("Learning Center");
   // Select Early Syllabus
   SpecialNeeds.selectByVisibleText("Early syllabus");
   // Click Apply
   driver.findElement(By.id("edit-special-needs-apply-filter")).click();
   // Check Result Received or Not
   try {
     assertTrue(
         func.isTextPresent(driver.findElement(By.className("search-total-results")).getText()));
   } catch (Error e) {
     verificationErrors.append(e.toString());
   }
   // Click All Selections
   driver.findElement(By.linkText("Clear All Selections")).click();
 }
 public void testExceptionHandling() {
   final ComponentAdapter componentAdapter =
       new ThreadLocalizing.ThreadLocalized(
           new ConstructorInjection.ConstructorInjector(
               TargetInvocationExceptionTester.class, ThrowingComponent.class, null));
   final TargetInvocationExceptionTester tester =
       (TargetInvocationExceptionTester)
           componentAdapter.getComponentInstance(null, ComponentAdapter.NOTHING.class);
   try {
     tester.throwsCheckedException();
     fail("ClassNotFoundException expected");
   } catch (final ClassNotFoundException e) {
     assertEquals("junit", e.getMessage());
   }
   try {
     tester.throwsRuntimeException();
     fail("RuntimeException expected");
   } catch (final RuntimeException e) {
     assertEquals("junit", e.getMessage());
   }
   try {
     tester.throwsError();
     fail("Error expected");
   } catch (final Error e) {
     assertEquals("junit", e.getMessage());
   }
 }
Ejemplo n.º 8
0
  @Test
  public void testOtsi() throws Exception {
    driver.get(baseUrl + "/");
    driver.findElement(By.linkText("Kandidaadid")).click();
    // Warning: waitForTextPresent may require manual changes
    for (int second = 0; ; second++) {
      if (second >= 60) fail("timeout");
      try {
        if (driver
            .findElement(By.cssSelector("BODY"))
            .getText()
            .matches("^[\\s\\S]*Vana Kala[\\s\\S]*$")) break;
      } catch (Exception e) {
      }
      Thread.sleep(1000);
    }

    driver.findElement(By.id("nimi")).clear();
    driver.findElement(By.id("nimi")).sendKeys("Magdalena");
    try {
      assertEquals("Magdalena", driver.findElement(By.id("nimi")).getAttribute("value"));
    } catch (Error e) {
      verificationErrors.append(e.toString());
    }
    driver.findElement(By.id("sButton")).click();
    // Warning: waitForTextPresent may require manual changes
    for (int second = 0; ; second++) {
      if (second >= 60) fail("timeout");
      try {
        if (driver
            .findElement(By.cssSelector("BODY"))
            .getText()
            .matches("^[\\s\\S]*Magdalena Malejeva[\\s\\S]*$")) break;
      } catch (Exception e) {
      }
      Thread.sleep(1000);
    }

    // Warning: verifyTextNotPresent may require manual changes
    try {
      assertFalse(
          driver
              .findElement(By.cssSelector("BODY"))
              .getText()
              .matches("^[\\s\\S]*Vana Kala[\\s\\S]*$"));
    } catch (Error e) {
      verificationErrors.append(e.toString());
    }
  }
Ejemplo n.º 9
0
 private void SearchButton() throws IOException {
   // Enter Text To Be Search
   driver.findElement(By.id("edit-keys")).clear();
   driver.findElement(By.id("edit-keys")).sendKeys("Abilene");
   // Click Search
   driver.findElement(By.id("edit-submit")).click();
   // Check Result Received or Not
   try {
     assertTrue(
         func.isTextPresent(driver.findElement(By.className("search-total-results")).getText()));
   } catch (Error e) {
     verificationErrors.append(e.toString());
   }
   // Click All Selections
   driver.findElement(By.linkText("Clear All Selections")).click();
 }
Ejemplo n.º 10
0
  @Test(
      dataProvider = "addNewAgentApplicant",
      dataProviderClass = applicantDataInternationalNewApplicant.class)
  public void testEnterDataAddNewApplicant(
      String loginEmail,
      String loginPassword,
      String firstName,
      String lastName,
      String birthDay,
      String birthMonth,
      String birthYear)
      throws Exception {

    // Add new applicant to Agent
    Thread.sleep(300);
    // Test case from HERE to CITIZENSHIP will fail if the applicant already exists.
    driver.findElement(By.id("field-email")).clear();
    driver.findElement(By.id("field-email")).sendKeys(loginEmail);
    Thread.sleep(150);
    driver.findElement(By.id("field-confirmEmail")).clear();
    driver.findElement(By.id("field-confirmEmail")).sendKeys(loginEmail);

    Thread.sleep(100);
    driver.findElement(By.id("field-firstName")).clear();
    driver.findElement(By.id("field-firstName")).sendKeys(firstName);

    driver.findElement(By.id("field-lastName")).clear();
    driver.findElement(By.id("field-lastName")).sendKeys(lastName);

    new Select(driver.findElement(By.name("dayOfBirth"))).selectByVisibleText(birthDay);
    new Select(driver.findElement(By.name("monthOfBirth"))).selectByVisibleText(birthMonth);
    new Select(driver.findElement(By.name("yearOfBirth"))).selectByVisibleText(birthYear);

    driver.findElement(By.xpath("//button[@type='submit']")).click();

    System.out.println("Applicant = " + loginEmail);
    Thread.sleep(500);

    try {
      assertEquals(
          "Profile Information", driver.findElement(By.cssSelector("h3.col-xs-12")).getText());
    } catch (Error e) {
      screenShots.takeScreenShot("enterDataAddNewAppl");
      verificationErrors.append(e.toString());
    }
  }
Ejemplo n.º 11
0
  @Test(
      dataProvider = "addCitizenshipInfo",
      dataProviderClass = applicantDataDomesticNewApplicant.class)
  public void testEnterDataCitizenshipResidencyDomestic(
      String citizenshipType,
      String domesticType,
      String fieldCitizenshipCountryId,
      String fieldBirthCountryId,
      String fieldResidenceCountryId,
      String ATSI)
      throws Exception {

    // Enter Citizenship
    driver.findElement(By.id(citizenshipType)).click();
    driver.findElement(By.id(domesticType)).click();

    Thread.sleep(300);
    selectFromSelect2.SelectDropDownOption("field-birthCountryId", fieldBirthCountryId);
    Thread.sleep(300);
    selectFromSelect2.SelectDropDownOption("field-residenceCountryId", fieldResidenceCountryId);

    driver.findElement(By.id("field-" + ATSI)).click();

    driver.findElement(By.xpath("//input[@value='Save']")).click();
    for (int second = 0; ; second++) {
      if (second >= 60) fail("timeout");
      try {
        if ("Saved".equals(driver.findElement(By.cssSelector("div.toast-message")).getText()))
          break;
      } catch (Exception e) {
        screenShots.takeScreenShot("enterDataCitResDom1");
      }
      Thread.sleep(1000);
    }

    // Goto Home or Dashboard
    driver.findElement(By.cssSelector("span.link-to-dashboard.dashboard-text")).click();
    try {
      assertEquals(
          "Profile Information", driver.findElement(By.cssSelector("h3.col-xs-12")).getText());
    } catch (Error e) {
      screenShots.takeScreenShot("enterDataCitResDom2");
      verificationErrors.append(e.toString());
    }
  }
Ejemplo n.º 12
0
 private void Sports() throws IOException {
   // Click Sports
   driver
       .findElement(
           By.xpath("//ul[@class='vertical-tabs-list']/li/a/strong[contains(text(), \"Sports\")]"))
       .click();
   // Select Sports
   Select Sports = new Select(driver.findElement(By.id("edit-varsity-sports")));
   // Select Baseball
   Sports.selectByVisibleText("baseball");
   // Select Basketball
   Sports.selectByVisibleText("basketball");
   // Click Apply
   driver.findElement(By.id("edit-varsity-sports-apply-filter")).click();
   // Check Result Received or Not
   try {
     assertTrue(
         func.isTextPresent(driver.findElement(By.className("search-total-results")).getText()));
   } catch (Error e) {
     verificationErrors.append(e.toString());
   }
   // Click All Selections
   driver.findElement(By.linkText("Clear All Selections")).click();
 }
Ejemplo n.º 13
0
 @Test
 public void testRegistreerimine() throws Exception {
   driver.get(baseUrl + "/login");
   driver.findElement(By.xpath("//button[5]")).click();
   driver.findElement(By.id("kasutajanimi")).clear();
   driver.findElement(By.id("kasutajanimi")).sendKeys("Testkasutaja");
   driver.findElement(By.id("eesnimi")).clear();
   driver.findElement(By.id("eesnimi")).sendKeys("Test");
   driver.findElement(By.id("perenimi")).clear();
   driver.findElement(By.id("perenimi")).sendKeys("Kasutaja");
   driver.findElement(By.id("parool")).clear();
   driver.findElement(By.id("parool")).sendKeys("testkasutaja");
   driver.findElement(By.id("email")).clear();
   driver.findElement(By.id("email")).sendKeys("*****@*****.**");
   driver.findElement(By.id("telnr")).clear();
   driver.findElement(By.id("telnr")).sendKeys("55123123");
   driver.findElement(By.id("regamisnupp")).click();
   try {
     assertEquals(
         "Registreerimine õnnestus!", driver.findElement(By.xpath("//div/div/div/div")).getText());
   } catch (Error e) {
     verificationErrors.append(e.toString());
   }
 }
Ejemplo n.º 14
0
  @Test
  public void testWeather() throws Exception {
    driver.get(baseUrl + "/");
    driver.findElement(By.linkText("Edmonton")).click();
    for (int second = 0; ; second++) {
      if (second >= 60) fail("timeout");
      try {
        if (isElementPresent(By.id("cityjump"))) break;
      } catch (Exception e) {
      }
      Thread.sleep(1000);
    }

    // Warning: verifyTextPresent may require manual changes
    try {
      assertTrue(
          driver
              .findElement(By.cssSelector("BODY"))
              .getText()
              .matches("^[\\s\\S]*Current Conditions[\\s\\S]*$"));
    } catch (Error e) {
      verificationErrors.append(e.toString());
    }
    // Warning: verifyTextPresent may require manual changes
    try {
      assertTrue(
          driver
              .findElement(By.cssSelector("BODY"))
              .getText()
              .matches("^[\\s\\S]*Forecast[\\s\\S]*$"));
    } catch (Error e) {
      verificationErrors.append(e.toString());
    }
    // Warning: verifyTextPresent may require manual changes
    try {
      assertTrue(
          driver
              .findElement(By.cssSelector("BODY"))
              .getText()
              .matches("^[\\s\\S]*Edmonton City Centre Airport[\\s\\S]*$"));
    } catch (Error e) {
      verificationErrors.append(e.toString());
    }
  }
  @Test(
      dataProvider = "addNewApplicant",
      dataProviderClass = applicantDataDomesticNewApplicant.class)
  public void testRegisterAccount(
      String loginEmail,
      String loginPassword,
      String firstName,
      String lastName,
      String birthDay,
      String birthMonth,
      String birthYear)
      throws Exception {
    // Register New Account
    driver.findElement(By.id("field-firstName")).clear();
    driver.findElement(By.id("field-firstName")).sendKeys(firstName);

    driver.findElement(By.id("field-lastName")).clear();
    driver.findElement(By.id("field-lastName")).sendKeys(lastName);

    new Select(driver.findElement(By.name("day"))).selectByVisibleText(birthDay);
    new Select(driver.findElement(By.name("month"))).selectByVisibleText(birthMonth);
    new Select(driver.findElement(By.name("year"))).selectByVisibleText(birthYear);

    driver.findElement(By.id("field-email")).clear();
    driver.findElement(By.id("field-email")).sendKeys(loginEmail);

    driver.findElement(By.id("field-confirmEmail")).clear();
    driver.findElement(By.id("field-confirmEmail")).sendKeys(loginEmail);

    driver.findElement(By.id("field-password")).clear();
    driver.findElement(By.id("field-password")).sendKeys(loginPassword);

    driver.findElement(By.id("field-confirmPassword")).clear();
    driver.findElement(By.id("field-confirmPassword")).sendKeys(loginPassword);

    driver.findElement(By.id("field-terms")).click();

    driver.findElement(By.xpath("(//button[@type='submit'])[2]")).click();
    try {
      assertEquals(
          "Successfully registered.",
          driver.findElement(By.cssSelector("div.alert.alert-success")).getText());
    } catch (Error e) {
      screenShots.takeScreenShot("registerAcct_outp");
      verificationErrors.append(e.toString());
    }
    System.out.println("Applicant = " + loginEmail + " Password = " + loginPassword);

    // Write out the Applicants email address to the output file created in gotoSite.java
    // First create object of java FileWriter and BufferedWriter class.
    String WriteFile = generateFileName();
    FileWriter FW = new FileWriter(WriteFile);
    BufferedWriter BW = new BufferedWriter(FW);
    BW.write(loginEmail); // Writing applicants login to File.
    BW.newLine(); // To write next string on new line.
    BW.write(lastName); // Writing applicants lastname to File.
    BW.newLine(); // To write next string on new line.
    BW.write(firstName); // Writing applicants first name to File.
    BW.newLine(); // To write next string on new line.
    BW.close();
  }