Skip to content

Commit

Permalink
LIME-1299 - Added Welsh Lang Tests for Footer
Browse files Browse the repository at this point in the history
To Check all Footer Links display the correct Welsh Language Text

Updated some webElement names to pass SonarCloud checks
Updated some LOGGER lines to pass SonarCloud Checks
  • Loading branch information
ChrisBates1 committed Oct 4, 2024
1 parent e7476aa commit 8f4aa70
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public class DrivingLicencePageObject extends UniversalSteps {
@FindBy(
xpath =
"//*[@class='govuk-error-summary error-summary']//*[@class='govuk-error-summary__body']//*[@class='govuk-list govuk-error-summary__list']//*[contains(@href,'#consentCheckbox')]")
public WebElement DVLAConsentErrorInSummary;
public WebElement dvlaConsentErrorInSummary;

// -------------------------

Expand Down Expand Up @@ -331,10 +331,34 @@ public class DrivingLicencePageObject extends UniversalSteps {
public WebElement InvalidPostcodeFieldError;

@FindBy(id = "consentCheckbox-error")
public WebElement DVLAConsentCheckboxError;
public WebElement dvlaConsentCheckboxError;

@FindBy(xpath = "//*[@id=\"main-content\"]/div/div/form/h2")
public WebElement DVLAConsentSection;
public WebElement dvlaConsentSection;

@FindBy(xpath = "//a[contains(text(),\"Datganiad hygyrchedd\")]")
public WebElement dvlaAccessibilityStatement;

@FindBy(xpath = "//a[contains(text(),\"Cwcis\")]")
public WebElement dvlaCookie;

@FindBy(xpath = "//a[contains(text(),\"Telerau ac amodau\")]")
public WebElement dvlaTermsAndConditions;

@FindBy(xpath = "//a[contains(text(),\"Hysbysiad preifatrwydd\")]")
public WebElement dvlaPrivacyStatement;

@FindBy(xpath = "//a[contains(text(),\"Cymorth (agor mewn tab newydd)\")]")
public WebElement dvlaSupport;

@FindBy(xpath = "//a[contains(text(),\"Trwydded Llywodraeth Agored v3.0\")]")
public WebElement dvlaOpenGovernmentLicence;

@FindBy(xpath = "//*[contains(text(),\"Mae’r holl gynnwys ar gael o dan\")]")
public WebElement dvlaOpenGovernmentLicenceText;

@FindBy(xpath = "//*[contains(text(),\"© Hawlfraint y goron\")]")
public WebElement dvlaCrownCopyright;

@FindBy(xpath = "//*[@id=\"consentCheckbox-hint\"]/ul/li[1]/a")
public WebElement oneLoginLink;
Expand Down Expand Up @@ -427,7 +451,7 @@ public void navigateToDrivingLicenceCRIOnTestEnv() {
visitCredentialIssuers.click();
assertPageTitle(IPV_CORE_STUB, true);
String dlCRITestEnvironment = configurationService.getDlCRITestEnvironment();
LOGGER.info("dlCRITestEnvironment = " + dlCRITestEnvironment);
LOGGER.info("dlCRITestEnvironment = {}", dlCRITestEnvironment);
if (dlCRITestEnvironment.equalsIgnoreCase("dev")
|| dlCRITestEnvironment.equalsIgnoreCase("local")) {
drivingLicenceCRIDev.click();
Expand Down Expand Up @@ -476,7 +500,7 @@ public void betaBanner() {

public void betaBannerSentence(String expectedText) {
assertEquals(expectedText, betaBannerText.getText());
LOGGER.info("actualText = " + betaBannerText.getText());
LOGGER.info("actualText = {}", betaBannerText.getText());
}

public void rejectAnalysisCookie(String rejectAnalysis) {
Expand Down Expand Up @@ -586,28 +610,28 @@ public void assertUserRoutedToIpvCoreErrorPage() {
coreStubUrl
+ "callback?error=access_denied&error_description=Authorization+permission+denied";
String actUrl = Driver.get().getCurrentUrl();
LOGGER.info("expectedUrl = " + expUrl);
LOGGER.info("actualUrl = " + actUrl);
LOGGER.info("expectedUrl = {}", expUrl);
LOGGER.info("actualUrl = {}", actUrl);
assertEquals(actUrl, expUrl);
}

public void jsonErrorResponse(String expectedErrorDescription, String expectedErrorStatusCode)
throws JsonProcessingException {
String result = JSONPayload.getText();
LOGGER.info("result = " + result);
LOGGER.info("result = {}", result);

JsonNode insideError = getJsonNode(result, "errorObject");
LOGGER.info("insideError = " + insideError);
LOGGER.info("insideError = {}", insideError);

JsonNode errorDescription = insideError.get("description");
JsonNode statusCode = insideError.get("httpstatusCode");
String ActualErrorDescription = insideError.get("description").asText();
String ActualStatusCode = insideError.get("httpstatusCode").asText();

LOGGER.info("errorDescription = " + errorDescription);
LOGGER.info("statusCode = " + statusCode);
LOGGER.info("testErrorDescription = " + expectedErrorDescription);
LOGGER.info("testStatusCode = " + expectedErrorStatusCode);
LOGGER.info("errorDescription = {}", errorDescription);
LOGGER.info("statusCode = {}", statusCode);
LOGGER.info("testErrorDescription = {}", expectedErrorDescription);
LOGGER.info("testStatusCode = {}", expectedErrorStatusCode);

assertEquals(expectedErrorDescription, ActualErrorDescription);
assertEquals(expectedErrorStatusCode, ActualStatusCode);
Expand All @@ -622,7 +646,7 @@ public void scoreIs(
String expectedValidityScore, String expectedStrengthScore, String jsonPayloadText)
throws IOException {
String result = jsonPayloadText;
LOGGER.info("result = " + result);
LOGGER.info("result = {}", result);
JsonNode vcNode = getJsonNode(result, "vc");
List<JsonNode> evidence = getListOfNodes(vcNode, "evidence");

Expand All @@ -640,7 +664,7 @@ public void scoreAndTypeIs(
String jsonPayloadText)
throws IOException {
String result = jsonPayloadText;
LOGGER.info("result = " + result);
LOGGER.info("result = {}", result);
JsonNode vcNode = getJsonNode(result, "vc");
List<JsonNode> evidence = getListOfNodes(vcNode, "evidence");

Expand All @@ -663,18 +687,18 @@ public void assertCheckDetailsWithinVc(
JsonNode vcNode = getJsonNode(drivingLicenceCRIVC, "vc");
List<JsonNode> evidence = getListOfNodes(vcNode, "evidence");
JsonNode firstItemInEvidenceArray = evidence.get(0);
LOGGER.info("firstItemInEvidenceArray = " + firstItemInEvidenceArray);
LOGGER.info("firstItemInEvidenceArray = {}", firstItemInEvidenceArray);
if (checkDetailsType.equals("success")) {
JsonNode checkDetailsNode = firstItemInEvidenceArray.get("checkDetails");
JsonNode checkMethodNode = checkDetailsNode.get(0).get("checkMethod");
String actualCheckMethod = checkMethodNode.asText();
LOGGER.info("actualCheckMethod = " + actualCheckMethod);
LOGGER.info("actualCheckMethod = {}", actualCheckMethod);
JsonNode identityCheckPolicyNode = checkDetailsNode.get(0).get("identityCheckPolicy");
String actualidentityCheckPolicy = identityCheckPolicyNode.asText();
LOGGER.info("actualidentityCheckPolicy = " + actualidentityCheckPolicy);
LOGGER.info("actualidentityCheckPolicy = {}", actualidentityCheckPolicy);
JsonNode activityFromNode = checkDetailsNode.get(0).get("activityFrom");
String actualactivityFrom = activityFromNode.asText();
LOGGER.info("actualactivityFrom = " + actualactivityFrom);
LOGGER.info("actualactivityFrom = {}", actualactivityFrom);
Assert.assertEquals(checkMethod, actualCheckMethod);
Assert.assertEquals(identityCheckPolicy, actualidentityCheckPolicy);
if (!StringUtils.isEmpty(activityFromNode.toString())) {
Expand All @@ -694,11 +718,11 @@ public void assertCheckDetailsWithinVc(
JsonNode failedCheckDetailsNode = firstItemInEvidenceArray.get("failedCheckDetails");
JsonNode checkMethodNode = failedCheckDetailsNode.get(0).get("checkMethod");
String actualCheckMethod = checkMethodNode.asText();
LOGGER.info("actualCheckMethod = " + actualCheckMethod);
LOGGER.info("actualCheckMethod = {}", actualCheckMethod);
JsonNode identityCheckPolicyNode =
failedCheckDetailsNode.get(0).get("identityCheckPolicy");
String actualidentityCheckPolicy = identityCheckPolicyNode.asText();
LOGGER.info("actualidentityCheckPolicy = " + actualidentityCheckPolicy);
LOGGER.info("actualidentityCheckPolicy = {}", actualidentityCheckPolicy);
Assert.assertEquals(checkMethod, actualCheckMethod);
Assert.assertEquals(identityCheckPolicy, actualidentityCheckPolicy);
assertEquals(
Expand Down Expand Up @@ -1067,7 +1091,7 @@ public void assertInvalidMiddleNameOnField(String expectedText) {

public void ciInVC(String ci) throws IOException {
String result = JSONPayload.getText();
LOGGER.info("result = " + result);
LOGGER.info("result = {}", result);
JsonNode vcNode = getJsonNode(result, "vc");
JsonNode evidenceNode = vcNode.get("evidence");

Expand All @@ -1084,15 +1108,15 @@ public void ciInVC(String ci) throws IOException {

public void assertPersonalNumberInVc(String personalNumber) throws IOException {
String result = JSONPayload.getText();
LOGGER.info("result = " + result);
LOGGER.info("result = {}", result);
JsonNode vcNode = getJsonNode(result, "vc");
String licenceNumber = getPersonalNumberFromVc(vcNode);
assertEquals(personalNumber, licenceNumber);
}

public void assertJtiPresent() throws IOException {
String result = JSONPayload.getText();
LOGGER.info("result = " + result);
LOGGER.info("result = {}", result);
JsonNode jtiNode = getJsonNode(result, "jti");
String jti = jtiNode.asText();
assertNotNull(jti);
Expand Down Expand Up @@ -1280,19 +1304,59 @@ private WebElement getLabel(WebElement webElement) {
}

public void assertDVLAConsentErrorInErrorSummary(String expectedText) {
assertEquals(expectedText, DVLAConsentErrorInSummary.getText());
assertEquals(expectedText, dvlaConsentErrorInSummary.getText());
}

public void assertDVLAConsentErrorOnCheckbox(String expectedText) {
assertEquals(expectedText, DVLAConsentCheckboxError.getText().trim().replace("\n", ""));
assertEquals(expectedText, dvlaConsentCheckboxError.getText().trim().replace("\n", ""));
}

public void goToPage(String page) {
assertPageTitle(page, false);
}

public void assertConsentSection(String consentSection) {
assertEquals(consentSection, DVLAConsentSection.getText());
assertEquals(consentSection, dvlaConsentSection.getText());
}

public void assertAccessbilityStatementLink(String accessibilityStatement) {
assertEquals(accessibilityStatement, dvlaAccessibilityStatement.getText());
LOGGER.info("actualText = {}", dvlaAccessibilityStatement.getText());
}

public void assertCookiesLink(String cookiesLink) {
assertEquals(cookiesLink, dvlaCookie.getText());
LOGGER.info("actualText = {}", dvlaCookie.getText());
}

public void assertTermsAndConditions(String termsAndConditions) {
assertEquals(termsAndConditions, dvlaTermsAndConditions.getText());
LOGGER.info("actualText = {}", dvlaTermsAndConditions.getText());
}

public void assertPrivacyNotice(String privacyNotice) {
assertEquals(privacyNotice, dvlaPrivacyStatement.getText());
LOGGER.info("actualText = {}", dvlaPrivacyStatement.getText());
}

public void assertSupportLink(String supportLink) {
assertEquals(supportLink, dvlaSupport.getText());
LOGGER.info("actualText = {}", dvlaSupport.getText());
}

public void assertOLGLink(String olgLink) {
assertEquals(olgLink, dvlaOpenGovernmentLicence.getText());
LOGGER.info("actualText = {}", dvlaOpenGovernmentLicence.getText());
}

public void assertOLGTextFirst(String olgTextFirst) {
assertEquals(olgTextFirst, dvlaOpenGovernmentLicenceText.getText());
LOGGER.info("actualText = {}", dvlaOpenGovernmentLicenceText.getText());
}

public void assertCrownCopyright(String crownCopyright) {
assertEquals(crownCopyright, dvlaCrownCopyright.getText());
LOGGER.info("actualText = {}", dvlaCrownCopyright.getText());
}

public void assertOneLoginPrivacyLink(String oneLoginPrivacyLink) {
Expand Down Expand Up @@ -1320,7 +1384,7 @@ public void assertDVLAContentLineTwo(String contentDVLALine2) {

private JsonNode getVCFromJson(String vc) throws JsonProcessingException {
String result = JSONPayload.getText();
LOGGER.info("result = " + result);
LOGGER.info("result = {}", result);
ObjectMapper objectMapper = new ObjectMapper();
JsonNode jsonNode = objectMapper.readTree(result);
return jsonNode.get(vc);
Expand All @@ -1332,14 +1396,14 @@ public void expiryAbsentFromVC(String exp) throws JsonProcessingException {

private void assertNbfIsRecentAndExpiryIsNull() throws JsonProcessingException {
String result = JSONPayload.getText();
LOGGER.info("result = " + result);
LOGGER.info("result = {}", result);
ObjectMapper objectMapper = new ObjectMapper();
JsonNode jsonNode = objectMapper.readTree(result);
JsonNode nbfNode = jsonNode.get("nbf");
JsonNode expNode = jsonNode.get("exp");
String nbf = jsonNode.get("nbf").asText();
LOGGER.info("nbf = " + nbfNode);
LOGGER.info("exp = " + expNode);
LOGGER.info("nbf = {}", nbfNode);
LOGGER.info("exp = {}", expNode);
LocalDateTime nbfDateTime =
LocalDateTime.ofEpochSecond(Long.parseLong(nbf), 0, ZoneOffset.UTC);

Expand All @@ -1350,9 +1414,9 @@ private void assertNbfIsRecentAndExpiryIsNull() throws JsonProcessingException {
boolean isWithinRange(LocalDateTime testDate) {
LocalDateTime nbfMin = LocalDateTime.now(ZoneOffset.UTC).minusSeconds(30);
LocalDateTime nbfMax = LocalDateTime.now(ZoneOffset.UTC).plusSeconds(30);
LOGGER.info("nbfMin " + nbfMin);
LOGGER.info("nbfMax " + nbfMax);
LOGGER.info("nbf " + testDate);
LOGGER.info("nbfMin {}", nbfMin);
LOGGER.info("nbfMax {}", nbfMax);
LOGGER.info("nbf {}", testDate);

return testDate.isBefore(nbfMax) && testDate.isAfter(nbfMin);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,46 @@ public void iSeeTheConsentSectionAllowDVLAToCheckYourDrivingLicenceDetails(
assertConsentSection(consentSection);
}

@Given("^I see the accessibility statement link (.*)$")
public void iSeeTheAccessibilityStatementLink(String accessibilityStatement) {
assertAccessbilityStatementLink(accessibilityStatement);
}

@And("^I see the cookies link (.*)$")
public void iSeeTheCookiesLink(String cookiesLink) {
assertCookiesLink(cookiesLink);
}

@And("^I see the terms and conditions link (.*)$")
public void iSeeTheTermsAndConditionsLink(String termsAndConditions) {
assertTermsAndConditions(termsAndConditions);
}

@And("^I see the privacy notice link (.*)$")
public void iSeeThePrivacyNoticeLink(String privacyNotice) {
assertPrivacyNotice(privacyNotice);
}

@And("^I see the support link (.*)$")
public void iSeeTheSupportLink(String supportLink) {
assertSupportLink(supportLink);
}

@And("^I see the OLG link (.*)$")
public void iSeeTheOLGLink(String olgLink) {
assertOLGLink(olgLink);
}

@And("^I see the OLG text first half (.*)$")
public void iSeeTheOLGTextFirst(String olgTextFirst) {
assertOLGTextFirst(olgTextFirst);
}

@And("^I see the crown copyright link (.*)$")
public void iSeeTheCrownCropyright(String crownCopyright) {
assertCrownCopyright(crownCopyright);
}

@Then("^I see privacy notice link (.*)$")
public void iSeePrivacyNoticeLinkTheGOVUKOneLoginPrivacyNotice(String oneLoginPrivacyLink) {
assertOneLoginPrivacyLink(oneLoginPrivacyLink);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ Feature: Driving License Language Test
When the beta banner reads Mae hwn yn wasanaeth newydd – bydd eich adborth (agor mewn tab newydd) yn ein helpu i'w wella.
Then The test is complete and I close the driver

@Language-regression
Scenario: Footer - Link Text Validation
Given I see the accessibility statement link Datganiad hygyrchedd
And I see the cookies link Cwcis
And I see the terms and conditions link Telerau ac amodau
And I see the privacy notice link Hysbysiad preifatrwydd
And I see the support link Cymorth (agor mewn tab newydd)
And I see the OLG link Trwydded Llywodraeth Agored v3.0
And I see the OLG text first half Mae’r holl gynnwys ar gael o dan Trwydded Llywodraeth Agored v3.0, oni nodir yn wahanol
And I see the crown copyright link © Hawlfraint y goron
And The test is complete and I close the driver

@Language-regression
Scenario Outline: DVLA Error tab title validation
Given I click on DVLA radio button and Parhau
Expand Down

0 comments on commit 8f4aa70

Please sign in to comment.