<commit_before>package com.codeborne.selenide.ex;

import com.codeborne.selenide.Condition;
import com.codeborne.selenide.Configuration;
import org.openqa.selenium.WebElement;

import java.io.File;
import java.net.MalformedURLException;
import java.util.logging.Logger;

import static com.codeborne.selenide.Screenshots.takeScreenShot;

public class ErrorMessages {
  private static final Logger LOG = Logger.getLogger(ErrorMessages.class.getName());

  protected static String timeout(long timeoutMs) {
    if (timeoutMs < 1000) {
      return "\nTimeout: " + timeoutMs + " ms.";
    }
    if (timeoutMs % 1000 == 0) {
      return "\nTimeout: " + timeoutMs / 1000 + " s.";
    }

    return "\nTimeout: " + String.format("%.3f", timeoutMs/1000.0) + " s.";
  }

  public static String actualValue(Condition condition, WebElement element) {
    if (element != null) {
      String actualValue = condition.actualValue(element);
      if (actualValue != null) {
        return "\nActual value: " + actualValue;
      }
    }
    return "";
  }

  public static String screenshot() {
    if (!Configuration.screenshots) {
      LOG.fine("Automatic screenshots are disabled.");
      return "";
    }

    return formatScreenShotPath(takeScreenShot());
  }

  private static String formatScreenShotPath(String screenshot) {
    if (Configuration.reportsUrl != null) {
      String screenshotRelativePath = screenshot.substring(System.getProperty("user.dir").length() + 1);
      String screenshotUrl = Configuration.reportsUrl + screenshotRelativePath;
      LOG.info("Replaced screenshot file path '" + screenshot + "' by public CI URL '" + screenshotUrl + "'");
      return "\nScreenshot: " + screenshotUrl;
    }

    LOG.info("reportsUrl is not configured. Returning screenshot file name '" + screenshot + "'");
    try {
      return "\nScreenshot: " + new File(screenshot).toURI().toURL().toExternalForm();
    } catch (MalformedURLException e) {
      return "\nScreenshot: file://" + screenshot;
    }
  }
}
<commit_msg>Fixes #76 - fixed unit-test failing on Windows<commit_after>package com.codeborne.selenide.ex;

import com.codeborne.selenide.Condition;
import com.codeborne.selenide.Configuration;
import org.openqa.selenium.WebElement;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Logger;

import static com.codeborne.selenide.Screenshots.takeScreenShot;

public class ErrorMessages {
  private static final Logger LOG = Logger.getLogger(ErrorMessages.class.getName());

  protected static String timeout(long timeoutMs) {
    if (timeoutMs < 1000) {
      return "\nTimeout: " + timeoutMs + " ms.";
    }
    if (timeoutMs % 1000 == 0) {
      return "\nTimeout: " + timeoutMs / 1000 + " s.";
    }

    return "\nTimeout: " + String.format("%.3f", timeoutMs/1000.0) + " s.";
  }

  public static String actualValue(Condition condition, WebElement element) {
    if (element != null) {
      String actualValue = condition.actualValue(element);
      if (actualValue != null) {
        return "\nActual value: " + actualValue;
      }
    }
    return "";
  }

  public static String screenshot() {
    if (!Configuration.screenshots) {
      LOG.fine("Automatic screenshots are disabled.");
      return "";
    }

    return formatScreenShotPath(takeScreenShot());
  }

  private static String formatScreenShotPath(String screenshot) {
    if (Configuration.reportsUrl != null) {
      String screenshotRelativePath = screenshot.substring(System.getProperty("user.dir").length() + 1);
      String screenshotUrl = Configuration.reportsUrl + screenshotRelativePath.replace('\\', '/');
      try {
        screenshotUrl = new URL(screenshotUrl).toExternalForm();
      }
      catch (MalformedURLException e) {}
      LOG.info("Replaced screenshot file path '" + screenshot + "' by public CI URL '" + screenshotUrl + "'");
      return "\nScreenshot: " + screenshotUrl;
    }

    LOG.info("reportsUrl is not configured. Returning screenshot file name '" + screenshot + "'");
    try {
      return "\nScreenshot: " + new File(screenshot).toURI().toURL().toExternalForm();
    } catch (MalformedURLException e) {
      return "\nScreenshot: file://" + screenshot;
    }
  }
}

{'fraction_non_alphanumeric': 0.12803012473523182, 'fraction_numerical': 0.009884678747940691, 'mean_word_length': 3.4409613375130617, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5710102', 'n_tokens_mistral': 1313, 'n_tokens_neox': 1212, 'n_words': 287}