public static void createAnAccount(String AccountName) throws InterruptedException {

    if (!WebNavPage.elementWithXPathExists("//div[@id = 'createNewButton']")) {
      WebNavPage.clickALink(HomePage.activateSideMenu);
    }
    WebNavPage.clickALinkWithCssLocator(HomePage.createNewDropdown);
    WebNavPage.clickALinkWithCssLocator(HomePage.accountOptionFromDropdown);
    WebNavPage.enterAnyTextInAFieldWithCssLocator(AccountsPage.accountName, AccountName);
    WebNavPage.enterAnyTextInAFieldWithCssLocator(AccountsPage.phone, "0208456789");
    WebNavPage.enterAnyTextInAField(AccountsPage.email, "*****@*****.**");
    WebNavPage.checkACheckBox(AccountsPage.dynamicTeleTracking);
    WebNavPage.enterAnyTextInAField(AccountsPage.telephoneTrackingNum, "25823");
    WebNavPage.enterAnyTextInAFieldWithCssLocator(AccountsPage.website, "http://www.test.com");
    WebNavPage.enterAnyTextInAFieldWithCssLocator(AccountsPage.billingStreet, "1, Some Street");
    WebNavPage.enterAnyTextInAFieldWithCssLocator(AccountsPage.billingCity, "Some City");
    WebNavPage.enterAnyTextInAFieldWithCssLocator(AccountsPage.billingPostcode, "E98 1XY");
    WebNavPage.enterAnyTextInAField(AccountsPage.SAPId, "9777777");
    WebNavPage.selectingAnOptionFromList("Car Dealer", AccountsPage.accType);
    WebNavPage.selectAnOptionFromAList("Key Account", AccountsPage.accSubType);
    WebNavPage.enterAnyTextInAField(AccountsPage.billCountry, "UK");
    WebNavPage.selectingAnOptionFromList("South-East", AccountsPage.region);
    WebNavPage.clickALink(AccountsPage.copyBillingAddress);
    WebNavPage.clickALink(HomePage.saveBTN);

    if (WebNavPage.getText("//div[@id='00N3000000AeABd_ileinner']").contains("SF") != false) {
      WebNavPage.waitForElementToLoad();
    } else {
      System.out.println(
          "The Dealer ID for the Account is :"
              + WebNavPage.getText("//div[@id='00N3000000AeABd_ileinner']"));
    }
  }
  @And("^I do a credit check pass the (.*) Account$")
  public static void doCreditCheckOnAccount(String AccName) {

    if (AccName.equalsIgnoreCase("Parent")) {
      accToBeChecked = parent_Account;
    } else {
      accToBeChecked = child_Account;
    }
    WebNavPage.enterAnyTextInAField(HomePage.search, accToBeChecked);
    WebNavPage.clickALink(HomePage.searchBTN);
    WebNavPage.waitForElementToLoad();
    String accLocator = "//a[contains(text(),'" + accToBeChecked + "')]";
    try {
      WebNavPage.elementWithXPathExists(accLocator);
    } catch (Exception e) {
      e.printStackTrace();
      System.out.println("The Account" + accToBeChecked + "is not displayed in the search results");
    } finally {
      WebNavPage.clickALink(accLocator);
      WebNavPage.waitForElementToLoad();
      WebNavPage.clickALink(AccountsPage.edit);
      WebNavPage.waitForElementToLoad();
      WebNavPage.checkACheckBox(AccountsPage.CreCheck);
      WebNavPage.enterAnyNumberInAField(AccountsPage.CreRefNum, 1111);
      WebNavPage.clickALink(HomePage.saveBTN);
      WebNavPage.waitForElementToLoad();
    }
  }
  @Given("^I am logged in as (.*) in Salesforce$")
  public static void logMeAs(String UserType) throws Exception {

    String UserName = "";

    if (UserType.equalsIgnoreCase("SalesUser")) {
      UserName = EnvironmentURLs.SalesUser;
    } else if (UserType.equalsIgnoreCase("SalesSupportUser")) {
      UserName = EnvironmentURLs.SalesSupportUser;
    } else if (UserType.equalsIgnoreCase("AdminUser")) {
      UserName = EnvironmentURLs.AdminUser;
    } else {
      System.out.println("User Type Unknown");
    }

    WebNavPage.openWebPage(EnvironmentURLs.SalesforceLoginPage);
    WebNavPage.enterAnyTextInAFieldWithCssLocator(LoginPage.username, UserName);
    WebNavPage.enterAnyTextInAFieldWithCssLocator(LoginPage.password, EnvironmentURLs.Password);
    WebNavPage.clickALinkWithCssLocator(LoginPage.loginBTN);

    // Selecting NewsInternational if its not selected

    if (WebNavPage.getText(HomePage.orgLabel).equalsIgnoreCase("News International") != true) {
      WebNavPage.clickALink(HomePage.groupMenu);
      // WebNavPage.waitForElementToBeVisible(HomePage.orgMenu);
      WebNavPage.clickALink(HomePage.newIntLNK);
    }
  }
  @When("^I link the Parent Account to the Child Account$")
  public void linkChildToParent() {

    WebNavPage.clickALink(AccountsPage.edit);
    WebNavPage.waitForElementToLoad();
    WebNavPage.enterAnyTextInAFieldWithCssLocator(AccountsPage.parentAccount, parent_Account);
    WebNavPage.clickALink(HomePage.saveBTN);
    WebNavPage.waitForElementToLoad();
  }
  public static void clickOnFooterLink(String linkName) {

    String footerLink = "//ul/li/a/span[contains(text(),'" + linkName + "')]";
    WebNavPage.clickALink(footerLink);
    WebNavPage.waitForShortSpan();
  }
  public static void clickOnATab(String TabName) {

    String tabToClick = "//span[contains(text(), '" + TabName + "')]";
    WebNavPage.clickALink(tabToClick);
    WebNavPage.waitForElementToLoad();
  }
  @When("^I click Orders link$")
  public void clickOnOrderLink() {

    WebNavPage.clickALink(HomePage.Orders_FooterLink);
  }
 @When("^I click Orders tab$")
 public void clickOnOrderstab() {
   WebNavPage.clickALink(HomePage.Orders);
 }