Summary Table

Categories Total Count
PII 0
URL 0
DNS 0
EKL 0
IP 0
PORT 0
VsID 0
CF 0
AI 0
VPD 0
PL 0
Other 0

File Content

package automation.Pages;

import java.util.Map;
import java.util.Set;

import org.junit.Assert;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.UnhandledAlertException;
import org.openqa.selenium.WebElement;

import automation.ExplorerSuite;
import automation.SharedCodeClass;

public class EDI_PDI_VerifyQuickView_DetailView_PrintFunctionality extends ExplorerSuite {
private String pdiNumberDentalClaim = "200617203000952";
private String pdiNumberProfessionalClaim = "200617203000825";
private String pdiNumberInstitutionalClaim = "200617203000832";

public void localRunner() throws Exception {
System.out.println("Inside of EDI_PDI_VerifyQuickView_DetailView_PrintFunctionality.localRunner()!");

goToEdiWebViewerPage();

// Verify Print Functionality when the Dental Claim Quick View is selected.
retrieveClaimInformationUsingEwvSearchPage(pdiNumberDentalClaim);
verifyQuickViewSelected();
verifyPrintFunctionality();

// Verify Print Functionality when the Dental Claim Detail View is selected.
SharedCodeClass.clickById("TAB_detailTab_ewvMaster_1");
Thread.sleep(1000);
verifyDetailViewSelected();
verifyPrintFunctionality();

goToEdiWebViewerPage_v2();

// Verify Print Functionality when the Professional Claim Quick View is selected.
retrieveClaimInformationUsingEwvSearchPage(pdiNumberProfessionalClaim);
verifyQuickViewSelected();
verifyPrintFunctionality();

// Verify Print Functionality when the Professional Claim Detail View is selected.
SharedCodeClass.clickById("TAB_detailTab_ewvMaster_1");
Thread.sleep(1000);
verifyDetailViewSelected();
verifyPrintFunctionality();

goToEdiWebViewerPage_v2();

// Verify Print Functionality when the Institutional Claim Quick View is selected.
retrieveClaimInformationUsingEwvSearchPage(pdiNumberInstitutionalClaim);
verifyQuickViewSelected();
verifyPrintFunctionality();

// Verify Print Functionality when the Institutional Claim Detail View is selected.
SharedCodeClass.clickById("TAB_detailTab_ewvMaster_1");
Thread.sleep(1000);
verifyDetailViewSelected();
verifyPrintFunctionality();
}

public void retrieveClaimInformationUsingEwvSearchPage(String pdiNumber) throws Exception {
SharedCodeClass.fillAllElementById("IPT_pdiSearchNumber_ewvSearch_1", pdiNumber);
Thread.sleep(1000);
SharedCodeClass.clickById("BTN_pdiSearchRetrieve_ewvSearch_1");

Thread.sleep(5000);

// Below no longer exists due to changes made by our Style Sheet Expert (J.A.).
// SharedCodeClass.findElementId("DIV_ediWebViewer_ewv_1");
// WebElement webElement = driver.findElement(By.id("DIV_ediWebViewer_ewv_1"));
// Assert.assertEquals("EDI Web Viewer / " + pdiNumber, webElement.getText());

SharedCodeClass.findElementId("HDG_ediWebViewer_ewv_1");
WebElement webElement = driver.findElement(By.id("HDG_ediWebViewer_ewv_1"));
Assert.assertEquals("EDI Web Viewer | " + pdiNumber, webElement.getText());
}

public void goToEdiWebViewerPage() throws Exception {
SharedCodeClass.clickById("NAV_ewvSearch_appNav_1");
Thread.sleep(4000);

SharedCodeClass.findElementId("HDG_ediWebViewer_ewvSearch_1");
SharedCodeClass.findElementId("IPT_pdiSearchNumber_ewvSearch_1");
SharedCodeClass.findElementId("BTN_pdiSearchRetrieve_ewvSearch_1");
SharedCodeClass.findElementId("BTN_pdiClear_ewvSearch_1");
}

public void goToEdiWebViewerPage_v2() throws Exception {
driver.get(baseUrl + "/ewvSearch");
Thread.sleep(4000);

SharedCodeClass.findElementId("HDG_ediWebViewer_ewvSearch_1");
SharedCodeClass.findElementId("IPT_pdiSearchNumber_ewvSearch_1");
SharedCodeClass.findElementId("BTN_pdiSearchRetrieve_ewvSearch_1");
SharedCodeClass.findElementId("BTN_pdiClear_ewvSearch_1");
}

public void verifyQuickViewSelected() throws Exception {
WebElement quickViewTabElement = driver.findElement(By.id("TAB_qvTab_ewvMaster_1"));
WebElement detailViewTabElement = driver.findElement(By.id("TAB_detailTab_ewvMaster_1"));

Assert.assertTrue("Quick View Tab should be selected!", quickViewTabElement.isSelected());
Assert.assertFalse("Detail View Tab should not be selected!", detailViewTabElement.isSelected());
}

public void verifyDetailViewSelected() throws Exception {
WebElement quickViewTabElement = driver.findElement(By.id("TAB_qvTab_ewvMaster_1"));
WebElement detailViewTabElement = driver.findElement(By.id("TAB_detailTab_ewvMaster_1"));

Assert.assertFalse("Quick View Tab should not be selected!", quickViewTabElement.isSelected());
Assert.assertTrue("Detail View Tab should be selected!", detailViewTabElement.isSelected());
}

public void verifyPrintFunctionality() throws Exception {
SharedCodeClass.clickById("IMG_printIcon_ewvMaster_1");
Thread.sleep(4000);

// No real definitive way to test Print Dialog appears when pressing Print Button in
// Selenium.

// Alert printDialog = driver.switchTo().alert();
// System.out.println("printDialog.getText() = " + printDialog.getText());
// System.out.println("printDialog.toString() = " + printDialog.toString());
// // printDialog.accept();
// printDialog.dismiss();

Set<String> windowHandlesSet = null;
UnhandledAlertException unhandledAlertException = null;
try {
// If a Print Dialog does appear, then the below will generate an UnhandledAlertException.
windowHandlesSet = driver.getWindowHandles();
// for (String windowHandle: windowHandlesSet) {
// System.out.println("windowHandle = " + windowHandle);
// }
} catch (UnhandledAlertException ex) {
// System.out.println("UnhandledAlertException occurred!");

// If this Exception occurs, that's a good indication that a print Dialog popped up when the
// Print Button was pressed. This Exception will also cause the Print Dialog to go away, so
// we do not have to worry about dismissing it.
unhandledAlertException = ex;
}

if (unhandledAlertException == null) {
Assert.fail("No Print Dialog appeared after Print button was pressed!");
} else {
// System.out.println("unhandledAlertException.getMessage() = " + unhandledAlertException.getMessage());
// System.out.println();
// System.out.println("unhandledAlertException.getAlertText() = " + unhandledAlertException.getAlertText());
// System.out.println();
// System.out.println("unhandledAlertException.getAdditionalInformation() = " + unhandledAlertException.getAdditionalInformation());

Assert.assertEquals("Expected some Print Modal Dialog but obtained some other type of Alert!",
"Modal dialog present: Status:", unhandledAlertException.getMessage().substring(0, 29));

// Map<String, String> anAlert = unhandledAlertException.getAlert();
// Set<String> alertKeySet = anAlert.keySet();
// for (String alertKey: alertKeySet) {
// System.out.println("alertKey = " + alertKey);
// System.out.println(" value = " + anAlert.get(alertKey));
// }
}
}
}