<commit_before>package integration;

import com.codeborne.selenide.Configuration;
import com.codeborne.selenide.SelenideElement;
import com.codeborne.selenide.impl.ScreenShotLaboratory;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;

import static com.codeborne.selenide.Selenide.$;
import static com.codeborne.selenide.WebDriverRunner.getWebDriver;
import static com.codeborne.selenide.WebDriverRunner.isHtmlUnit;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.lessThan;
import static org.junit.Assert.*;
import static org.junit.Assume.assumeFalse;

public class ScreenshotTest extends IntegrationTest {

  @Before
  public void openTestPage() {
    assumeFalse(isHtmlUnit());
    openFile("page_with_big_divs.html");
  }

  @Test
  public void canTakeScreenshotOfElement() throws IOException {
    SelenideElement element = $("#small_div");
    File screenshot = element.screenshot();
    String info = "(Screenshot of element: " + screenshot.getAbsolutePath() + ") ";

    BufferedImage img = ImageIO.read(screenshot);
    assertEquals("Screenshot doesn't fit width " + info, img.getWidth(), element.getSize().getWidth());
    assertEquals("Screenshot doesn't fit height " + info, img.getHeight(), element.getSize().getHeight());
    assertTrue("Screenshot file should be located in " + Configuration.reportsFolder +
            ", but was: " + screenshot.getPath(),
        screenshot.getPath().startsWith(Configuration.reportsFolder));
  }

  @Test
  @Ignore
  public void resizeBigImageWidth() {
    SelenideElement element = $("#wide_div");
    BufferedImage img = element.screenshotAsImage();
    assertThat("Screenshot doesn't fit width", img.getWidth(), is(lessThan(element.getSize().getWidth())));
  }

  @Test
  @Ignore<commit_msg>fixed screenshot test for windows<commit_after>package integration;

import com.codeborne.selenide.Configuration;
import com.codeborne.selenide.SelenideElement;
import com.codeborne.selenide.impl.ScreenShotLaboratory;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;

import static com.codeborne.selenide.Selenide.$;
import static com.codeborne.selenide.WebDriverRunner.getWebDriver;
import static com.codeborne.selenide.WebDriverRunner.isHtmlUnit;
import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.lessThan;
import static org.junit.Assert.*;
import static org.junit.Assume.assumeFalse;

public class ScreenshotTest extends IntegrationTest {

  @Before
  public void openTestPage() {
    assumeFalse(isHtmlUnit());
    openFile("page_with_big_divs.html");
  }

  @Test
  public void canTakeScreenshotOfElement() throws IOException {
    SelenideElement element = $("#small_div");
    File screenshot = element.screenshot();
    String info = "(Screenshot of element: " + screenshot.getAbsolutePath() + ") ";
    String screenshotPath = IS_OS_WINDOWS ? Configuration.reportsFolder.replace("/", "\\") : Configuration.reportsFolder;

    BufferedImage img = ImageIO.read(screenshot);
    assertEquals("Screenshot doesn't fit width " + info, img.getWidth(), element.getSize().getWidth());
    assertEquals("Screenshot doesn't fit height " + info, img.getHeight(), element.getSize().getHeight());
    assertTrue("Screenshot file should be located in " + screenshotPath + ", but was: " +
            screenshot.getPath(), screenshot.getPath().startsWith(screenshotPath));
  }

  @Test
  @Ignore
  public void resizeBigImageWidth() {
    SelenideElement element = $("#wide_div");
    BufferedImage img = element.screenshotAsImage();
    assertThat("Screenshot doesn't fit width", img.getWidth(), is(lessThan(element.getSize().getWidth())));
  }

  @Test
  @Ignore
{'fraction_non_alphanumeric': 0.11757775683317626, 'fraction_numerical': 0.000235626767200754, 'mean_word_length': 5.242647058823529, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7382756', 'n_tokens_mistral': 1310, 'n_tokens_neox': 1263, 'n_words': 261}