public static void assertJavaScriptErrors(WebDriver webDriver, String ignoreJavaScriptError)
      throws Exception {

    if (!PropsValues.TEST_ASSERT_JAVASCRIPT_ERRORS) {
      return;
    }

    String location = getLocation(webDriver);

    if (!location.contains("localhost")) {
      return;
    }

    String pageSource = null;

    try {
      pageSource = webDriver.getPageSource();
    } catch (Exception e) {
      WebDriver.TargetLocator targetLocator = webDriver.switchTo();

      targetLocator.window(_defaultWindowHandle);

      pageSource = webDriver.getPageSource();
    }

    if (pageSource.contains(
        "html id=\"feedHandler\" xmlns=" + "\"http://www.w3.org/1999/xhtml\"")) {

      return;
    }

    List<JavaScriptError> javaScriptErrors = new ArrayList<>();

    try {
      WebElement webElement = getWebElement(webDriver, "//body");

      WrapsDriver wrapsDriver = (WrapsDriver) webElement;

      WebDriver wrappedWebDriver = wrapsDriver.getWrappedDriver();

      javaScriptErrors.addAll(JavaScriptError.readErrors(wrappedWebDriver));
    } catch (Exception e) {
    }

    List<Exception> exceptions = new ArrayList<>();

    if (!javaScriptErrors.isEmpty()) {
      for (JavaScriptError javaScriptError : javaScriptErrors) {
        String javaScriptErrorValue = javaScriptError.toString();

        if (Validator.isNotNull(ignoreJavaScriptError)
            && javaScriptErrorValue.contains(ignoreJavaScriptError)) {

          continue;
        }

        if (LiferaySeleniumHelper.isInIgnoreErrorsFile(javaScriptErrorValue, "javascript")) {

          continue;
        }

        String message = "JAVA_SCRIPT_ERROR: " + javaScriptErrorValue;

        System.out.println(message);

        exceptions.add(new PoshiRunnerWarningException(message));
      }
    }

    if (!exceptions.isEmpty()) {
      LiferaySeleniumHelper.addToJavaScriptExceptions(exceptions);

      throw exceptions.get(0);
    }
  }
  @Override
  public void assertJavaScriptErrors(String ignoreJavaScriptError) throws Exception {

    if (!TestPropsValues.TEST_ASSSERT_JAVASCRIPT_ERRORS) {
      return;
    }

    String location = getLocation();

    if (!location.contains("localhost")) {
      return;
    }

    String pageSource = null;

    try {
      pageSource = getPageSource();
    } catch (Exception e) {
      WebDriver.TargetLocator targetLocator = switchTo();

      targetLocator.window(defaultWindowHandle);

      pageSource = getPageSource();
    }

    if (pageSource.contains(
        "html id=\"feedHandler\" xmlns=" + "\"http://www.w3.org/1999/xhtml\"")) {

      return;
    }

    WebElement webElement = getWebElement("//body");

    WrapsDriver wrapsDriver = (WrapsDriver) webElement;

    WebDriver webDriver = wrapsDriver.getWrappedDriver();

    List<JavaScriptError> javaScriptErrors = JavaScriptError.readErrors(webDriver);

    if (!javaScriptErrors.isEmpty()) {
      for (JavaScriptError javaScriptError : javaScriptErrors) {
        String javaScriptErrorValue = javaScriptError.toString();

        System.out.println("JS_ERROR: " + javaScriptErrorValue);

        if (Validator.isNotNull(ignoreJavaScriptError)
            && javaScriptErrorValue.contains(ignoreJavaScriptError)) {

          continue;
        }

        // LPS-41634

        if (javaScriptErrorValue.contains("TypeError: d.config.doc.defaultView is null")) {

          continue;
        }

        // LPS-41634

        if (javaScriptErrorValue.contains("NS_ERROR_NOT_INITIALIZED:")) {

          continue;
        }

        // LPS-42469

        if (javaScriptErrorValue.contains("https://apis.google.com/_/+1/fastbutton")) {

          continue;
        }

        throw new Exception(javaScriptErrorValue);
      }
    }
  }