/**
   * This is constructor for this class. It validates that the user is on Meal Plans Page.
   *
   * @param selenium
   */
  public MealPlansPage(LoggingSelenium selenium) {
    selenium.logComment("Executing constructor of Meal Plans Page");
    this.selenium = selenium;

    assertTrue(
        "This is not Meal Plans Page of logged in user, current page " + selenium.getLocation(),
        selenium.getTitle().equals("Meal Plans"),
        selenium);
  }
 /**
  * This is constructor for this class. It validates that the user is on The Beachbody Challenge
  * Page.
  *
  * @param selenium
  */
 public TheBeachbodyChallengePage(LoggingSelenium selenium) {
   selenium.logComment("Executing constructor of Beachbody Challenge Page");
   this.selenium = selenium;
   assertTrue(
       "This is not The Beachbody Challenge Page of logged in user, current page "
           + selenium.getLocation(),
       selenium.getTitle().equals("Team Beachbody - The Beachbody Challenge"),
       selenium);
 }
 /**
  * This is constructor for this class. It validates that the user is on Shakeology And Supplements
  * Page.
  *
  * @param selenium
  */
 public ShakeologyAndSupplementsPage(LoggingSelenium selenium) {
   selenium.logComment("Executing constructor of Shakeology And Supplements Page");
   this.selenium = selenium;
   assertTrue(
       "This is not Shakeology And Supplements Page of logged in user, current page "
           + selenium.getLocation(),
       selenium.getTitle().equals("Team Beachbody - Eat Smart: Supplements"),
       selenium);
 }
Example #4
0
  /**
   * This method takes screen shot of web page. After taking screen shot, it saves that to file with
   * test method name and time stamp. This also writes a comment (having link to screenshot) to
   * selenium logging file created through LoggingSelenium.
   */
  public void captureScreenShot(LoggingSelenium selenium, String screenshotsResultsPath) {

    try {

      final String SCREENSHOT_PATH = "screenshots";
      /*
      String screenshotsResultsPath = new File(RESULTS_BASE_PATH
      		+ File.separator + SCREENSHOT_PATH).getAbsolutePath();


      if (!new File(screenshotsResultsPath).exists()) {
      	new File(screenshotsResultsPath).mkdirs();
      }*/

      String imageName = "Image" + timeStampForFileName() + ".png";

      String finalImage = screenshotsResultsPath + File.separator + imageName;

      String browser = ConfigFileReader.getConfigItemValue("browser");
      if (browser.equals("*chrome") || browser.equals("*firefox") || browser.equals("*iehta")) {
        // call captureEntirePageScreenshotToString method and it will
        // return Base64 encoded string referring to screen shot
        String base64Screenshot = selenium.captureEntirePageScreenshotToString("");

        // Decode that Base64 encoded string to get actual screen shot.
        // Finally this screen shot will be written to file object.
        byte[] decodedScreenshot = Base64.decode(base64Screenshot);

        // create instance of FileOutputStream by passing it filename
        FileOutputStream fos = new FileOutputStream(new File(finalImage));

        // Write decoded screenshot to fileoutputstream object
        fos.write(decodedScreenshot);
        fos.close();
      } else {
        selenium.captureScreenshot(finalImage);
      }

      String failedSS =
          "<a href=\"file://" + finalImage + "\">Screenshot for previous action " + "</a>";
      logger.debug(finalImage);
      // selenium.logComment(failedSS);
      selenium.logComment(
          "<a href=\""
              + SCREENSHOT_PATH
              + "/"
              + imageName
              + "\"><img src=\""
              + SCREENSHOT_PATH
              + "/"
              + imageName
              + "\" alt=\"Page Screen Shot\" width=\"150\" height=\"300\" border=\"5\"/></a>");
    } catch (Exception e) {
      e.printStackTrace();
    }
  }