<commit_before>package pl.softwaremill.common.test.web.selenium;

import org.testng.Assert;

import static pl.softwaremill.common.test.web.selenium.AbstractSeleniumTest.fail;
import static pl.softwaremill.common.test.web.selenium.AbstractSeleniumTest.selenium;

/**
 * @author <NAME> (pawel . wrzeszcz [at] gmail . com)
 * @author <NAME> (kijanowski [at] gmail . com)
 */
public class SeleniumCommands {

    private static final String WAIT_FOR_LOAD = "60000";
    private static final int TIME_OUT = 30;

    public static void waitForPageToLoad() {
        selenium.waitForPageToLoad(WAIT_FOR_LOAD);
    }

    public static void waitFor(String xpath) throws Exception {
        for (int second = 0; ; second++) {
            if (second >= TIME_OUT) {
                Assert.fail("Timed out on xpath: " + xpath);
            }
            if (selenium.isElementPresent(xpath)) {
                break;
            }
            Thread.sleep(1000);
        }
    }

    public static void waitForElementPresent(String element) throws Exception {
        waitForElement(element, TIME_OUT, true);
    }

    public static void waitForElementNotPresent(String element) throws Exception {
        waitForElement(element, TIME_OUT, false);
    }

    public static void waitForElement(String element, boolean isPresent) throws Exception {
        waitForElement(element, TIME_OUT, isPresent);
    }

    public static void waitForElementPresent(String xpath, int timeout) throws Exception {
        waitForElement(xpath, timeout, true);
    }

    public static void waitForElement(String element, int timeout, boolean isPresent) throws Exception {
        for (int second = 0; ; second++) {
            if (second >= timeout) Assert.fail("Timed out on xpath: " + element);
            try {
                if (selenium.isElementPresent(element) == isPresent) {
                    break;
                }
            }
            catch (Exception e) {
                // Empty
            }
            Thread.sleep(1000);
        }
    }


    public static void clickAndWait(String locator, String timeout) {
        selenium.click(locator);
        selenium.waitForPageToLoad(timeout);
    }

    public static void clickAndWait(String locator) {
        clickAndWait(locator, String.valueOf(TIME_OUT));
    }

    public static void waitForElementVisible(String locator) throws Exception {
        waitForElementVisible(locator, true);
    }

    public static void waitForElementVisible(String locator, boolean isVisible) throws Exception {
        for (int second = 0; ; second++) {
            if (second >= TIME_OUT) Assert.fail("timeout");
            try {
                if (selenium.isVisible(locator) == isVisible) {
                    break;
                }
            }
            catch (Exception e) {
                // Empty
            }
            Thread.sleep(1000);
        }
    }

    public static void waitForTextPresent(String text) throws Exception {
        waitForTextPresent(text, 30);
    }

    public static void waitForTextPresent(String text, int timeout) throws Exception {
        for (int second = 0; ; second++) {
            if (second >= 30) Assert.fail("Timed out waiting for text: " + text);
            try {
                if (selenium.isTextPresent(text)) {
                    break;
                }
            }
            catch (Exception e) {
                // Empty
            }
            Thread.sleep(1000);
        }
    }

    public static void clickOncePresent(String xpath) throws Exception {<commit_msg>#17 add waitForTextNotPresent to SeleniumCommands<commit_after>package pl.softwaremill.common.test.web.selenium;

import org.testng.Assert;

import static pl.softwaremill.common.test.web.selenium.AbstractSeleniumTest.fail;
import static pl.softwaremill.common.test.web.selenium.AbstractSeleniumTest.selenium;

/**
 * @author <NAME> (pawel . wrzeszcz [at] gmail . com)
 * @author <NAME> (kijanowski [at] gmail . com)
 */
public class SeleniumCommands {

    private static final String WAIT_FOR_LOAD = "60000";
    private static final int TIME_OUT = 30;

    public static void waitForPageToLoad() {
        selenium.waitForPageToLoad(WAIT_FOR_LOAD);
    }

    public static void waitFor(String xpath) throws Exception {
        for (int second = 0; ; second++) {
            if (second >= TIME_OUT) {
                Assert.fail("Timed out on xpath: " + xpath);
            }
            if (selenium.isElementPresent(xpath)) {
                break;
            }
            Thread.sleep(1000);
        }
    }

    public static void waitForElementPresent(String element) throws Exception {
        waitForElement(element, TIME_OUT, true);
    }

    public static void waitForElementNotPresent(String element) throws Exception {
        waitForElement(element, TIME_OUT, false);
    }

    public static void waitForElement(String element, boolean isPresent) throws Exception {
        waitForElement(element, TIME_OUT, isPresent);
    }

    public static void waitForElementPresent(String xpath, int timeout) throws Exception {
        waitForElement(xpath, timeout, true);
    }

    public static void waitForElement(String element, int timeout, boolean isPresent) throws Exception {
        for (int second = 0; ; second++) {
            if (second >= timeout) Assert.fail("Timed out on xpath: " + element);
            try {
                if (selenium.isElementPresent(element) == isPresent) {
                    break;
                }
            }
            catch (Exception e) {
                // Empty
            }
            Thread.sleep(1000);
        }
    }


    public static void clickAndWait(String locator, String timeout) {
        selenium.click(locator);
        selenium.waitForPageToLoad(timeout);
    }

    public static void clickAndWait(String locator) {
        clickAndWait(locator, String.valueOf(TIME_OUT));
    }

    public static void waitForElementVisible(String locator) throws Exception {
        waitForElementVisible(locator, true);
    }

    public static void waitForElementVisible(String locator, boolean isVisible) throws Exception {
        for (int second = 0; ; second++) {
            if (second >= TIME_OUT) Assert.fail("timeout");
            try {
                if (selenium.isVisible(locator) == isVisible) {
                    break;
                }
            }
            catch (Exception e) {
                // Empty
            }
            Thread.sleep(1000);
        }
    }

    public static void waitForTextPresent(String text) throws Exception {
        waitForText(text, TIME_OUT, true);
    }

    public static void waitForTextPresent(String text, int timeout) throws Exception {
        waitForText(text, timeout, true);
    }

    public static void waitForTextNotPresent(String text) throws Exception {
        waitForText(text, TIME_OUT, false);
    }

    public static void waitForTextNotPresent(String text, int timeout) throws Exception {
        waitForText(text, timeout, false);
    }

    public static void waitForText(String text, int timeout, boolean isPresent) throws Exception {
        for (int second = 0; ; second++) {
            if (second >= timeout) Assert.fail("Timed out waiting for text: " + text);
            try {
                if (selenium.isTextPresent(text) == isPresent) {
                    break;
                }
            }
            catch (Exception e) {
                // Empty
            }
            Thread.sleep(1000);
        }
    }

    public static void clickOncePresent(String xpath) throws Exception {
{'fraction_non_alphanumeric': 0.09039696056596358, 'fraction_numerical': 0.007860605266605529, 'mean_word_length': 2.1095723014256618, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, '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': '3116354', 'n_tokens_mistral': 2142, 'n_tokens_neox': 1995, 'n_words': 534}