<commit_before>/*
 * Copyright (C) 2013 salesforce.com, inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.auraframework.util;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;

import junit.framework.Assert;

import org.apache.commons.lang3.StringEscapeUtils;
import org.auraframework.test.SauceUtil;
import org.auraframework.util.json.JsonReader;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.StaleElementReferenceException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;

import com.google.common.base.Function;
import com.google.common.collect.Lists;

/**
 * A place to put common UI testing specific helper methods
 */

public class AuraUITestingUtil {
    private final WebDriver driver;
    private long timeoutInSecs = 30;
    private int rerunCount = 0;

    public AuraUITestingUtil(WebDriver driver) {
        this.driver = driver;
        if (SauceUtil.areTestsRunningOnSauce()) {
            // things are slower in SauceLabs
            timeoutInSecs = 120;
        }
    }

    public void setTimeoutInSecs(long timeoutInSecs) {
        this.timeoutInSecs = timeoutInSecs;
    }

    /**
     * An internal class to wait for and retrieve an element from the driver.
     */
    private static class WaitAndRetrieve implements ExpectedCondition<Boolean> {
        private final By locator;
        private WebElement found = null;

        public WaitAndRetrieve(By locator) {
            this.locator = locator;
        }

        @Override
        public Boolean apply(WebDriver d) {
            List<WebElement> elements = d.findElements(locator);

            if (elements.size() > 0) {
                found = elements.get(0);
                return true;<commit_msg>Changing timeoutInSecs variable to 240 from 120 @bug W-2360424@ @rev tbliss@<commit_after>/*
 * Copyright (C) 2013 salesforce.com, inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.auraframework.util;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;

import junit.framework.Assert;

import org.apache.commons.lang3.StringEscapeUtils;
import org.auraframework.test.SauceUtil;
import org.auraframework.util.json.JsonReader;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.StaleElementReferenceException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;

import com.google.common.base.Function;
import com.google.common.collect.Lists;

/**
 * A place to put common UI testing specific helper methods
 */

public class AuraUITestingUtil {
    private final WebDriver driver;
    private long timeoutInSecs = 30;
    private int rerunCount = 0;

    public AuraUITestingUtil(WebDriver driver) {
        this.driver = driver;
        if (SauceUtil.areTestsRunningOnSauce()) {
            // things are slower in SauceLabs
            timeoutInSecs = 240;
        }
    }

    public void setTimeoutInSecs(long timeoutInSecs) {
        this.timeoutInSecs = timeoutInSecs;
    }

    /**
     * An internal class to wait for and retrieve an element from the driver.
     */
    private static class WaitAndRetrieve implements ExpectedCondition<Boolean> {
        private final By locator;
        private WebElement found = null;

        public WaitAndRetrieve(By locator) {
            this.locator = locator;
        }

        @Override
        public Boolean apply(WebDriver d) {
            List<WebElement> elements = d.findElements(locator);

            if (elements.size() > 0) {
                found = elements.get(0);
                return true;
{'fraction_non_alphanumeric': 0.08371665133394664, 'fraction_numerical': 0.008647654093836247, 'mean_word_length': 3.34185303514377, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5628305', 'n_tokens_mistral': 1609, 'n_tokens_neox': 1516, 'n_words': 453}