// Creating A  Post and link With image attachments
  public HomePage composeImagePost() throws InterruptedException {
    composePageObjects.postTitleField.sendKeys(composePageObjects.title);
    composePageObjects.postContentField.sendKeys(composePageObjects.content);
    composePageObjects.imageAttachmentButton.click();
    composePageObjects.galleryButton.click();

    if (composePageObjects.galleryImages.size() > 0) {
      Reporter.log("Image present in gallery " + composePageObjects.galleryImages.size(), true);

      for (int i = 0; i <= 1; i++) {
        composePageObjects.galleryImages.get(i).click();
      }
      //				   TouchAction element=new TouchAction(driver);
      //				   element.tap(10, 165);
      composePageObjects.galleryOkButton.click();
    } else {
      driver.navigate().back();
      Reporter.log("No images present in Gallery");
    }

    composePageObjects.imageAttachmentButton.click();
    composePageObjects.cameraButton.click();
    composePageObjects.imageCaptureButton.click();
    composePageObjects.selectCapturedImageButton.click();
    linkAttachment();
    composePageObjects.submitButton.click();
    Thread.sleep(5000);

    return new HomePage(driver);
  }
Пример #2
0
  @Test
  public void saveForLaterPDP() throws Exception {
    cm.openHomePage(driver);
    Boolean isLoggedIn = cm.isLoggedIn(driver);

    if (isLoggedIn == true) {
      // logout to start test with desired logged out condition
      cm.logout(driver);
    }
    cm.login(driver, testEmailWithSavedCards, pswdForTestEmailWithSavedCards);
    System.out.println(
        "Using email " + testEmailWithSavedCards + " password " + pswdForTestEmailWithSavedCards);

    // pass locator for subcat you want to the method (here it is t-shirts)
    By locator_tshirtLink = map.getLocator("men_tshirtcss");
    cm.homePageMainNavMen(driver, locator_tshirtLink);

    Reporter.log("On Subcat page title is " + driver.getTitle());

    // 2/24 using new CommonMethod, '1' means it will click on 2nd product on subcat page
    cm.subcatPageClickProduct(driver, 1);

    // on PDP click on save for later and assert 'saved' msg displayed on the screen
    Reporter.log("On PDP page title is " + driver.getTitle());
    cm.pdpPageSaveForLater(driver);

    // ts.takeScreenshot(driver);

  }
Пример #3
0
  /**
   * The method creates an screenshot usually saved in output/screenshots It also adds the
   * screenshot to the index.html file generated by surefire-reports for ease of debugging The
   * method checks to see if the safari driver is used and if it is it will maximize the window so
   * that it catches most of the page.
   *
   * @param LOG_FILE //@param the parameter is used to form the file usually is
   *     test_errorLocation_failed.png
   * @param driver
   */
  public static void screenShooter(String LOG_FILE, WebDriver driver) {

    File dest = new File("test-output\\Screen.png");

    try {
      // ((TakesScreenshot)driver).getScreenshotAs(target)

      System.setProperty("org.uncommons.reportng.escape-output", "false");
      File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
      FileUtils.copyFile(scrFile, dest);
      String absolute = dest.getAbsolutePath();
      int beginIndex = absolute.indexOf(".");
      String relative = absolute.substring(beginIndex).replace(".\\", "");
      String screenShot = relative.replace('\\', '/');
      Reporter.log(
          "<a href=\"" + screenShot + "\"><p align=\"left\">Screenshot at " + new Date() + "</p>");
      Reporter.log(
          "<p style='border:1px solid red;'><img width=\"800\" src=\""
              + dest.getAbsoluteFile()
              + "\" alt=\"screenshot at "
              + new Date()
              + "\"/></p></a><br />");

    } catch (IOException e) {
      // Logger.Log(LOG_FILE, "Couldn't take the screenshot ",driver);
    }
  }
Пример #4
0
 // Check links on header for current page
 @Test(
     priority = 52,
     groups = {"Playlist"},
     description = "Проверяет ссылки на шапке на <<Мой плейлист>>")
 public void CheckHeader() throws Exception {
   driver.get(pageUrl);
   try {
     // my play list
     contentPage.PlayList.click();
     contentPage.PlayList.isDisplayed();
     assertEquals("Мой плейлист", contentPage.PlayList.getText());
     // music
     contentPage.Music.isDisplayed();
     assertEquals("МУЗЫКА", contentPage.Music.getText());
     // new music
     contentPage.NewMusic.isDisplayed();
     assertEquals("Новинки", contentPage.NewMusic.getText());
     // kazahs music
     contentPage.Kazahskaya.isDisplayed();
     assertEquals("Казахская", contentPage.Kazahskaya.getText());
     // upload
     contentPage.Upload.isDisplayed();
     assertEquals("Загрузить", contentPage.Upload.getText());
   } catch (NoSuchElementException e) {
     String errorUrl = driver.getCurrentUrl();
     log("FAILED: by no such element on page " + errorUrl);
     Reporter.log("FAILED: by no such element on page " + errorUrl);
     throw new NoSuchElementException();
   } catch (AssertionError e) {
     String errorUrl = driver.getCurrentUrl();
     log("FAILED: by assertion error on page " + errorUrl);
     Reporter.log("FAILED: by assertion error on page " + errorUrl);
     throw new AssertionError();
   }
 }
Пример #5
0
 private void printReport(Report report) {
   if (report == null) {
     Reporter.log("no report");
   } else {
     Reporter.log(report.getStatus().name() + " : " + report.getLocalizedMessage());
     printItems("   ", report.getItems());
   }
 }
  public void afterInvocation(IInvokedMethod method, ITestResult result) {
    resultT = result;
    String textMsg = "Completed executing " + returnMethodName(method.getTestMethod());
    Reporter.log(textMsg, true);

    Reporter.setCurrentTestResult(result);

    if (method.isTestMethod()) {

      List<Throwable> verificationFailures = TestBase.getVerificationFailures();

      // if there are verification failures...
      if (verificationFailures.size() > 0) {

        // set the test to failed
        result.setStatus(ITestResult.FAILURE);

        // if there is an assertion failure add it to verificationFailures
        if (result.getThrowable() != null) {
          verificationFailures.add(result.getThrowable());
        }

        int size = verificationFailures.size();
        // if there's only one failure just set that
        if (size == 1) {
          result.setThrowable(verificationFailures.get(0));
        } else {
          // create a failure message with all failures and stack traces (except last failure)
          StringBuffer failureMessage =
              new StringBuffer("Multiple failures (").append(size).append("):\n\n");
          for (int i = 0; i < size - 1; i++) {
            failureMessage
                .append("Failure ")
                .append(i + 1)
                .append(" of ")
                .append(size)
                .append(":\n");
            Throwable t = verificationFailures.get(i);
            String fullStackTrace = Utils.stackTrace(t, false)[1];
            failureMessage.append(fullStackTrace).append("\n\n");
          }

          // final failure
          Throwable last = verificationFailures.get(size - 1);
          failureMessage.append("Failure ").append(size).append(" of ").append(size).append(":\n");
          failureMessage.append(last.toString());

          // set merged throwable
          Throwable merged = new Throwable(failureMessage.toString());
          merged.setStackTrace(last.getStackTrace());

          result.setThrowable(merged);
        }
      }
    }
  }
  @Override
  public NumbersRecord readItem() throws Exception {
    int i = readerIndex;

    // Throw an exception when forcedFailCount is reached
    if (forcedFailCount != 0 && readerIndex >= forcedFailCount) {
      forcedFailCount = 0;
      failindex = readerIndex;
      testState = STATE_RETRY;
      Reporter.log("Fail on purpose NumbersRecord.readItem<p>");
      throw new MyParentException("Fail on purpose in NumbersRecord.readItem()");
    }

    if (testState == STATE_RETRY) {
      if (stepCtx.getProperties().getProperty("retry.read.exception.invoked") != "true") {
        Reporter.log("onRetryReadException not invoked<p>");
        throw new Exception("onRetryReadException not invoked");
      }

      if (stepCtx.getProperties().getProperty("retry.read.exception.match") != "true") {
        Reporter.log("retryable exception does not match");
        throw new Exception("retryable exception does not match");
      }

      testState = STATE_NORMAL;
    }

    if (readerIndex > 5) {
      return null;
    }

    Connection connection = null;
    PreparedStatement statement = null;
    ResultSet rs = null;

    try {
      connection = RetryConnectionHelper.getConnection(dataSource);

      statement = connection.prepareStatement(RetryConnectionHelper.SELECT_NUMBERS);
      statement.setInt(1, readerIndex);
      rs = statement.executeQuery();

      int quantity = -1;
      while (rs.next()) {
        quantity = rs.getInt("quantity");
      }

      readerIndex++;

      return new NumbersRecord(i, quantity);
    } catch (SQLException e) {
      throw e;
    } finally {
      RetryConnectionHelper.cleanupConnection(connection, rs, statement);
    }
  }
Пример #8
0
 private void takeScreenShot(ITestResult tr) {
   String screenName = String.valueOf(new Date().getTime()) + ".jpg";
   File dir = new File("test-output/snapshot");
   if (!dir.exists()) dir.mkdirs();
   String screenPath = dir.getAbsolutePath() + "/" + screenName;
   Reporter.setCurrentTestResult(tr);
   Reporter.log(screenPath);
   // 这里实现把图片链接直接输出到结果文件中,通过邮件发�?�结果则可以直接显示图片
   Reporter.log("<img src=\"../" + screenPath + "\"/>");
 }
Пример #9
0
  /**
   * // * @param nameMedicineShort // * @param nameMedicineFull
   *
   * @return
   * @throws IOException
   * @throws InterruptedException
   */
  public void createMedicinePostRandom(String nameOfMed, String reasonOfMed)
      throws InterruptedException {
    setNameOfMedicine(nameOfMed);
    WebElement nameOfMedicine;
    // creating list of proposed Eleemtns
    List<WebElement> nameOfMedicineList = nameOfMedicineOptions.findElements(By.tagName("li"));
    // picking random element
    Random rand = new Random();
    int nameOfMedicineCounter = rand.nextInt(1);
    nameOfMedicine = nameOfMedicineList.get(nameOfMedicineCounter);
    String name = nameOfMedicine.getText();
    Log.info("Choosing randomly name of medicine from list: " + name + " ");
    clickElement(nameOfMedicine);

    setReasonForMedicine(reasonOfMed);
    WebElement reasonForMedicine;
    List<WebElement> reasonForMedicineList =
        reasonForMedicineOptions.findElements(By.tagName("li"));
    Random rand2 = new Random();
    int nameOfReasonCounter = rand2.nextInt(1);
    reasonForMedicine = reasonForMedicineList.get(nameOfReasonCounter);
    String reason = reasonForMedicine.getText();
    Log.info("Choosing randomly name of medicine from list: " + reason + " ");
    clickElement(reasonForMedicine);

    Log.info("Typing text in 'Tell Us More' field: Testing post ");
    typeTellUsMore("Testing post");
    clickOnAllStarsTogether();
    rateFifeStars();
    clickOnPostButton();
    Log.info("Checking, that medicine and medicine reason are posted in a right way");
    name.equalsIgnoreCase(medicineName.getText());
    Log.info(
        "Medicine is posted in a right way: choosen "
            + name
            + ", posted "
            + medicineName.getText());
    Reporter.log(
        "Medicine is posted in a right way: choosen "
            + name
            + ", posted "
            + medicineName.getText());
    reason.equalsIgnoreCase(reasonName.getText());
    // Assert.assertEquals(reasonName.getText(), reason, "Medicine reason name doesen't match");
    Log.info(
        "Medicine reason is posted in a right way: choosen "
            + reason
            + ", posted "
            + reasonName.getText());
    Reporter.log(
        "Medicine is posted in a right way: choosen "
            + reason
            + ", posted "
            + reasonName.getText());
  }
 @BeforeMethod
 public void LaunchApplication() throws InterruptedException, AWTException, java.io.IOException {
   try {
     Reporter.log("Launching Retail URL  <br> <p>");
     launchBrowser(readConfig("urlRetail"));
   } catch (Exception e) {
     Reporter.log(e.toString());
   }
   Utilities.waitForDocumentReady(driver);
   driver.manage().timeouts().pageLoadTimeout(300000, TimeUnit.MILLISECONDS);
   Utilities.isElementPresent(PageBase.LoginPageRetail().usernameTextbox);
 }
Пример #11
0
  /**
   * This method is intended to provide initial setup. Creates any realms specified in the
   * setup-realms property in the AddRealmAttributesTest.properties file.
   */
  @Parameters({"testName"})
  @BeforeClass(
      groups = {
        "ldapv3",
        "ldapv3_sec",
        "s1ds",
        "s1ds_sec",
        "ad",
        "ad_sec",
        "amsdk",
        "amsdk_sec",
        "jdbc",
        "jdbc_sec"
      })
  public void setup(String testName) throws Exception {
    Object[] params = {testName};
    entering("setup", params);
    try {
      locTestName = testName;
      rb = ResourceBundle.getBundle("cli" + fileseparator + "AddRealmAttributesTest");
      setupRealms = (String) rb.getString(locTestName + "-create-setup-realms");
      useVerboseOption =
          ((String) rb.getString(locTestName + "-use-verbose-option")).equals("true");
      useDebugOption = ((String) rb.getString(locTestName + "-use-debug-option")).equals("true");
      useLongOptions = ((String) rb.getString(locTestName + "-use-long-options")).equals("true");

      log(Level.FINEST, "setup", "use-verbose-option: " + useVerboseOption);
      log(Level.FINEST, "setup", "use-debug-option: " + useDebugOption);
      log(Level.FINEST, "setup", "use-long-options: " + useLongOptions);
      log(Level.FINEST, "setup", "create-setup-realms: " + setupRealms);

      Reporter.log("UseDebugOption: " + useDebugOption);
      Reporter.log("UseVerboseOption: " + useVerboseOption);
      Reporter.log("UseLongOptions: " + useLongOptions);
      Reporter.log("SetupRealms: " + setupRealms);

      cli = new FederationManagerCLI(useDebugOption, useVerboseOption, useLongOptions);

      log(Level.FINE, "setup", "Creating the following realms: " + setupRealms);

      if (!cli.createRealms(setupRealms)) {
        log(Level.SEVERE, "setup", "All the realms failed to be created.");
        assert false;
      }

      exiting("setup");
    } catch (Exception e) {
      log(Level.SEVERE, "setup", e.getMessage(), null);
      e.printStackTrace();
      throw e;
    }
  }
  /**
   * Create Two users
   *
   * @throws Exception
   */
  @Test(groups = {"regressionSmoke", "fullSmoke", "criticalDataSmoke", "users.pesAdminCreateUsers"})
  public void testPesAdminUserCreation() throws Exception {
    a.navigateToMyContacts();
    a.navigateToCreateUserPage();
    userNamesArray[0][0] = a.createUser("teacher");
    Reporter.log("teacherUserName: "******"student");
    studentNameArray[0][0] = userNamesArray[0][1];
    Reporter.log("studentUserName: " + userNamesArray[0][1], true);
  }
Пример #13
0
  /**
   * This method remove any realms and identities that were created during the setup and
   * testRealmAddAttributeValues methods using "ssoadm delete-realm".
   */
  @AfterClass(
      groups = {
        "ldapv3",
        "ldapv3_sec",
        "s1ds",
        "s1ds_sec",
        "ad",
        "ad_sec",
        "amsdk",
        "amsdk_sec",
        "jdbc",
        "jdbc_sec"
      })
  public void cleanup() throws Exception {
    int exitStatus = -1;

    entering("cleanup", null);
    try {
      log(Level.FINEST, "cleanup", "useDebugOption: " + useDebugOption);
      log(Level.FINEST, "cleanup", "useVerboseOption: " + useVerboseOption);
      log(Level.FINEST, "cleanup", "useLongOptions: " + useLongOptions);

      Reporter.log("UseDebugOption: " + useDebugOption);
      Reporter.log("UseVerboseOption: " + useVerboseOption);
      Reporter.log("UseLongOptions: " + useLongOptions);

      if (!setupRealms.equals("")) {
        String[] realms = setupRealms.split(";");
        for (int i = realms.length - 1; i >= 0; i--) {
          log(Level.FINE, "cleanup", "Removing realm " + realms[i]);
          Reporter.log("SetupRealmToDelete: " + realms[i]);
          exitStatus = cli.deleteRealm(realms[i], true);
          cli.logCommand("cleanup");
          cli.resetArgList();
          if (exitStatus != SUCCESS_STATUS) {
            log(
                Level.SEVERE,
                "cleanup",
                "The removal of realm " + realms[i] + " failed with exit status " + exitStatus);
            assert false;
          }
        }
      }
      exiting("cleanup");
    } catch (Exception e) {
      log(Level.SEVERE, "cleanup", e.getMessage(), null);
      e.printStackTrace();
      throw e;
    }
  }
  @SuppressWarnings("unchecked")
  public Map<String, List<Map<String, String>>> getAddressbook(String msisdn, DB db) {
    DBCollection collection = db.getCollection(HikeConstants.MONGO_USERS_COLLECTION);
    DBObject result = collection.findOne(new BasicDBObject(HikeConstants.MSISDN, msisdn));

    if (result == null || result.get("addressbook") == null) {
      return null;
    }
    Map<String, List<Map<String, String>>> addressBookUploadedList =
        (Map<String, List<Map<String, String>>>) result.get("addressbook");
    Reporter.log("" + addressBookUploadedList);
    Reporter.log("" + addressBookUploadedList.size());
    return (Map<String, List<Map<String, String>>>) result.get("addressbook");
  }
Пример #15
0
  // PAGE OBJECT METHODS
  public void waitTillFeaturedPageIsDisplayed() throws Exception {
    Reporter.log(
        "Invoke Application: " + System.getProperty("AppName") + " to display Featured Page..");

    SeleniumFunctions.isElementPresent(driver, By.id(loginButton), 60);
    SeleniumFunctions.isElementPresent(driver, By.id(Search_Btn), 30);
  }
Пример #16
0
 /**
  * Fatal log
  *
  * @param message Message
  */
 public void fatal(final String message) {
   String msg = message;
   logger.fatal(message);
   msg = "<div class=\"failedConfig\">" + msg + "</div>"; // red color from reportng css
   Reporter.log(msg + "<br>");
   Assert.assertTrue(false, message);
 }
Пример #17
0
 /**
  * @param indent
  * @param items
  */
 private void printItems(String indent, List<ReportItem> items) {
   if (items == null) return;
   for (ReportItem item : items) {
     Reporter.log(indent + item.getStatus().name() + " : " + item.getLocalizedMessage());
     printItems(indent + "   ", item.getItems());
   }
 }
Пример #18
0
 @Test(priority = 6, dataProvider = "pageNavDataProvider")
 public void verifyPersonHpPageNavigation(String recordsToDisplay) {
   Assert.assertTrue(
       person.pageNavigation(recordsToDisplay), "person home page navigation does not work");
   logger.info("Test case passed: verify person home page pagination works fine");
   Reporter.log("Test case passed: verify person home page pagination works fine");
 }
Пример #19
0
 public void beforeInvocation(IInvokedMethod arg0, ITestResult arg1) {
   TestNG tn = new TestNG();
   tn.setDefaultTestName(returnMethodName(arg0.getTestMethod()));
   String textMsg = "About to begin executing " + returnMethodName(arg0.getTestMethod());
   method = returnMethodName(arg0.getTestMethod());
   Reporter.log(textMsg, true);
 }
 public void launchInventoryInNewTab(String storeID)
     throws InterruptedException, AWTException, java.io.IOException {
   driver.findElement(By.cssSelector("body")).sendKeys(Keys.CONTROL + "t");
   driver.get(readConfig("urlInventory"));
   Reporter.log("Successfully launched the Inventory Management page in new tab <br><p>");
   inventoryLogin(storeID);
 }
 /** @throws Exception */
 @Test(groups = {"users.coordinatorCreation"})
 public void testPesAdminCourseCoordinatorCreation() throws Exception {
   a.navigateToMyContacts();
   a.navigateToCreateUserPage();
   coordinatorNameArray[0][0] = a.createUser("coordinator");
   Reporter.log("coordinatorNamesArray: " + coordinatorNameArray[0][0], true);
 }
  @Test
  public void testRequiredServerConnectorInfo() throws Exception {
    AsyncConnectorInfoManager manager =
        localConnectorFramework.get().getRemoteManager(CONNECTION_INFO);
    Assert.assertNotNull(manager);

    manager = serverConnectorFramework.get().getServerManager("anonymous");
    Assert.assertNotNull(manager);

    ConnectorInfo c =
        manager
            .findConnectorInfoAsync(getTestConnectorKey())
            .getOrThrowUninterruptibly(5, TimeUnit.MINUTES);
    Assert.assertNotNull(c);

    Assert.assertNotNull(
        manager
            .findConnectorInfoAsync(getTestStatefulConnectorKey())
            .getOrThrowUninterruptibly(30, TimeUnit.SECONDS));

    Assert.assertNotNull(
        manager
            .findConnectorInfoAsync(getTestPoolableStatefulConnectorKey())
            .getOrThrowUninterruptibly(30, TimeUnit.SECONDS));

    for (ConnectorInfo ci : manager.getConnectorInfos()) {
      Reporter.log(String.valueOf(ci.getConnectorKey()), true);
    }
  }
Пример #23
0
  public void onTestFailure(ITestResult result) {
    Reporter.setCurrentTestResult(result);

    try {
      outputDirectory.mkdirs();
      File outFile = File.createTempFile("TEST-" + result.getName(), ".png", outputDirectory);
      outFile.delete();
      selenium.captureScreenshot(outFile.getAbsolutePath());
      Reporter.log("<a href='" + outFile.getName() + "'>screenshot</a>");
    } catch (Exception e) {
      e.printStackTrace();
      Reporter.log("Couldn't create screenshot");
      Reporter.log(e.getMessage());
    }

    Reporter.setCurrentTestResult(null);
  }
  protected void shutdownTest(ITestContext context) throws Exception {
    connectorServer.stop();
    connectorServer.destroy();

    serverConnectorFramework.release();
    localConnectorFramework.release();
    Reporter.log("Jetty Server Stopped", true);
  }
 // Clicks "Sign In" link and navigates to "Sign In" page
 public void clickSignInNav() {
   ((JavascriptExecutor) driver)
       .executeScript("window.scrollTo(0," + signInNavBar().getLocation().y + ")");
   wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(SIGN_IN_LINK)));
   signInNavBar().click();
   System.out.println("Navigating to Sign In page...");
   Reporter.log("Navigated to Sign In page");
 }
Пример #26
0
  public void VerifyDateShowInfoColumn() throws Exception {

    Reporter.log("Verify column headers present of 'Date', 'Show', and 'Information'.");
    List<WebElement> allColumns = waitFor.ElementsVisible(ProgramGuideTbl_Cls);
    Assert.assertTrue(allColumns.get(0).getText().contains("Date"));
    Assert.assertTrue(allColumns.get(1).getText().contains("Show"));
    Assert.assertTrue(allColumns.get(2).getText().contains("Information"));
  }
Пример #27
0
 @Test(priority = 2)
 public void verifyShowEntriesDropdownvalues() {
   Assert.assertTrue(person.getDropDownEntries(), "Show Entries drop down values does not match");
   logger.info(
       "Test case passed: verify user able to see values 10, 25, 50, 100 in 'Show entries' dropdown");
   Reporter.log(
       "Test case passed: verify user able to see values 10, 25, 50, 100 in 'Show entries' dropdown");
 }
 public static void VerifyPopUpForDelete() throws Exception {
   GenericClass.clickElement(FstCheckBox);
   GenericClass.clickElement(DeleteSeasonBtn);
   Alert al = GenericClass.driver.switchTo().alert();
   al.getText();
   al.dismiss();
   System.out.print("Alert Message");
   Reporter.log("Pop up showing when deleting Season", true);
 }
Пример #29
0
 @Test(priority = 3)
 public void verifyDefaultSelectedValueOfShowEntiresDropdown() {
   Assert.assertEquals(
       person.getdefaultSelectedShowEntriesOption(),
       "10",
       "By default, 10 is not selected in 'Show entries' dropdown");
   logger.info("Test case passed: verify by default, 10 is selected in 'Show entries' dropdown");
   Reporter.log("Test case passed: verify by default, 10 is selected in 'Show entries' dropdown");
 }
Пример #30
0
 @Test(priority = 7)
 public void verifyDiffPageNavLinkWorks() {
   Assert.assertTrue(
       person.clickOnDiffPageNavLinks(), "Different page navigation links do not work");
   logger.info(
       "Test case passed: verify page navigation links like First, Previous, Next and Last links work properly");
   Reporter.log(
       "Test case passed: verify page navigation links like First, Previous, Next and Last links work properly");
 }