<commit_before>package org.twinstone.tdi;

import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;

import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.WebDriverWait;

import com.google.common.base.Function;

import static org.junit.Assert.*;

public class BrowserPages {

	protected WebDriver driver;
	
	protected static final File base = new File("tests").getAbsoluteFile();
	
	@BeforeClass
	public static void assertBase() {
		assertNotNull(base);
	}
	
	protected URI makeUri(String name) throws URISyntaxException {
		return new File(base,name).toURI();
	}
	
	protected void testPage(String name) throws URISyntaxException {
		String url = makeUri(name).toString();
		driver.get(url);
		WebDriverWait waitForResult = new WebDriverWait(driver, 60);
        WebElement resultElm = waitForResult.until(new Function<WebDriver, WebElement>() {
            @Override
            public WebElement apply(WebDriver driver) {
                WebElement elm = driver.findElement(By.id("qunit-testresult"));
                if (elm != null && !elm.getText().contains("Running")) {
                    return elm;
                }
                return null;
            }
        });
        assertTrue("There are failed qunit tests", resultElm.getText().contains("0 failed"));
	}
	
	@Test
	public void ajax() throws URISyntaxException {
		testPage("tdi-ajax.html");
	}<commit_msg>Automatic accept of alert() windows.<commit_after>package org.twinstone.tdi;

import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;

import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.WebDriverWait;

import com.google.common.base.Function;

import static org.junit.Assert.*;

public class BrowserPages {

	protected WebDriver driver;
	
	protected static final File base = new File("tests").getAbsoluteFile();
	
	@BeforeClass
	public static void assertBase() {
		assertNotNull(base);
	}
	
	protected URI makeUri(String name) throws URISyntaxException {
		return new File(base,name).toURI();
	}
	
	protected void testPage(String name) throws URISyntaxException {
		String url = makeUri(name).toString();
		driver.get(url);
		WebDriverWait waitForResult = new WebDriverWait(driver, 60);
        WebElement resultElm = waitForResult.until(new Function<WebDriver, WebElement>() {
            @Override
            public WebElement apply(WebDriver driver) {
                WebElement elm = driver.findElement(By.id("qunit-testresult"));
                if (elm != null && !elm.getText().contains("Running")) {
                    return elm;
                }
                
				try {
					Alert alert = driver.switchTo().alert();
					alert.accept();
				}
				catch (final WebDriverException e) {}
				
				return null;
            }
        });
        assertTrue("There are failed qunit tests", resultElm.getText().contains("0 failed"));
	}
	
	@Test
	public void ajax() throws URISyntaxException {
		testPage("tdi-ajax.html");
	}
{'fraction_non_alphanumeric': 0.11222978975421972, 'fraction_numerical': 0.0017767249037607344, 'mean_word_length': 3.319693094629156, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '119212', 'n_tokens_mistral': 1067, 'n_tokens_neox': 976, 'n_words': 227}