<commit_before><commit_msg>Algunas pruebas con selenium<commit_after>package Selenium;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

import java.util.NoSuchElementException;
import java.util.concurrent.TimeUnit;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.*;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;

import scala.util.control.Exception.By;

public class Prueba {
	private WebDriver driver;
	private String baseUrl;
	private boolean acceptNextAlert = true;
	private StringBuffer verificationErrors = new StringBuffer();

	@Before
	public void setUp() throws Exception {
		driver = new HtmlUnitDriver();
		baseUrl = "http://localhost:8080/";
		driver.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS);
	}

	@Test
	public void testVerPropuestas() throws Exception {
		loginUser();
		assertEquals("Propuestas activas", driver.findElement(By.cssSelector("h1")).getText());
		assertEquals("Crear una propuesta", driver.findElement(By.linkText("Crear una propuesta")).getText());
	}

	@Test
	public void testVoidVerComentarios() throws Exception {
		loginUser();
		driver.findElement(By.id("apoyar${iter.id}")).click();
		driver.findElement(By.id("comentarios${iter.id}")).click();
		assertEquals("Comentarios de la propuesta", driver.findElement(By.cssSelector("h1")).getText());
		assertEquals("Comentar", driver.findElement(By.id("login")).getText());
		assertEquals("Comente aquí", driver.findElement(By.cssSelector("form > p")).getText());
		driver.findElement(By.id("positivo${iter.id}")).click();
	}

	private void loginUser() {
		driver.get(baseUrl);
		driver.findElement(By.id("email")).clear();
		driver.findElement(By.id("email")).sendKeys("<EMAIL>");
		driver.findElement(By.id("password")).clear();
		driver.findElement(By.id("password")).sendKeys("<PASSWORD>");
		driver.findElement(By.id("login")).click();
	}

	@After
	public void tearDown() throws Exception {
		driver.quit();
		String verificationErrorString = verificationErrors.toString();
		if (!"".equals(verificationErrorString)) {
			fail(verificationErrorString);
		}
	}

	private boolean isElementPresent(By by) {
		try {
			driver.findElement(by);
			return true;
		} catch (NoSuchElementException e) {
			return false;
		}
	}

	private boolean isAlertPresent() {
		try {
			driver.switchTo().alert();
			return true;
		} catch (NoAlertPresentException e) {
			return false;
		}
	}

	private String closeAlertAndGetItsText() {
		try {
			Alert alert = driver.switchTo().alert();
			String alertText = alert.getText();
			if (acceptNextAlert) {
				alert.accept();
			} else {
				alert.dismiss();
			}
			return alertText;
		} finally {
			acceptNextAlert = true;
		}
	}
}
{'fraction_non_alphanumeric': 0.14960058097313, 'fraction_numerical': 0.002541757443718228, 'mean_word_length': 5.16331096196868, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, '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': '2118390', 'n_tokens_mistral': 955, 'n_tokens_neox': 864, 'n_words': 162}