<commit_before>package browserview;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

import java.util.NoSuchElementException;

// acts as a middleman for ChromeDriver when not in testing mode,
// and as a stub when testing

public class ChromeDriverEx {

    private boolean isTestChromeDriver;
    private ChromeDriver driver;

    ChromeDriverEx(ChromeOptions options, boolean isTestChromeDriver) {
        this.isTestChromeDriver = isTestChromeDriver;
        initialise(options);
    }

    private void initialise(ChromeOptions options) {
        if (!isTestChromeDriver) driver = new ChromeDriver(options);
    }

    public WebDriver.Options manage() {
        return !isTestChromeDriver ? driver.manage() : null;
    }

    public void quit() {
        if (!isTestChromeDriver) driver.quit();
    }

    public void get(String url) {
        if (!isTestChromeDriver) driver.get(url);
    }

    public String getCurrentUrl() {
        return !isTestChromeDriver ? driver.getCurrentUrl() :
                "https://github.com/HubTurbo/HubTurbo/issues/1";
    }

    public WebElement findElementById(String id) throws NoSuchElementException {
        if (!isTestChromeDriver) return driver.findElementById(id);
        throw new NoSuchElementException();
    }

    public WebElement findElementByTagName(String tag) throws NoSuchElementException {
        if (!isTestChromeDriver) return driver.findElementByTagName(tag);
        throw new NoSuchElementException();
    }

    public WebDriver.TargetLocator switchTo() throws WebDriverException {
        if (!isTestChromeDriver) {
            return driver.switchTo();
        } else {
            if (Math.random() < 0.1) {
                throw new WebDriverException();
            }
        }
        return null;
    }

    public String getWindowHandle() {<commit_msg>increased random chance to throw exception for ChromeDriverEx.switchTo()<commit_after>package browserview;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

import java.util.NoSuchElementException;

// acts as a middleman for ChromeDriver when not in testing mode,
// and as a stub when testing

public class ChromeDriverEx {

    private boolean isTestChromeDriver;
    private ChromeDriver driver;

    ChromeDriverEx(ChromeOptions options, boolean isTestChromeDriver) {
        this.isTestChromeDriver = isTestChromeDriver;
        initialise(options);
    }

    private void initialise(ChromeOptions options) {
        if (!isTestChromeDriver) driver = new ChromeDriver(options);
    }

    public WebDriver.Options manage() {
        return !isTestChromeDriver ? driver.manage() : null;
    }

    public void quit() {
        if (!isTestChromeDriver) driver.quit();
    }

    public void get(String url) {
        if (!isTestChromeDriver) driver.get(url);
    }

    public String getCurrentUrl() {
        return !isTestChromeDriver ? driver.getCurrentUrl() :
                "https://github.com/HubTurbo/HubTurbo/issues/1";
    }

    public WebElement findElementById(String id) throws NoSuchElementException {
        if (!isTestChromeDriver) return driver.findElementById(id);
        throw new NoSuchElementException();
    }

    public WebElement findElementByTagName(String tag) throws NoSuchElementException {
        if (!isTestChromeDriver) return driver.findElementByTagName(tag);
        throw new NoSuchElementException();
    }

    public WebDriver.TargetLocator switchTo() throws WebDriverException {
        if (!isTestChromeDriver) {
            return driver.switchTo();
        } else {
            // ~50% chance to throw an exception which is used to test resetBrowser
            if (Math.random() < 0.5) {
                throw new WebDriverException();
            }
        }
        return null;
    }

    public String getWindowHandle() {
{'fraction_non_alphanumeric': 0.08603934581654421, 'fraction_numerical': 0.0018961839298411946, 'mean_word_length': 3.0891472868217056, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '2485425', 'n_tokens_mistral': 1197, 'n_tokens_neox': 1154, 'n_words': 283}