<commit_before>package nl.hsac.fitnesse.fixture.util;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * Helper to work with Selenium.
 */
public class SeleniumHelper {

    private static WebDriver WEB_DRIVER = null;
    private static boolean SHUTDOWN_HOOK_ENABLED = false;
    /** Timeout in milliseconds to wait for element to appear */
    public static int IMPLICIT_WAIT = 15000;

    public static WebDriver getWebDriver() {
        if(WEB_DRIVER == null) {
            if(!SHUTDOWN_HOOK_ENABLED) {
                Runtime.getRuntime().addShutdownHook(new Thread() {
                    public void run() {
                        close();
                    }
                });
                SHUTDOWN_HOOK_ENABLED = true;
            }
			/*
			 * Vervang dit eventueel door een browser naar keuze.
			 */
            WEB_DRIVER = new FirefoxDriver();
        }

        setImplicitWait(IMPLICIT_WAIT);
        return WEB_DRIVER;
    }

    private static void setImplicitWait(int implicitWait) {
//        WEB_DRIVER.manage().timeouts().implicitlyWait(implicitWait, TimeUnit.MILLISECONDS);
    }

    public static void close() {
        if(WEB_DRIVER != null) {
            WEB_DRIVER.quit();
            WEB_DRIVER = null;
        }
    }

    public WebElement getElement(String place) {
        WebElement element = null;
        setImplicitlyWait(5);
        String xpathPlace = place.replace("\"", "&quot;")
                                 .replace("'", "&apos;").trim();
        if (element == null) {
            WebElement label = findElement(By.xpath("//label[text()='" + xpathPlace + "']"));
            if (label != null) {
                String forAttr = label.getAttribute("for");
                element = findElement(By.id(forAttr));
            }
        }
        if (element == null) {
            element = findElement(By.xpath("//*[@aria-label='" + xpathPlace + "']"));
        }
        if (element == null) {
            element = findElement(By.name(place));
        }
        if (element == null) {
            element = findElement(By.id(place));<commit_msg>Don't set the default on each get<commit_after>package nl.hsac.fitnesse.fixture.util;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * Helper to work with Selenium.
 */
public class SeleniumHelper {

    private static WebDriver WEB_DRIVER = null;
    private static boolean SHUTDOWN_HOOK_ENABLED = false;
    /** Timeout in milliseconds to wait for element to appear */
    public static int IMPLICIT_WAIT = 15000;

    public static WebDriver getWebDriver() {
        if(WEB_DRIVER == null) {
            if(!SHUTDOWN_HOOK_ENABLED) {
                Runtime.getRuntime().addShutdownHook(new Thread() {
                    public void run() {
                        close();
                    }
                });
                SHUTDOWN_HOOK_ENABLED = true;
            }
			/*
			 * Vervang dit eventueel door een browser naar keuze.
			 */
            WEB_DRIVER = new FirefoxDriver();
            setImplicitWait(IMPLICIT_WAIT);
        }

        return WEB_DRIVER;
    }

    private static void setImplicitWait(int implicitWait) {
        WEB_DRIVER.manage().timeouts().implicitlyWait(implicitWait, TimeUnit.MILLISECONDS);
    }

    public static void close() {
        if(WEB_DRIVER != null) {
            WEB_DRIVER.quit();
            WEB_DRIVER = null;
        }
    }

    public WebElement getElement(String place) {
        WebElement element = null;
        setImplicitlyWait(100);
        String xpathPlace = place.replace("\"", "&quot;")
                                 .replace("'", "&apos;").trim();
        if (element == null) {
            WebElement label = findElement(By.xpath("//label[text()='" + xpathPlace + "']"));
            if (label != null) {
                String forAttr = label.getAttribute("for");
                element = findElement(By.id(forAttr));
            }
        }
        if (element == null) {
            element = findElement(By.xpath("//*[@aria-label='" + xpathPlace + "']"));
        }
        if (element == null) {
            element = findElement(By.name(place));
        }
        if (element == null) {
            element = findElement(By.id(place));
{'fraction_non_alphanumeric': 0.11834192439862543, 'fraction_numerical': 0.003006872852233677, 'mean_word_length': 2.0161917098445596, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3314903', 'n_tokens_mistral': 1411, 'n_tokens_neox': 1359, 'n_words': 283}