use of exceptions.AutomationException in project cvs-auto-svc by dvsa.
the class WebDriverBrowsertack method checkAtfEmailDetails.
public static void checkAtfEmailDetails(WebDriver driver, String testStationName, String testStationPNumber, String testerName, String startDate, String startTime) {
FluentWait wait = new FluentWait<>(driver).withTimeout(Duration.ofSeconds(10)).pollingEvery(Duration.ofMillis(250)).ignoring(NoSuchElementException.class);
System.out.println("Checking the email title details are correct");
wait.until(ExpectedConditions.and(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("div[role='main']>div:nth-of-type(1)")), ExpectedConditions.presenceOfElementLocated(By.cssSelector("div[role='main']>div:nth-of-type(1)"))));
String actualString = driver.findElement(By.cssSelector("div[role='main']>div:nth-of-type(1)")).getText();
String expectedString = "DVSA Commercial Vehicle Service – Site Activity Report: " + testStationPNumber + " – " + testerName + " – " + startDate;
try {
assertEquals(expectedString, actualString);
} catch (AssertionError e) {
throw new AutomationException("Expected string " + expectedString + " is not identical to actual string " + actualString);
}
System.out.println("Checking the details in the email are correct");
wait.until(ExpectedConditions.numberOfElementsToBeMoreThan(By.cssSelector("div[class^='rps']>div>table:nth-of-type(4)>tbody>tr:nth-of-type(2)>td:nth-of-type(2)>p:first-of-type"), 0));
String actualString1 = driver.findElement(By.cssSelector("div[class^='rps']>div>table:nth-of-type(4)>tbody>tr:nth-of-type(2)>td:nth-of-type(2)>p:first-of-type")).getText();
String expectedString1 = "Please find below the report for the activities conducted on " + startDate + " by " + testerName + ".";
try {
assertTrue(actualString1.contains(expectedString1));
} catch (AssertionError e) {
throw new AutomationException("Actual string '" + actualString1 + "' does not contain expected string '" + expectedString1 + "'");
}
wait.until(ExpectedConditions.and(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("div[class^='rps']>div>table:nth-of-type(4)>tbody>tr:nth-of-type(2)>td:nth-of-type(2)>p:nth-of-type(3)")), ExpectedConditions.presenceOfElementLocated(By.cssSelector("div[class^='rps']>div>table:nth-of-type(4)>tbody>tr:nth-of-type(2)>td:nth-of-type(2)>p:nth-of-type(3)"))));
String siteVisitDetailsText = driver.findElement(By.cssSelector("div[class^='rps']>div>table:nth-of-type(4)>tbody>tr:nth-of-type(2)>td:nth-of-type(2)>p:nth-of-type(3)")).getText();
String expectedString2 = "Site: " + testStationName + " – " + testStationPNumber;
String expectedString3 = "Assessor: " + testerName;
String expectedString4 = "Date: " + startDate;
String expectedString5 = "Start Time: " + startTime;
try {
assertTrue(siteVisitDetailsText.contains(expectedString2));
} catch (AssertionError e) {
throw new AutomationException("Actual string '" + siteVisitDetailsText + "' does not contain expected string '" + expectedString2 + "'");
}
try {
assertTrue(siteVisitDetailsText.contains(expectedString3));
} catch (AssertionError e) {
throw new AutomationException("Actual string '" + siteVisitDetailsText + "' does not contain expected string '" + expectedString3 + "'");
}
try {
assertTrue(siteVisitDetailsText.contains(expectedString4));
} catch (AssertionError e) {
throw new AutomationException("Actual string '" + siteVisitDetailsText + "' does not contain expected string '" + expectedString4 + "'");
}
try {
assertTrue(siteVisitDetailsText.contains(expectedString5));
} catch (AssertionError e) {
throw new AutomationException("Actual string '" + siteVisitDetailsText + "' does not contain expected string '" + expectedString5 + "'");
}
driver.close();
driver.quit();
}
use of exceptions.AutomationException in project cvs-auto-svc by dvsa.
the class DataMapper method getTestTypeById.
public static TestTypeById getTestTypeById(String testTypeClassification, String forVehicleType, String forVehicleSize, String forVehicleConfiguration, String forVehicleAxles) {
TestTypeById testTypeByIdReturned = null;
ClassLoader classLoader = new DataMapper().getClass().getClassLoader();
try {
ObjectMapper objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
TestTypeById[] node = objectMapper.readValue(readFromInputStream(classLoader.getResourceAsStream("loader/" + BaseData.getDataLocation() + "/test-type-by-id.json")), TestTypeById[].class);
List<TestTypeById> list = Arrays.asList(node);
testTypeByIdReturned = findTestType(list, testTypeClassification, forVehicleType, forVehicleSize, forVehicleConfiguration, forVehicleAxles);
} catch (IOException e) {
throw new AutomationException("Error: " + e.getMessage());
}
if (testTypeByIdReturned == null) {
throw new AutomationException("Error finding test type by id. Check file contents: test-type-by-id.json");
}
return testTypeByIdReturned;
}
Aggregations