text:
package com.github.markusbernhardt.selenium2library.keywords;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.robotframework.javalib.annotation.ArgumentNames;
import org.robotframework.javalib.annotation.Autowired;
import org.robotframework.javalib.annotation.RobotKeyword;
import org.robotframework.javalib.annotation.RobotKeywordOverload;
import org.robotframework.javalib.annotation.RobotKeywords;

import com.github.markusbernhardt.selenium2library.RunOnFailureKeywordsAdapter;
import com.github.markusbernhardt.selenium2library.Selenium2LibraryNonFatalException;
import com.github.markusbernhardt.selenium2library.locators.ElementFinder;
import com.github.markusbernhardt.selenium2library.utils.Python;

@RobotKeywords
public class Element extends RunOnFailureKeywordsAdapter {

	/**
	 * Instantiated BrowserManagement keyword bean
	 */
	@Autowired
	protected BrowserManagement browserManagement;

	/**
	 * Instantiated FormElement keyword bean
	 */
	@Autowired
	protected FormElement formElement;

	/**
	 * Instantiated Logging keyword bean
	 */
	@Autowired
	protected Logging logging;

	// ##############################
	// Keywords - Element Lookups
	// ##############################

	@RobotKeywordOverload
	@ArgumentNames({ "text" })
	public void currentFrameContains(String text) {
		currentFrameContains(text, "INFO");
	}

	/**
	 * Verify the current frame contains text.

	 *

	 * See `Introduction` for details about log levels.

	 *
	 * @param text
	 *            The text to verify.
	 * @param logLevel
	 *            Default=INFO. Optional log level.
	 */
	@RobotKeyword
	@ArgumentNames({ "text", "logLevel=INFO" })
	public void currentFrameContains(String text, String logLevel) {
		if (!isTextPresent(text)) {
			logging.log(String.format("Current Frame Contains: %s => FAILED", text), logLevel);
			throw new Selenium2LibraryNonFatalException(
					String.format("Page should have contained text '%s', but did not.", text));
		} else {
			logging.log(String.format("Current Frame Contains: %s => OK", text), logLevel);
		}
	}

	@RobotKeywordOverload
	public void currentFrameShouldNotContain(String text) {
		currentFrameShouldNotContain(text, "INFO");
	}

	/**
	 * Verify the current frame does not contain text.

	 *

	 * See `Introduction` for details about log levels.

	 *
	 * @param text
	 *            The text to verify.
	 * @param logLevel
	 *            Default=INFO. Optional log level.
	 */
	@RobotKeyword
	@ArgumentNames({ "text", "logLevel=INFO" })
	public void currentFrameShouldNotContain(String text, String logLevel) {
		if (isTextPresent(text)) {
			logging.log(String.format("Current Frame Should Not Contain: %s => FAILED", text), logLevel);
			throw new Selenium2LibraryNonFatalException(
					String.format("Page should have not contained text '%s', but did.", text));
		} else {
			logging.log(String.format("Current Frame Should Not Contain: %s => OK", text), logLevel);
		}
	}

	@RobotKeywordOverload
	public void elementShouldContain(String locator, String text) {
		elementShouldContain(locator, text, "");
	}

	/**
	 * Verify the element identified by locator contains text.

	 *

	 * See `Introduction` for details about locators.
	 *
	 * @param locator
	 *            The locator to locate the element.
	 * @param text
	 *            The text to verify.
	 * @param message
	 *            Default=NONE. Optional custom error message.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator", "text", "message=NONE" })
	public void elementShouldContain(String locator, String text, String message) {
		String actual = getText(locator);

		if (!actual.toLowerCase().contains(text.toLowerCase())) {
			logging.info(String.format("Element Should Contain: %s => FAILED", text));
			throw new Selenium2LibraryNonFatalException(
					String.format("Element should have contained text '%s', but its text was %s.", text, actual));
		} else {
			logging.info(String.format("Element Should Contain: %s => OK", text));
		}
	}

	@RobotKeywordOverload
	public void elementShouldNotContain(String locator, String text) {
		elementShouldNotContain(locator, text, "");
	}

	/**
	 * Verify the element identified by locator does not contain
	 * text.

	 *

	 * See `Introduction` for details about locators.
	 *
	 * @param locator
	 *            The locator to locate the element.
	 * @param text
	 *            The text to verify.
	 * @param message
	 *            Default=NONE. Optional custom error message.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator", "text", "message=NONE" })
	public void elementShouldNotContain(String locator, String text, String message) {
		String actual = getText(locator);

		if (actual.toLowerCase().contains(text.toLowerCase())) {
			logging.info(String.format("Element Should Not Contain: %s => FAILED", text));
			throw new Selenium2LibraryNonFatalException(
					String.format("Element should not have contained text '%s', but its text was %s.", text, actual));
		} else {
			logging.info(String.format("Element Should Not Contain: %s => OK", text));
		}
	}

	@RobotKeywordOverload
	public void frameShouldContain(String locator, String text) {
		frameShouldContain(locator, text, "INFO");
	}

	/**
	 * Verify the frame identified by locator contains text.

	 *

	 * See `Introduction` for details about locators.
	 *
	 * @param locator
	 *            The locator to locate the frame.
	 * @param text
	 *            The text to verify.
	 * @param logLevel
	 *            Default=INFO. Optional log level.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator", "text", "logLevel=INFO" })
	public void frameShouldContain(String locator, String text, String logLevel) {
		if (!frameContains(locator, text)) {
			logging.log(String.format("Frame Should Contain: %s => FAILED", text), logLevel);
			throw new Selenium2LibraryNonFatalException(
					String.format("Frame should have contained text '%s', but did not.", text));
		} else {
			logging.log(String.format("Frame Should Contain: %s => OK", text), logLevel);
		}
	}

	/**
	 * Verify the frame identified by locator does not contain
	 * text.

	 *

	 * See `Introduction` for details about locators.
	 *
	 * @param locator
	 *            The locator to locate the frame.
	 * @param text
	 *            The text to verify.
	 * @param logLevel
	 *            Default=INFO. Optional log level.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator", "text", "logLevel=INFO" })
	public void frameShouldNotContain(String locator, String text, String logLevel) {
		if (frameContains(locator, text)) {
			logging.log(String.format("Frame Should Not Contain: %s => FAILED", text), logLevel);
			throw new Selenium2LibraryNonFatalException(
					String.format("Frame should not have contained text '%s', but did.", text));
		} else {
			logging.log(String.format("Frame Should Not Contain: %s => OK", text), logLevel);
		}
	}

	@RobotKeywordOverload
	public void pageShouldContain(String text) {
		pageShouldContain(text, "INFO");
	}

	/**
	 * Verify the current page contains text.

	 *

	 * See `Introduction` for details about log levels.

	 *
	 * @param text
	 *            The text to verify.
	 * @param logLevel
	 *            Default=INFO. Optional log level.
	 */
	@RobotKeyword
	@ArgumentNames({ "text", "logLevel=INFO" })
	public void pageShouldContain(String text, String logLevel) {
		if (!pageContains(text)) {
			logging.log(String.format("Page Should Contain: %s => FAILED", text), logLevel);
			throw new Selenium2LibraryNonFatalException(
					String.format("Page should have contained text '%s' but did not.", text));
		} else {
			logging.log(String.format("Page Should Contain: %s => OK", text), logLevel);
		}
	}

	@RobotKeywordOverload
	public void pageShouldNotContain(String text) {
		pageShouldNotContain(text, "INFO");
	}

	/**
	 * Verify the current page does not contain text.

	 *

	 * See `Introduction` for details about log levels.

	 *
	 * @param text
	 *            The text to verify.
	 * @param logLevel
	 *            Default=INFO. Optional log level.
	 */
	@RobotKeyword
	@ArgumentNames({ "text", "logLevel=INFO" })
	public void pageShouldNotContain(String text, String logLevel) {
		if (pageContains(text)) {
			logging.log(String.format("Page Should Not Contain: %s => FAILED", text), logLevel);
			throw new Selenium2LibraryNonFatalException(
					String.format("Page should not have contained text '%s' but did.", text));
		} else {
			logging.log(String.format("Page Should Not Contain: %s => OK", text), logLevel);
		}
	}

	@RobotKeywordOverload
	public void pageShouldContainElement(String locator) {
		pageShouldContainElement(locator, "", "INFO");
	}

	@RobotKeywordOverload
	public void pageShouldContainElement(String locator, String message) {
		pageShouldContainElement(locator, message, "INFO");
	}

	/**
	 * Verify the element identified by locator is found on the current
	 * page.

	 *

	 * Key attributes for arbitrary elements are id and name. See `Introduction`
	 * for details about log levels and locators.

	 *
	 * @param locator
	 *            The locator to locate the element.
	 * @param message
	 *            Default=NONE. Optional custom error message.
	 * @param logLevel
	 *            Default=INFO. Optional log level.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator", "message=NONE", "logLevel=INFO" })
	public void pageShouldContainElement(String locator, String message, String logLevel) {
		pageShouldContainElement(locator, null, message, "INFO");
	}

	protected void pageShouldContainElement(String locator, String tag, String message, String logLevel) {
		String name = tag != null ? tag : "element";
		if (!isElementPresent(locator, tag)) {
			if (message == null || message.equals("")) {
				message = String.format("Page should have contained %s '%s' but did not", name, locator);
			}
			logging.log(message, logLevel);
			throw new Selenium2LibraryNonFatalException(message);
		} else {
			logging.log(String.format("Current page contains %s '%s'.", name, locator), logLevel);
		}
	}

	@RobotKeywordOverload
	public void pageShouldNotContainElement(String locator) {
		pageShouldNotContainElement(locator, "", "INFO");
	}

	@RobotKeywordOverload
	public void pageShouldNotContainElement(String locator, String message) {
		pageShouldNotContainElement(locator, message, "INFO");
	}

	/**
	 * Verify the element identified by locator is not found on the
	 * current page.

	 *

	 * Key attributes for arbitrary elements are id and name. See `Introduction`
	 * for details about log levels and locators.

	 *
	 * @param locator
	 *            The locator to locate the element.
	 * @param message
	 *            Default=NONE. Optional custom error message.
	 * @param logLevel
	 *            Default=INFO. Optional log level.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator", "message=NONE", "logLevel=INFO" })
	public void pageShouldNotContainElement(String locator, String message, String logLevel) {
		pageShouldNotContainElement(locator, null, message, "INFO");
	}

	protected void pageShouldNotContainElement(String locator, String tag, String message, String logLevel) {
		String name = tag != null ? tag : "element";
		if (isElementPresent(locator, tag)) {
			if (message == null || message.equals("")) {
				message = String.format("Page should not have contained %s '%s' but did", name, locator);
			}
			logging.log(message, logLevel);
			throw new Selenium2LibraryNonFatalException(message);
		} else {
			logging.log(String.format("Current page does not contain %s '%s'.", name, locator), logLevel);
		}
	}

	// ##############################
	// Keywords - Attributes
	// ##############################

	/**
	 * Assigns a temporary identifier to the element identified by
	 * locator

	 *

	 * This is mainly useful, when the locator is a complicated and slow XPath
	 * expression. The identifier expires when the page is reloaded.

	 *

	 * Example:
	 *

	 *

	 * Assign ID to Element
	 * xpath=//div[@id=\"first_div\"]
	 * my id
	 *

	 *

	 * Page Should Contain Element
	 * my id
	 *
	 *

	 *

	 *
	 * @param locator
	 *            The locator to locate the element.
	 * @param id
	 *            The id to assign.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator", "id" })
	public void assignIdToElement(String locator, String id) {
		logging.info(String.format("Assigning temporary id '%s' to element '%s'", id, locator));
		List<WebElement> elements = elementFind(locator, true, true);

		((JavascriptExecutor) browserManagement.getCurrentWebDriver())
				.executeScript(String.format("arguments[0].id = '%s';", id), elements.get(0));
	}

	/**
	 * Verify the element identified by locator is enabled.

	 *

	 * Key attributes for arbitrary elements are id and name. See `Introduction`
	 * for details about locators.

	 *
	 * @param locator
	 *            The locator to locate the element.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator" })
	public void elementShouldBeEnabled(String locator) {
		if (!isEnabled(locator)) {
			throw new Selenium2LibraryNonFatalException(String.format("Element %s is disabled.", locator));
		}
	}

	/**
	 * Verify the element identified by locator is disabled.

	 *

	 * Key attributes for arbitrary elements are id and name. See `Introduction`
	 * for details about locators.

	 *
	 * @param locator
	 *            The locator to locate the element.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator" })
	public void elementShouldBeDisabled(String locator) {
		if (isEnabled(locator)) {
			throw new Selenium2LibraryNonFatalException(String.format("Element %s is enabled.", locator));
		}
	}

	@RobotKeywordOverload
	public void elementShouldBeSelected(String locator) {
		elementShouldBeSelected(locator, "");
	}

	/**
	 * Verify the element identified by locator is selected.

	 *

	 * Key attributes for arbitrary elements are id and name. See `Introduction`
	 * for details about locators.

	 *
	 * @param locator
	 *            The locator to locate the element.
	 * @param message
	 *            Default=NONE. Optional custom error message.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator", "message=NONE" })
	public void elementShouldBeSelected(String locator, String message) {
		logging.info(String.format("Verifying element '%s' is selected.", locator));
		boolean selected = isSelected(locator);

		if (!selected) {
			if (message == null || message.equals("")) {
				message = String.format("Element '%s' should be selected, but it is not.", locator);
			}
			throw new Selenium2LibraryNonFatalException(message);
		}
	}

	@RobotKeywordOverload
	public void elementShouldNotBeSelected(String locator) {
		elementShouldNotBeSelected(locator, "");
	}

	/**
	 * Verify the element identified by locator is not selected.

	 *

	 * Key attributes for arbitrary elements are id and name. See `Introduction`
	 * for details about locators.

	 *
	 * @param locator
	 *            The locator to locate the element.
	 * @param message
	 *            Default=NONE. Optional custom error message.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator", "message=NONE" })
	public void elementShouldNotBeSelected(String locator, String message) {
		logging.info(String.format("Verifying element '%s' is not selected.", locator));
		boolean selected = isSelected(locator);

		if (selected) {
			if (message == null || message.equals("")) {
				message = String.format("Element '%s' should not be selected, but it is.", locator);
			}
			throw new Selenium2LibraryNonFatalException(message);
		}
	}

	@RobotKeywordOverload
	public void elementShouldBeVisible(String locator) {
		elementShouldBeVisible(locator, "");
	}

	/**
	 * Verify the element identified by locator is visible.

	 *

	 * Herein, visible means that the element is logically visible, not
	 * optically visible in the current browser viewport. For example, an
	 * element that carries display:none is not logically visible, so using this
	 * keyword on that element would fail.

	 *

	 * Key attributes for arbitrary elements are id and name. See `Introduction`
	 * for details about locators.

	 *
	 * @param locator
	 *            The locator to locate the element.
	 * @param message
	 *            Default=NONE. Optional custom error message.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator", "message=NONE" })
	public void elementShouldBeVisible(String locator, String message) {
		logging.info(String.format("Verifying element '%s' is visible.", locator));
		boolean visible = isVisible(locator);

		if (!visible) {
			if (message == null || message.equals("")) {
				message = String.format("Element '%s' should be visible, but it is not.", locator);
			}
			throw new Selenium2LibraryNonFatalException(message);
		}
	}

	@RobotKeywordOverload
	public void elementShouldNotBeVisible(String locator) {
		elementShouldNotBeVisible(locator, "");
	}

	/**
	 * Verify the element identified by locator is not visible.

	 *

	 * Herein, visible means that the element is logically visible, not
	 * optically visible in the current browser viewport. For example, an
	 * element that carries display:none is not logically visible, so using this
	 * keyword on that element would fail.

	 *

	 * Key attributes for arbitrary elements are id and name. See `Introduction`
	 * for details about locators.

	 *
	 * @param locator
	 *            The locator to locate the element.
	 * @param message
	 *            Default=NONE. Optional custom error message.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator", "message=NONE" })
	public void elementShouldNotBeVisible(String locator, String message) {
		logging.info(String.format("Verifying element '%s' is not visible.", locator));
		boolean visible = isVisible(locator);

		if (visible) {
			if (message == null || message.equals("")) {
				message = String.format("Element '%s' should not be visible, but it is.", locator);
			}
			throw new Selenium2LibraryNonFatalException(message);
		}
	}

	@RobotKeywordOverload
	public void elementShouldBeClickable(String locator) {
		elementShouldBeClickable(locator, "");
	}

	/**
	 * Verify the element identified by locator is clickable.

	 *

	 * Key attributes for arbitrary elements are id and name. See `Introduction`
	 * for details about locators.

	 *
	 * @param locator
	 *            The locator to locate the element.
	 * @param message
	 *            Default=NONE. Optional custom error message.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator", "message=NONE" })
	public void elementShouldBeClickable(String locator, String message) {
		logging.info(String.format("Verifying element '%s' is clickable.", locator));
		boolean clickable = isClickable(locator);

		if (!clickable) {
			if (message == null || message.equals("")) {
				message = String.format("Element '%s' should be clickable, but it is not.", locator);
			}
			throw new Selenium2LibraryNonFatalException(message);
		}
	}

	@RobotKeywordOverload
	public void elementShouldNotBeClickable(String locator) {
		elementShouldNotBeClickable(locator, "");
	}

	/**
	 * Verify the element identified by locator is not clickable.

	 *

	 * Key attributes for arbitrary elements are id and name. See `Introduction`
	 * for details about locators.

	 *
	 * @param locator
	 *            The locator to locate the element.
	 * @param message
	 *            Default=NONE. Optional custom error message.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator", "message=NONE" })
	public void elementShouldNotBeClickable(String locator, String message) {
		logging.info(String.format("Verifying element '%s' is not clickable.", locator));
		boolean clickable = isClickable(locator);

		if (clickable) {
			if (message == null || message.equals("")) {
				message = String.format("Element '%s' should not be clickable, but it is.", locator);
			}
			throw new Selenium2LibraryNonFatalException(message);
		}
	}

	@RobotKeywordOverload
	public void elementTextShouldBe(String locator, String expected) {
		elementTextShouldBe(locator, expected, "");
	}

	/**
	 * Verify the text of the element identified by locator is exactly
	 * text.

	 *

	 * In contrast to `Element Should Contain`, this keyword does not try a
	 * substring match but an exact match on the element identified by locator.
	 *

	 *

	 * Key attributes for arbitrary elements are id and name. See `Introduction`
	 * for details about locators.

	 *
	 * @param locator
	 *            The locator to locate the element.
	 * @param text
	 *            The text to verify.
	 * @param message
	 *            Default=NONE. Optional custom error message.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator", "text", "message=NONE" })
	public void elementTextShouldBe(String locator, String text, String message) {
		List<WebElement> elements = elementFind(locator, true, true);
		String actual = elements.get(0).getText();

		if (!text.equals(actual)) {
			if (message == null || message.equals("")) {
				message = String.format("The text of element '%s' should have been '%s', but it was '%s'.", locator,
						text, actual);
			}
			throw new Selenium2LibraryNonFatalException(message);
		}
	}

	@RobotKeywordOverload
	public void elementTextShouldNotBe(String locator, String expected) {
		elementTextShouldNotBe(locator, expected, "");
	}

	/**
	 * Verify the text of the element identified by locator is not
	 * exactly text.

	 *

	 * In contrast to `Element Should Not Contain`, this keyword does not try a
	 * substring match but an exact match on the element identified by locator.
	 *

	 *

	 * Key attributes for arbitrary elements are id and name. See `Introduction`
	 * for details about locators.

	 *
	 * @param locator
	 *            The locator to locate the element.
	 * @param text
	 *            The text to verify.
	 * @param message
	 *            Default=NONE. Optional custom error message.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator", "text", "message=NONE" })
	public void elementTextShouldNotBe(String locator, String text, String message) {
		List<WebElement> elements = elementFind(locator, true, true);
		String actual = elements.get(0).getText();

		if (text.equals(actual)) {
			if (message == null || message.equals("")) {
				message = String.format("The text of element '%s' should have been '%s', but it was '%s'.", locator,
						text, actual);
			}
			throw new Selenium2LibraryNonFatalException(message);
		}
	}

	/**
	 * Returns the value of an element attribute.

	 *

	 * The attribute_locator consists of element locator followed by an @
	 * sign and attribute name. Example: element_id@class

	 *

	 * Key attributes for arbitrary elements are id and name. See `Introduction`
	 * for details about locators.

	 *
	 * @param attributeLocator
	 *            The attribute locator.
	 * @return The attribute value.
	 */
	@RobotKeyword
	@ArgumentNames({ "attributeLocator" })
	public String getElementAttribute(String attributeLocator) {
		String[] parts = parseAttributeLocator(attributeLocator);

		List<WebElement> elements = elementFind(parts[0], true, false);

		if (elements.size() == 0) {
			throw new Selenium2LibraryNonFatalException(String.format("Element '%s' not found.", parts[0]));
		}

		return elements.get(0).getAttribute(parts[1]);
	}

	/**
	 * Clears the text from element identified by locator.

	 *

	 * This keyword does not execute any checks on whether or not the clear
	 * method has succeeded, so if any subsequent checks are needed, they should
	 * be executed using method `Element Text Should Be`.

	 *

	 * Also, this method will use WebDriver's internal _element.clear()_ method,
	 * i.e. it will not send any keypresses, and it will not have any effect
	 * whatsoever on elements other than input textfields or input textareas.
	 * Clients relying on keypresses should implement their own methods.

	 *

	 * Key attributes for arbitrary elements are id and name. See `Introduction`
	 * for details about locators.

	 *
	 * @param locator
	 *            The locator to locate the element.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator" })
	public void clearElementText(String locator) {
		List<WebElement> elements = elementFind(locator, true, true);

		elements.get(0).clear();
	}

	/**
	 * Returns inner element id by index of element identified by
	 * locator which is matched by matchid.

	 *

	 * The position is returned in pixels off the left side of the page, as an
	 * integer. Fails if the matching element is not found.

	 *

	 * Key attributes for arbitrary elements are id and name. See `Introduction`
	 * for details about locators.

	 *
	 * @param locator
	 *            The locator to locate the element.
	 * @param matchid
	 *            partial inner element id to match
	 * @param index
	 *            position of the inner element to match
	 * @return The element id
	 */
	@RobotKeyword
	@ArgumentNames({ "locator", "matchid", "index" })
	public String getInnerElementId(String locator, String matchid, int index) {
		List<WebElement> elements = elementFind(locator, true, true);

		if (elements.size() == 0) {
			throw new Selenium2LibraryNonFatalException(String.format("get Inner element '%s' not found.", locator));
		}

		String xpathId = ".//*[contains(@id," + matchid + ")]";

		List<WebElement> tmpe = elements.get(0).findElements((By.xpath(xpathId)));
		if (tmpe.size() == 0) {
			throw new Selenium2LibraryNonFatalException(
					String.format("No Inner element '%s' not found by '%s'", locator, matchid));
		}
		String eId = tmpe.get(index).getAttribute("id");

		logging.info(String.format("Found element ID: '%s'.", eId));

		return eId;

	}

	/**
	 * Returns horizontal position of element identified by locator.

	 *

	 * The position is returned in pixels off the left side of the page, as an
	 * integer. Fails if the matching element is not found.

	 *

	 * Key attributes for arbitrary elements are id and name. See `Introduction`
	 * for details about locators.

	 *
	 * @param locator
	 *            The locator to locate the element.
	 * @return The horizontal position
	 */
	@RobotKeyword
	@ArgumentNames({ "locator" })
	public int getHorizontalPosition(String locator) {
		List<WebElement> elements = elementFind(locator, true, false);

		if (elements.size() == 0) {
			throw new Selenium2LibraryNonFatalException(
					String.format("Could not determine position for '%s'.", locator));
		}

		return elements.get(0).getLocation().getX();
	}

	/**
	 * Returns the value attribute of the element identified by locator.
	 *

	 *

	 * Key attributes for arbitrary elements are id and name. See `Introduction`
	 * for details about locators.

	 *
	 * @param locator
	 *            The locator to locate the element.
	 * @return The value attribute of the element.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator" })
	public String getValue(String locator) {
		return getValue(locator, null);
	}

	protected String getValue(String locator, String tag) {
		List<WebElement> elements = elementFind(locator, true, false, tag);

		if (elements.size() == 0) {
			return null;
		}

		return elements.get(0).getAttribute("value");
	}

	/**
	 * Returns the text of the element identified by locator.

	 *

	 * Key attributes for arbitrary elements are id and name. See `Introduction`
	 * for details about locators.

	 *
	 * @param locator
	 *            The locator to locate the element.
	 * @return The text of the element.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator" })
	public String getText(String locator) {
		List<WebElement> elements = elementFind(locator, true, true);

		if (elements.size() == 0) {
			return null;
		}

		return elements.get(0).getText();
	}

	/**
	 * Returns vertical position of element identified by locator.

	 *

	 * The position is returned in pixels off the top of the page, as an
	 * integer. Fails if the matching element is not found.

	 *

	 * Key attributes for arbitrary elements are id and name. See `Introduction`
	 * for details about locators.

	 *
	 * @param locator
	 *            The locator to locate the element.
	 * @return The vertical position
	 */
	@RobotKeyword
	@ArgumentNames({ "locator" })
	public int getVerticalPosition(String locator) {
		List<WebElement> elements = elementFind(locator, true, false);

		if (elements.size() == 0) {
			throw new Selenium2LibraryNonFatalException(
					String.format("Could not determine position for '%s'.", locator));
		}

		return elements.get(0).getLocation().getY();
	}

	// ##############################
	// Keywords - Mouse Input/Events
	// ##############################

	/**
	 * Click on the element identified by locator.

	 *

	 * Key attributes for arbitrary elements are id and name. See `Introduction`
	 * for details about locators.

	 *
	 * @param locator
	 *            The locator to locate the element.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator" })
	public void clickElement(String locator) {
		logging.info(String.format("Clicking element '%s'.", locator));
		List<WebElement> elements = elementFind(locator, true, true);

		elements.get(0).click();
	}

	/**
	 * Click on the element identified by locator at the coordinates
	 * xOffset and yOffset.

	 *

	 * The cursor is moved at the center of the element and the to the given x/y
	 * offset from that point. Both offsets are specified as negative (left/up)
	 * or positive (right/down) number.

	 *

	 * Key attributes for arbitrary elements are id and name. See `Introduction`
	 * for details about locators.

	 *

	 *
	 * @param locator
	 *            The locator to locate the element.
	 * @param xOffset
	 *            The horizontal offset in pixel. Negative means left, positive
	 *            right.
	 * @param yOffset
	 *            The vertical offset in pixel. Negative means up, positive
	 *            down.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator", "xOffset", "yOffset" })
	public void clickElementAtCoordinates(String locator, String xOffset, String yOffset) {
		logging.info(String.format("Clicking element '%s'in coordinates '%s', '%s'.", locator, xOffset, yOffset));
		List<WebElement> elements = elementFind(locator, true, true);

		WebElement element = elements.get(0);
		Actions action = new Actions(browserManagement.getCurrentWebDriver());
		action.moveToElement(element).moveByOffset(Integer.parseInt(xOffset), Integer.parseInt(yOffset)).perform();
	}

	/**
	 * Double-Click on the element identified by locator.

	 *

	 * Key attributes for arbitrary elements are id and name. See `Introduction`
	 * for details about locators.

	 *
	 * @param locator
	 *            The locator to locate the element.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator" })
	public void doubleClickElement(String locator) {
		logging.info(String.format("Double clicking element '%s'.", locator));

		List<WebElement> elements = elementFind(locator, true, true);
		Actions action = new Actions(browserManagement.getCurrentWebDriver());

		action.doubleClick(elements.get(0)).perform();
	}

	/**
	 * Set the focus to the element identified by locator.

	 *

	 * Key attributes for arbitrary elements are id and name. See `Introduction`
	 * for details about locators.

	 *
	 * @param locator
	 *            The locator to locate the element.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator" })
	public void focus(String locator) {
		List<WebElement> elements = elementFind(locator, true, true);
		((JavascriptExecutor) browserManagement.getCurrentWebDriver()).executeScript("arguments[0].focus();",
				elements.get(0));
	}

	/**
	 * Drag the element identified by the locator source and move it on
	 * top of the element identified by the locator target.

	 *

	 * Key attributes for arbitrary elements are id and name. See `Introduction`
	 * for details about locators.

	 *

	 * Example:
	 *

	 *

	 * Drag And Drop
	 * elem1
	 * elem2
	 * # Move elem1 over elem2
	 *

	 *

	 *
	 * @param source
	 *            The locator to locate the element to drag.
	 * @param target
	 *            The locator to locate the element where to drop the dragged
	 *            element.
	 */
	@RobotKeyword
	@ArgumentNames({ "source", "target" })
	public void dragAndDrop(String source, String target) {
		List<WebElement> sourceElements = elementFind(source, true, true);
		List<WebElement> targetElements = elementFind(target, true, true);

		Actions action = new Actions(browserManagement.getCurrentWebDriver());
		action.dragAndDrop(sourceElements.get(0), targetElements.get(0)).perform();
	}

	/**
	 * Drag the element identified by the locator source and move it by
	 * xOffset and yOffset.

	 *

	 * Both offsets are specified as negative (left/up) or positive (right/down)
	 * number.

	 *

	 * Key attributes for arbitrary elements are id and name. See `Introduction`
	 * for details about locators.

	 *

	 * Example:
	 *

	 *

	 * Drag And Drop By Offset
	 * elem1
	 * 50
	 * 35
	 * # Move elem1 50px right and 35px down.
	 *

	 *

	 *
	 * @param source
	 *            The locator to locate the element to drag.
	 * @param xOffset
	 *            The horizontal offset in pixel. Negative means left, positive
	 *            right.
	 * @param yOffset
	 *            The vertical offset in pixel. Negative means up, positive
	 *            down.
	 */
	@RobotKeyword
	@ArgumentNames({ "source", "xOffset", "yOffset" })
	public void dragAndDropByOffset(String source, int xOffset, int yOffset) {
		List<WebElement> elements = elementFind(source, true, true);

		Actions action = new Actions(browserManagement.getCurrentWebDriver());
		action.dragAndDropBy(elements.get(0), xOffset, yOffset).perform();
	}

	/**
	 * Simulates pressing the left mouse button on the element identified by
	 * locator.

	 *

	 * The element is pressed without releasing the mouse button.

	 *

	 * Key attributes for arbitrary elements are id and name. See `Introduction`
	 * for details about locators.

	 *
	 * @param locator
	 *            The locator to locate the element.
	 * @see Element#mouseDownOnImage
	 * @see Element#mouseDownOnLink
	 */
	@RobotKeyword
	@ArgumentNames({ "locator" })
	public void mouseDown(String locator) {
		logging.info(String.format("Simulating Mouse Down on element '%s'.", locator));
		List<WebElement> elements = elementFind(locator, true, false);

		if (elements.size() == 0) {
			throw new Selenium2LibraryNonFatalException(String.format("ERROR: Element %s not found.", locator));
		}

		Actions action = new Actions(browserManagement.getCurrentWebDriver());
		action.clickAndHold(elements.get(0)).perform();
	}

	/**
	 * Simulates moving the mouse away from the element identified by
	 * locator.

	 *

	 * Key attributes for arbitrary elements are id and name. See `Introduction`
	 * for details about locators.

	 *
	 * @param locator
	 *            The locator to locate the element.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator" })
	public void mouseOut(String locator) {
		logging.info(String.format("Simulating Mouse Out on element '%s'.", locator));
		List<WebElement> elements = elementFind(locator, true, false);

		if (elements.size() == 0) {
			throw new Selenium2LibraryNonFatalException(String.format("ERROR: Element %s not found.", locator));
		}

		WebElement element = elements.get(0);
		Dimension size = element.getSize();
		int offsetX = size.getWidth() / 2 + 1;
		int offsetY = size.getHeight() / 2 + 1;

		Actions action = new Actions(browserManagement.getCurrentWebDriver());
		action.moveToElement(element).moveByOffset(offsetX, offsetY).perform();
	}

	/**
	 * Simulates moving the mouse over the element identified by locator.
	 *

	 *

	 * Key attributes for arbitrary elements are id and name. See `Introduction`
	 * for details about locators.

	 *
	 * @param locator
	 *            The locator to locate the element.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator" })
	public void mouseOver(String locator) {
		logging.info(String.format("Simulating Mouse Over on element '%s'.", locator));
		List<WebElement> elements = elementFind(locator, true, false);

		if (elements.size() == 0) {
			throw new Selenium2LibraryNonFatalException(String.format("ERROR: Element %s not found.", locator));
		}

		WebElement element = elements.get(0);
		Actions action = new Actions(browserManagement.getCurrentWebDriver());
		action.moveToElement(element).perform();
	}

	/**
	 * Simulates releasing the left mouse button on the element identified by
	 * locator.

	 *

	 * Key attributes for arbitrary elements are id and name. See `Introduction`
	 * for details about locators.

	 *
	 * @param locator
	 *            The locator to locate the element.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator" })
	public void mouseUp(String locator) {
		logging.info(String.format("Simulating Mouse Up on element '%s'.", locator));
		List<WebElement> elements = elementFind(locator, true, false);

		if (elements.size() == 0) {
			throw new Selenium2LibraryNonFatalException(String.format("ERROR: Element %s not found.", locator));
		}

		WebElement element = elements.get(0);
		Actions action = new Actions(browserManagement.getCurrentWebDriver());
		action.release(element).perform();
	}

	/**
	 * Opens the context menu on the element identified by locator.

	 *

	 * Key attributes for arbitrary elements are id and name. See `Introduction`
	 * for details about locators.

	 *
	 * @param locator
	 *            The locator to locate the element.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator" })
	public void openContextMenu(String locator) {
		List<WebElement> elements = elementFind(locator, true, true);

		Actions action = new Actions(browserManagement.getCurrentWebDriver());
		action.contextClick(elements.get(0)).perform();
	}

	/**
	 * Simulates the given event on the element identified by
	 * locator.

	 *

	 * This keyword is especially useful, when the element has an OnEvent
	 * handler that needs to be explicitly invoked.

	 *

	 * Key attributes for arbitrary elements are id and name. See `Introduction`
	 * for details about locators.

	 *
	 * @param locator
	 *            The locator to locate the element.
	 * @param event
	 *            The event to invoke.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator", "event" })
	public void simulate(String locator, String event) {
		List<WebElement> elements = elementFind(locator, true, true);
		String script = "element = arguments[0];" + "eventName = arguments[1];" + "if (document.createEventObject) {"
				+ "return element.fireEvent('on' + eventName, document.createEventObject());" + "}"
				+ "var evt = document.createEvent(\"HTMLEvents\");" + "evt.initEvent(eventName, true, true);"
				+ "return !element.dispatchEvent(evt);";

		((JavascriptExecutor) browserManagement.getCurrentWebDriver()).executeScript(script, elements.get(0), event);
	}

	/**
	 * Simulates pressing key on the element identified by locator
	 * .

	 *

	 * Key is either a single character, or a numerical ASCII code of the key
	 * lead by '\\'.

	 *

	 * Key attributes for arbitrary elements are id and name. See `Introduction`
	 * for details about locators.

	 *

	 * Example:
	 *

	 *

	 * Press Key
	 * text_field
	 * q
	 * # Press 'q'
	 *

	 *

	 * Press Key
	 * login_button
	 * \\13
	 * # ASCII code for enter key
	 *

	 *

	 *
	 * @param locator
	 *            The locator to locate the element.
	 * @param key
	 *            The key to press.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator", "key" })
	public void pressKey(String locator, String key) {
		if (key.startsWith("\\") && key.length() > 1) {
			key = mapAsciiKeyCodeToKey(Integer.parseInt(key.substring(1))).toString();
		}
		List<WebElement> element = elementFind(locator, true, true);
		element.get(0).sendKeys(key);
	}

	// ##############################
	// Keywords - Links
	// ##############################

	/**
	 * Click on the link identified by locator.

	 *

	 * Key attributes for links are id, name, href and link text. See
	 * `Introduction` for details about locators.

	 *
	 * @param locator
	 *            The locator to locate the link.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator" })
	public void clickLink(String locator) {
		logging.info(String.format("Clicking link '%s'.", locator));
		List<WebElement> elements = elementFind(locator, true, true, "a");

		elements.get(0).click();
	}

	/**
	 * Returns a list containing ids of all links found in current page.

	 *

	 * If a link has no id, an empty string will be in the list instead.

	 *
	 * @return The list of link ids.
	 */
	@RobotKeyword
	public ArrayList<String> getAllLinks() {
		ArrayList<String> ret = new ArrayList<String>();

		List<WebElement> elements = elementFind("tag=a", false, false, "a");
		for (WebElement element : elements) {
			ret.add(element.getAttribute("id"));
		}

		return ret;
	}

	/**
	 * Simulates pressing the left mouse button on the link identified by
	 * locator.

	 *

	 * The element is pressed without releasing the mouse button.

	 *

	 * Key attributes for links are id, name, href and link text. See
	 * `Introduction` for details about locators.

	 *
	 * @param locator
	 *            The locator to locate the element.
	 * @see Element#mouseDown
	 * @see Element#mouseDownOnImage
	 */
	@RobotKeyword
	@ArgumentNames({ "locator" })
	public void mouseDownOnLink(String locator) {
		List<WebElement> elements = elementFind(locator, true, true, "link");

		Actions action = new Actions(browserManagement.getCurrentWebDriver());
		action.clickAndHold(elements.get(0)).perform();
	}

	@RobotKeywordOverload
	@ArgumentNames({ "locator" })
	public void pageShouldContainLink(String locator) {
		pageShouldContainLink(locator, "", "INFO");
	}

	@RobotKeywordOverload
	@ArgumentNames({ "locator", "message=NONE" })
	public void pageShouldContainLink(String locator, String message) {
		pageShouldContainLink(locator, message, "INFO");
	}

	/**
	 * Verify the link identified by locator is found on the current
	 * page.

	 *

	 * Key attributes for links are id, name, href and link text. See
	 * `Introduction` for details about log levels and locators.

	 *
	 * @param locator
	 *            The locator to locate the link.
	 * @param message
	 *            Default=NONE. Optional custom error message.
	 * @param logLevel
	 *            Default=INFO. Optional log level.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator", "message=NONE", "logLevel=INFO" })
	public void pageShouldContainLink(String locator, String message, String logLevel) {
		pageShouldContainElement(locator, "link", message, logLevel);
	}

	@RobotKeywordOverload
	public void pageShouldNotContainLink(String locator) {
		pageShouldNotContainLink(locator, "", "INFO");
	}

	@RobotKeywordOverload
	public void pageShouldNotContainLink(String locator, String message) {
		pageShouldNotContainLink(locator, message, "INFO");
	}

	/**
	 * Verify the link identified by locator is not found on the current
	 * page.

	 *

	 * Key attributes for links are id, name, href and link text. See
	 * `Introduction` for details about log levels and locators.

	 *
	 * @param locator
	 *            The locator to locate the link.
	 * @param message
	 *            Default=NONE. Optional custom error message.
	 * @param logLevel
	 *            Default=INFO. Optional log level.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator", "message=NONE", "logLevel=INFO" })
	public void pageShouldNotContainLink(String locator, String message, String logLevel) {
		pageShouldNotContainElement(locator, "link", message, logLevel);
	}

	// ##############################
	// Keywords - Images
	// ##############################

	/**
	 * Click on the image identified by locator.

	 *

	 * Key attributes for images are id, src and alt. See `Introduction` for
	 * details about locators.

	 *
	 * @param locator
	 *            The locator to locate the element.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator" })
	public void clickImage(String locator) {
		logging.info(String.format("Clicking image '%s'.", locator));

		List<WebElement> elements = elementFind(locator, true, false, "image");

		if (elements.size() == 0) {
			elements = elementFind(locator, true, true, "input");
		}
		WebElement element = elements.get(0);
		element.click();
	}

	/**
	 * Simulates pressing the left mouse button on the image identified by
	 * locator.

	 *

	 * The element is pressed without releasing the mouse button.

	 *

	 * Key attributes for images are id, src and alt. See `Introduction` for
	 * details about locators.

	 *
	 * @param locator
	 *            The locator to locate the element.
	 * @see Element#mouseDown
	 * @see Element#mouseDownOnLink
	 */
	@RobotKeyword
	@ArgumentNames({ "locator" })
	public void mouseDownOnImage(String locator) {
		List<WebElement> elements = elementFind(locator, true, true, "image");

		Actions action = new Actions(browserManagement.getCurrentWebDriver());
		action.clickAndHold(elements.get(0)).perform();
	}

	@RobotKeywordOverload
	@ArgumentNames({ "locator" })
	public void pageShouldContainImage(String locator) {
		pageShouldContainImage(locator, "", "INFO");
	}

	@RobotKeywordOverload
	@ArgumentNames({ "locator", "message=NONE" })
	public void pageShouldContainImage(String locator, String message) {
		pageShouldContainImage(locator, message, "INFO");
	}

	/**
	 * Verify the image identified by locator is found on the current
	 * page.

	 *

	 * Key attributes for images are id, src and alt. See `Introduction` for
	 * details about log levels and locators.

	 *
	 * @param locator
	 *            The locator to locate the link.
	 * @param message
	 *            Default=NONE. Optional custom error message.
	 * @param logLevel
	 *            Default=INFO. Optional log level.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator", "message=NONE", "logLevel=INFO" })
	public void pageShouldContainImage(String locator, String message, String logLevel) {
		pageShouldContainElement(locator, "image", message, logLevel);
	}

	@RobotKeywordOverload
	@ArgumentNames({ "locator" })
	public void pageShouldNotContainImage(String locator) {
		pageShouldNotContainImage(locator, "", "INFO");
	}

	@RobotKeywordOverload
	@ArgumentNames({ "locator", "message=NONE" })
	public void pageShouldNotContainImage(String locator, String message) {
		pageShouldNotContainImage(locator, message, "INFO");
	}

	/**
	 * Verify the image identified by locator is not found on the current
	 * page.

	 *

	 * Key attributes for images are id, src and alt. See `Introduction` for
	 * details about log levels and locators.

	 *
	 * @param locator
	 *            The locator to locate the link.
	 * @param message
	 *            Default=NONE. Optional custom error message.
	 * @param logLevel
	 *            Default=INFO. Optional log level.
	 */
	@RobotKeyword
	@ArgumentNames({ "locator", "message=NONE", "logLevel=INFO" })
	public void pageShouldNotContainImage(String locator, String message, String logLevel) {
		pageShouldNotContainElement(locator, "image", message, logLevel);
	}

	// ##############################
	// Keywords - Xpath
	// ##############################

	/**
	 * Returns the number of elements located the given xpath.

	 *

	 * If you wish to assert the number of located elements, use `Xpath Should
	 * Match X Times`.

	 *
	 * @param xpath
	 *            The XPath to match page elements
	 * @return The number of located elements
	 */
	@RobotKeyword
	@ArgumentNames({ "xpath" })
	public int getMatchingXpathCount(String xpath) {
		if (!xpath.startsWith("xpath=")) {
			xpath = "xpath=" + xpath;
		}
		List<WebElement> elements = elementFind(xpath, false, false);

		return elements.size();
	}

	@RobotKeywordOverload
	@ArgumentNames({ "xpath", "expectedXpathCount" })
	public void xpathShouldMatchXTimes(String xpath, int expectedXpathCount) {
		xpathShouldMatchXTimes(xpath, expectedXpathCount, "");
	}

	@RobotKeywordOverload
	@ArgumentNames({ "xpath", "expectedXpathCount", "message=NONE" })
	public void xpathShouldMatchXTimes(String xpath, int expectedXpathCount, String message) {
		xpathShouldMatchXTimes(xpath, expectedXpathCount, message, "INFO");
	}

	/**
	 * Verify that the page contains the expectedXpathCount of elements
	 * located by the given xpath.

	 *
	 * @param xpath
	 *            The XPath to match page elements
	 * @param expectedXpathCount
	 *            The expected number of located elements
	 * @param message
	 *            Default=NONE. Optional custom error message.
	 * @param logLevel
	 *            Default=INFO. Optional log level.
	 */
	@RobotKeyword
	@ArgumentNames({ "xpath", "expectedXpathCount", "message=NONE", "logLevel=INFO" })
	public void xpathShouldMatchXTimes(String xpath, int expectedXpathCount, String message, String logLevel) {
		if (!xpath.startsWith("xpath=")) {
			xpath = "xpath=" + xpath;
		}
		List<WebElement> elements = elementFind(xpath, false, false);
		int actualXpathCount = elements.size();

		if (actualXpathCount != expectedXpathCount) {
			if (message == null || message.equals("")) {
				message = String.format("Xpath %s should have matched %s times but matched %s times.", xpath,
						expectedXpathCount, actualXpathCount);
			}
			throw new Selenium2LibraryNonFatalException(message);
		}

		logging.log(String.format("Current page contains %s elements matching '%s'.", actualXpathCount, xpath),
				logLevel);
	}

	// ##############################
	// Internal Methods
	// ##############################

	protected List<WebElement> elementFind(String locator, boolean firstOnly, boolean required) {
		return elementFind(locator, firstOnly, required, null);
	}

	protected List<WebElement> elementFind(String locator, boolean firstOnly, boolean required, String tag) {
		List<WebElement> elements = ElementFinder.find(browserManagement.getCurrentWebDriver(), locator, tag);

		if (required && elements.size() == 0) {
			throw new Selenium2LibraryNonFatalException(
					String.format("Element locator '%s' did not match any elements.", locator));
		}

		if (firstOnly) {
			if (elements.size() > 1) {
				List<WebElement> tmp = new ArrayList<WebElement>();
				tmp.add(elements.get(0));
				elements = tmp;
			}
		}

		return elements;
	}

	protected boolean frameContains(String locator, String text) {
		WebDriver current = browserManagement.getCurrentWebDriver();
		List<WebElement> elements = elementFind(locator, true, true);

		current.switchTo().frame(elements.get(0));
		logging.info(String.format("Searching for text from frame '%s'.", locator));
		boolean found = isTextPresent(text);
		current.switchTo().defaultContent();

		return found;
	}

	protected boolean isTextPresent(String text) {
		String locator = String.format("xpath=//*[contains(., %s)]", escapeXpathValue(text));

		return isElementPresent(locator);
	}

	protected boolean isEnabled(String locator) {
		List<WebElement> elements = elementFind(locator, true, true);
		WebElement element = elements.get(0);

		if (!formElement.isFormElement(element)) {
			throw new Selenium2LibraryNonFatalException(String.format("ERROR: Element %s is not an input.", locator));
		}
		if (!element.isEnabled()) {
			return false;
		}
		String readonly = element.getAttribute("readonly");
		if (readonly != null && (readonly.equals("readonly") || readonly.equals("true"))) {
			return false;
		}

		return true;
	}

	protected boolean isVisible(String locator) {
		List<WebElement> elements = elementFind(locator, true, false);
		if (elements.size() == 0) {
			return false;
		}
		WebElement element = elements.get(0);
		return element.isDisplayed();
	}

	protected boolean isClickable(String locator) {
		List<WebElement> webElements = elementFind(locator, true, false);
		if (webElements.size() == 0) {
			return false;
		}
		WebElement element = webElements.get(0);
		return element.isDisplayed() && element.isEnabled();
	}

	protected boolean isSelected(String locator) {
		List<WebElement> webElements = elementFind(locator, true, false);
		if (webElements.size() == 0) {
			return false;
		}
		WebElement element = webElements.get(0);
		return element.isSelected();
	}

	protected String[] parseAttributeLocator(String attributeLocator) {
		int index = attributeLocator.lastIndexOf('@');
		if (index <= 0) {
			throw new Selenium2LibraryNonFatalException(
					String.format("Attribute locator '%s' does not contain an element locator.", attributeLocator));
		}
		if (index + 1 == attributeLocator.length()) {
			throw new Selenium2LibraryNonFatalException(
					String.format("Attribute locator '%s' does not contain an attribute name.", attributeLocator));
		}
		String[] parts = new String[2];
		parts[0] = attributeLocator.substring(0, index);
		parts[1] = attributeLocator.substring(index + 1);

		return parts;
	}

	protected boolean isElementPresent(String locator) {
		return isElementPresent(locator, null);
	}

	protected boolean isElementPresent(String locator, String tag) {
		return elementFind(locator, true, false, tag).size() != 0;
	}

	protected boolean pageContains(String text) {
		WebDriver current = browserManagement.getCurrentWebDriver();
		current.switchTo().defaultContent();

		if (isTextPresent(text)) {
			return true;
		}

		List<WebElement> elements = elementFind("xpath=//frame|//iframe", false, false);
		Iterator<WebElement> it = elements.iterator();
		while (it.hasNext()) {
			current.switchTo().frame(it.next());
			boolean found = isTextPresent(text);
			current.switchTo().defaultContent();
			if (found) {
				return true;
			}
		}

		return false;
	}

	protected CharSequence mapAsciiKeyCodeToKey(int keyCode) {
		switch (keyCode) {
		case 0:
			return Keys.NULL;
		case 8:
			return Keys.BACK_SPACE;
		case 9:
			return Keys.TAB;
		case 10:
			return Keys.RETURN;
		case 13:
			return Keys.ENTER;
		case 24:
			return Keys.CANCEL;
		case 27:
			return Keys.ESCAPE;
		case 32:
			return Keys.SPACE;
		case 42:
			return Keys.MULTIPLY;
		case 43:
			return Keys.ADD;
		case 44:
			return Keys.SEPARATOR;
		case 45:
			return Keys.SUBTRACT;
		case 56:
			return Keys.DECIMAL;
		case 57:
			return Keys.DIVIDE;
		case 59:
			return Keys.SEMICOLON;
		case 61:
			return Keys.EQUALS;
		case 127:
			return Keys.DELETE;
		default:
			return new StringBuffer((char) keyCode);
		}
	}

	public static String escapeXpathValue(String value) {
		if (value.contains("\"") && value.contains("'")) {
			String[] partsWoApos = value.split("'");
			return String.format("concat('%s')", Python.join("', \"'\", '", Arrays.asList(partsWoApos)));
		}
		if (value.contains("'")) {
			return String.format("\"%s\"", value);
		}
		return String.format("'%s'", value);
	}

}


text:
module Pretender
  module Rails
    class Railtie < ::Rails::Railtie
      initializer "pretender.configure_rails_initialization" do
        ::Rails.application.middleware.use Pretender::Rails::Middleware
      end
    end
  end
end

redpajama_set_name: RedPajamaGithub


text:
'use strict';

module.exports = function(app) {
	var users = require('../../app/controllers/users.server.controller');
	var buildings = require('../../app/controllers/buildings.server.controller');

	// Buildings Routes
	app.route('/buildings')
		.get(buildings.list)
		.post(users.requiresLogin, buildings.create);

	app.route('/buildings/:buildingId')
		.get(buildings.read)
		.put(users.requiresLogin, buildings.hasAuthorization, buildings.update)
		.delete(users.requiresLogin, buildings.hasAuthorization, buildings.delete);

	// Finish by binding the Building middleware
	app.param('buildingId', buildings.buildingByID);
};


text:
Before you submit your pull request consider the following guidelines:

- Search [GitHub](https://github.com/ngOfficeUIFabric/ng-officeuifabric/pulls) for an open or closed Pull Request
  that relates to your submission. You don't want to duplicate effort.
- Make your changes in a new git branch:

  ```bash
  git checkout -b my-fix-branch master
  ```

- Be familiar with and adhere to things stated in:
  - [CONTRIBUTING](https://github.com/ngOfficeUIFabric/ng-officeuifabric/blob/master/CONTRIBUTING.md)
  - [CONTRIB-WORKFLOW](CONTRIB-WORKFLOW.md)
  - [CODING](CODING.md)
  - [TESTING](TESTING.md)
- **Include appropriate test cases.**
- Ensure your fork is updated and not behind the upstream **ngofficeuifabric** repo. Refer to these resources for more information on syncing your repo:
    - [GitHub Help: Syncing a Fork](https://help.github.com/articles/syncing-a-fork/)
    - [AC: Keep Your Forked Git Repo Updated with Changes from the Original Upstream Repo](http://www.andrewconnell.com/blog/keep-your-forked-git-repo-updated-with-changes-from-the-original-upstream-repo)

- Push your branch to GitHub:

  ```bash
  git push origin my-fix-branch
  ```

## Before You Submit Your Pull Request

Please do the following checks on your code before you submit a pull request. They do all these same checks manually and if any fail, your PR will be rejected and you will be prompted to address the issues.

> NOTE: these are all done automatically using [TravisCI](https://travis-ci.org) as defined in the `.travis.yml` file in the root of the repo.

- Run the full ngOfficeUIFabric test suite, as described in the [TESTING](TESTING.md), and ensure that all tests pass.
- Run the code vetting script `$ gulp vet-lib-ts` to verify you are meeting all required code style requirements.
- Check the code coverage report generated when running tests to ensure you do not cause the coverage percentage to fall as described in [TESTING](TESTING.md#code-coverage)

Please correct any issues that come up before submitting your PR. Any issues that come up will be listed in the comments for the PR and it will be closed. You can always reopen the PR once you fix the issues, but making sure things are in order before submitting the PR streamlines the process and saves time for everyone involved.

## Submit Your Pull Request
- In GitHub, send a pull request to `ngofficeuifabric:dev`.
  - Do **NOT** push to `ngofficeuifabric:master`.
  - Monitor the automated checks that are performed on your PR when submitted by both Travis CI & Coveralls. If either fails you need to address the issues prior to your submission to be considered for merge. If you need help with this process, jump in the [ngofficeuifabric Slack team](https://ngofficeuifabric.slack.com) and ask for help.
- If we suggest changes then:
  - Make the required updates.
  - Re-run the test suite to ensure tests are still passing.
  - Rebase your branch and force push to your GitHub repository (this will update your Pull Request):

    ```bash
    git rebase master -i
    git push -f
    ```

### What Happens if The Build Fails on my Pull Request?

Well, it depends.

If the failure is due to [failing to transpile the TypeScript to JavaScript](https://github.com/ngOfficeUIFabric/ng-officeuifabric/blob/master/.travis.yml#L22-L23), [any failing unit tests](https://github.com/ngOfficeUIFabric/ng-officeuifabric/blob/master/.travis.yml#L26-L27), [code style issues when vetting](https://github.com/ngOfficeUIFabric/ng-officeuifabric/blob/master/.travis.yml#L28-29) or from a significant drop in code coverage, the issues will be mentioned in your PR & it will be closed. You are free to reopen the PR after addressing the issues, resubmitting the code.

However there are other reasons the build may fail that won't cause this...

#### GITHUB API: GitHub Rate Limit Exceeded

Because we are using TypeScript type definitions from https://definitelytyped.org, [the build is configured to download all type definitions](https://github.com/ngOfficeUIFabric/ng-officeuifabric/blob/master/.travis.yml#L20-L21) using the **tsd** utility which uses the Github API to download TypeScript type definitions. The challenge with this is that Github's API limits the number of anonymous API requests to 60/hour. If you exceed this number, TSD will throw an error and break the build with the message *GitHub rate limit exceeded* which [you can easily see in the build logs](https://travis-ci.org/ngOfficeUIFabric/ng-officeuifabric#L1542-L1547).

The fix is to [set an environment variable that contains a GitHub API token](https://github.com/DefinitelyTyped/tsd#tsdrc) that's tied to your account to bump this limit up to 5,000 API calls. However this [does not apply to pull requests](https://docs.travis-ci.com/user/pull-requests). TravisCI does not include secured environment variables in builds triggered by pull requests.

As such, if your build fails, when it is evaluated, library managers will look to see if this was the root cause. If it is the root cause for the failing build in TravisCI, the three tests above will be manually checked.

## After Your Pull Request is Merged

After your pull request is merged, you can safely delete your branch and pull the changes from the main (upstream) repository:

- Delete the remote branch on GitHub either through the GitHub web UI or your local shell as follows:

  ```bash
  git push origin --delete my-fix-branch
  ```

- Checkout & update the master branch:

  ```bash
  git checkout master -f
  git pull --ff upstream master
  ```

- Checkout & update the dev branch:

  ```bash
  git checkout dev -f
  git pull --ff upstream dev
  ```

- Delete the local branch:

  ```bash
  git branch -D my-fix-branch
  ```


text:
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**city** | **String** |  |
**state** | **String** | The [ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2) two letter code for the state.  |
**county** | **String** | County name of the address city. |
**countyFips** | **String** | A 5-digit [FIPS county code](https://en.wikipedia.org/wiki/FIPS_county_code) which uniquely identifies `components[county]`. It consists of a 2-digit state code and a 3-digit county code.  |
**preferred** | **Boolean** | Indicates whether or not the city is the [USPS default city](https://en.wikipedia.org/wiki/ZIP_Code#ZIP_Codes_and_previous_zoning_lines) (preferred city) of a ZIP code. There is only one preferred city per ZIP code, which will always be in position 0 in the array of cities.  |


text:
function result=gab_task_savemat(args)
%basic function to save variables in mat files through gab
if ~iscell(args.vars)
    args.vars={args.vars};
end

%any variables you want to save should already be on the global workspace,
%so get them locally with a eval statement
txt='global';
for i=1:length(args.vars)
    txt=[txt ' ' args.vars{i}];
end
eval(txt);

%make sure the directory you want to save to exists
if ~exist(args.path,'dir')
    mkdir(args.path);
end

save(fullfile(args.path,args.file),args.vars{:},'-v7.3'); %for some reason, some of the EEG structs can't be saved in the older format. no idea why, this is the easy fix KH 10/06/25

result='done';


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace gov.va.medora.mdws.dto.sm
{
    [Serializable]
    public class FolderTO : BaseSmTO
    {
        public string name;
        public bool isSystemFolder;

        public FolderTO() { }

        public FolderTO(mdo.domain.sm.Folder folder)
        {
            if (folder == null)
            {
                return;
            }
            this.id = folder.Id;
            this.oplock = folder.Oplock;
            this.name = folder.Name;
            isSystemFolder = folder.SystemFolder;
        }
    }
}


text:
using System;
using System.Collections.Generic;
using System.Text;
using VMLab.Helpers;

namespace VMLab.Startup
{
    public class DirectoryLocations : IStartup
    {
        private readonly IEnvironmentHelper _environmentHelper;
        private readonly IFileSystem _fileSystem;
        private readonly IConfig _config;

        public DirectoryLocations(IEnvironmentHelper environmentHelper, IFileSystem fileSystem, IConfig config)
        {
            _environmentHelper = environmentHelper;
            _fileSystem = fileSystem;
            _config = config;
        }

        public int Priority => -1;
        public void Execute()
        {
            var globaldir = _environmentHelper.Var("VMLAB_GLOBAL");
            var labRoot = _environmentHelper.Var("VMLAB_ROOT");
            var vmpayload = _environmentHelper.Var("VMLAB_PAYLOAD");
            var vmlabFolderName = _environmentHelper.Var("VMLAB_DIRNAME");
            var vmlabFileName = _environmentHelper.Var("VMLAB_SCRIPT");
            var vmlabfolder = default(string);

            if (string.IsNullOrEmpty(vmlabFileName))
                vmlabFileName = "vmlab.csx";

            if (string.IsNullOrEmpty(vmlabFolderName))
                vmlabFolderName = ".vmlab";

            if (string.IsNullOrEmpty(globaldir))
                globaldir = $"{_environmentHelper.Var("LOCALAPPDATA")}\\VMLAB";

            if (string.IsNullOrEmpty(labRoot))
                labRoot = _fileSystem.CurrentDirectory;

            vmlabfolder = $"{labRoot}\\{vmlabFolderName}";

            _config.Set(ConfigScope.Dynamic, "GLOBALDIR", globaldir);
            _config.Set(ConfigScope.Dynamic, "LABROOT", labRoot);
            _config.Set(ConfigScope.Dynamic, "VMFolderName", vmlabFolderName);
            _config.Set(ConfigScope.Dynamic, "VMLABDIR", vmlabfolder);
            _config.Set(ConfigScope.Dynamic, "VMLABFILENAME", vmlabFileName);
            _config.Set(ConfigScope.Dynamic, "DefaultConfigRun", "true");

            if (string.IsNullOrEmpty(vmpayload))
            {
                vmpayload = $"{vmlabfolder}\\vm";
            }
            else
            {
                var payloadName = _config.Get(ConfigScope.Lab, "payloadName") ?? Guid.NewGuid().ToString();
                _config.Set(ConfigScope.Lab, "payloadName", payloadName);

                vmpayload = $"{vmpayload}\\{payloadName}";

                if(!_fileSystem.DirectoryExists(vmpayload))
                    _fileSystem.CreateDirectory(vmpayload);

            }

            _config.Set(ConfigScope.Dynamic, "PAYLOADDIR", vmpayload);

        }
    }
}


text:
package com.navercorp.pinpoint.metric.web.util;

/**
 * @author emeroad
 */
public interface TimeWindowSampler {
    long getWindowSize(Range range);
}


text:
@interface Constants : NSObject

#define WAAD_LOGIN_URL @"https://login.windows.net/"
#define WAAD_DOMAIN @"christesttwo.onmicrosoft.com"
#define WAAD_CLIENT_ID @"fa94de18-3636-447e-8986-99db18aeac85"
#define WAAD_REDIRECT_URI @"com.cmr.waadtest://authorize"
#define WAAD_RESOURCE @"http://win8webapp.azurewebsites.net/"
#define WAAD_SERVICE_ENDPOINT @"api/todolist"

typedef void (^CompletionBlock) ();
typedef void (^CompletionBlockWithString) (NSString *string);

@end


text:
namespace DataCat.Core.Exception
{
    using Microsoft.AspNetCore.Mvc.ModelBinding;
    using Newtonsoft.Json;
    using System.Collections.Generic;
    using System.Linq;

    public class ApiError
    {
        public string Message { get; set; }

        [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
        public string StackTrace { get; set; }

        [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
        public IEnumerable<string> Errors { get; private set; }

        public ApiError(string message, IEnumerable<ModelError> modelErrors=null)
        {
            this.Message = message;
            if (modelErrors!=null)
            {
                this.Errors = modelErrors.Select(x => x.ErrorMessage);
            }
        }

        public ApiError(IEnumerable<string> Errors)
        {
            this.Message = "Api errors detected";
            this.Errors = Errors;
        }
    }
}


text:
jQuery UI "metaframe" widget
============================

A metaframe is an information frame with extra options that appears
around an element (like an image) when hovering it.

It is very useful to add extra options to e.g. a list of thumbnails
without having to clutter the user interface with all those options;
they only are visible when the mouse hovers them.

Example HTML code:

                download
                share

The three `metaframe-` class names are important. The`"trigger`
element gets the onmouseover hover effect. The `popup` div is positioned
absolutely around the trigger. The placeholder element in the popup
will receive the contents of the trigger, so that the frame seems to
appear "around" the trigger.

The following code would add metaframe to each `li` element:

    $("
").metaframe();

See `metaframe.html` in the examples directory for a full example.


text:
ACCEPTED

#### According to
International Plant Names Index

#### Published in
Sketch veg. Swan R. xxxiv. 1839

#### Original name
null

### Remarks
null


text:
'use strict';

const webpack = require('webpack');
const packageJSON = require('../../package.json');
const legoConfig = packageJSON.legoconfig;
const resourceResolver = require('./resourceresolver.js');

const env = process.env;

function getEntries() {
    const entry = {};
    entry[legoConfig.vuechunkname] = ['billund-supportor/lib/vendors/vue.js'];
    entry[legoConfig.reactchunkname] = ['billund-supportor/lib/vendors/react.js'];
    return entry;
}

const plugins = [];
if (env === 'product') {
    plugins.push(new webpack.DefinePlugin({
        'process.env': {
            NODE_ENV: JSON.stringify('production')
        }
    }));
    plugins.push(new webpack.optimize.UglifyJsPlugin({
        compress: {
            warnings: false
        }
    }));
}

module.exports = {
    entry: getEntries(),
    output: {
        filename: '[name].js',
        path: resourceResolver.DIST_PATH,
        publicPath: resourceResolver.PUBLIC_PATH,
        chunkFilename: '[name].[chunkhash].js'
    },
    cache: true,
    resolve: {
        extensions: ['.js', '.jsx', '.vue', '.less']
    },
    target: 'web',
    module: {
        rules: [{
            test: /\.(js)$/,
            exclude: /node_modules\//,
            use: [{
                loader: 'babel-loader',
                options: {
                    presets: ['es2015', 'stage-0'],
                    cacheDirectory: true
                }
            }]
        }]
    },
    plugins
};


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FlatRedBall.Glue.Managers
{
    public class CommandLineManager : Singleton<CommandLineManager>
    {
        string mProjectToLoad = null;

        public string ProjectToLoad
        {
            get
            {
                return mProjectToLoad;
            }
        }

        public CommandLineManager()
        {
            string[] commandLineArgs = Environment.GetCommandLineArgs();

            foreach(string var in commandLineArgs)
            {
                if (var.Contains(".glux"))
                {
                    mProjectToLoad = var;
                    mProjectToLoad = mProjectToLoad.Replace(".glux", ".csproj");
                }
                if (var.Contains(".gluj"))
                {
                    mProjectToLoad = var;
                    mProjectToLoad = mProjectToLoad.Replace(".gluj", ".csproj");
                }
                if (var.Contains(".csproj"))
                {
                    mProjectToLoad = var;
                }
            }

        }
    }
}


text:
<?php
/* @var $this SiteController */

$this->pageTitle=Yii::app()->name;
if(Yii::app()->user->checkAccess('0')){
    echo "hello, I'm administrator";
}
?>


text:
<?php

use ElkArte\Controller\Emailpost;
use ElkArte\EventManager;
use ElkArte\Themes\ThemeLoader;

/**
 * TestCase class for the EmailPost Controller
 *
 * WARNING. These tests work directly with the local database. Don't run
 * them local if you need to keep your data untouched!
 */
class TestEmailPostController extends ElkArteCommonSetupTest
{
	protected $backupGlobalsBlacklist = ['user_info'];
	protected $data = '';

	/**
	 * Initialize or add whatever necessary for these tests
	 */
	protected function setUp(): void
	{
		global $modSettings;

		// Load in the common items so the system thinks we have an active login
		parent::setUp();

		new ElkArte\Themes\ThemeLoader();
		ThemeLoader::loadLanguageFile('EmailTemplates', 'english', false, true);
		ThemeLoader::loadLanguageFile('Maillist', 'english', false, true);

		$modSettings['maillist_enabled'] = true;
		$modSettings['pbe_post_enabled'] = true;
		$_POST['item'] = '';

		$this->data = 'Return-Path: <noreply@elkarte.net>
Delivered-To: <email@testadmin.tld>
Received: from galileo.tardis.com
	by galileo.tardis.com (Dovecot) with LMTP id znQ3AvalOVi/SgAAhPm7pg
	for <email@testadmin.tld>; Sat, 26 Nov 2016 09:10:46 -0600
Received: by galileo.tardis.com (Postfix, from userid 1005)
	id 0671C1C8; Sat, 26 Nov 2016 09:10:46 -0600 (CST)
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
	galileo.tardis.com
X-Spam-Flag: No
X-Spam-Level: ******
X-Spam-Status: No, score=4.0 required=5.0 tests=HTML_IMAGE_ONLY_16,
	HTML_MESSAGE,HTML_SHORT_LINK_IMG_2,MIME_HTML_ONLY,MIME_HTML_ONLY_MULTI,
	MPART_ALT_DIFF,RCVD_IN_BRBL_LASTEXT,T_DKIM_INVALID,URIBL_BLACK autolearn=no
	autolearn_force=no version=3.4.0
Received: from mail.elkarte.net (s2.eurich.de [85.214.104.5])
	by galileo.tardis.com (Postfix) with ESMTP id 1872579
	for <email@testadmin.tld>; Sat, 26 Nov 2016 09:10:40 -0600 (CST)
Received: from localhost (localhost [127.0.0.1])
	by mail.elkarte.net (Postfix) with ESMTP id 9DE3C4CE1535
	for <email@testadmin.tld>; Sat, 26 Nov 2016 16:10:39 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at s2.eurich.de
Received: from mail.elkarte.net ([127.0.0.1])
	by localhost (h2294877.stratoserver.net [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id zQep5x32jrqA for <email@testadmin.tld>;
	Sat, 26 Nov 2016 16:10:03 +0100 (CET)
Received: from mail.elkarte.net (h2294877.stratoserver.net [85.214.104.5])
	by mail.elkarte.net (Postfix) with ESMTPA id 990694CE0CFA
	for <email@testadmin.tld>; Sat, 26 Nov 2016 16:10:03 +0100 (CET)
Subject: [ElkArte Community] Test Message
To: <email@testadmin.tld>
From: "Administrator" <email@testadmin.tld>
Reply-To: "ElkArte Community" <elkarteforum@gmail.com>
References: <4124@elkarte.net>
Date: Sat, 26 Nov 2016 15:09:15 -0000
X-Mailer: ELK
X-Auto-Response-Suppress: All
Auto-Submitted: auto-generated
List-Id: <elkarteforum@gmail.com>
List-Unsubscribe: <http://www.elkarte.net/community/index.php?action=profile;area=notification>
List-Owner: <mailto:help@elkarte.net> (ElkArte Community)
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="ELK-66593aefa4beed000470cbd4cc3238d9"
Content-Transfer-Encoding: 7bit
Message-ID: <cd8c399768891330804a1d2fc613ccf3-t1@elkarte.net>

Testing

Regards, The ElkArte Community

[cd8c399768891330804a1d2fc613ccf3-t1]

--ELK-66593aefa4beed000470cbd4cc3238d9
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

Testing

Regards, The ElkArte Community

[cd8c399768891330804a1d2fc613ccf3-t1]

--ELK-66593aefa4beed000470cbd4cc3238d9--

--ELK-66593aefa4beed000470cbd4cc3238d9
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit

Testing

Regards, The ElkArte Community

[cd8c399768891330804a1d2fc613ccf3-t1]

--ELK-66593aefa4beed000470cbd4cc3238d9--;';
	}

	/**
	 * Test trying looking at a pbe message
	 */
	public function testActionPbePreview()
	{
		// Get the controller, call preview
		$controller = new Emailpost(new EventManager());
		$result = $controller->action_pbe_preview($this->data);

		// Check that the preview was set
		$this->assertEquals('email@testadmin.tld', $result['to'], $result['to']);
		$this->assertStringContainsString('[b]Testing[/b]', $result['body'], $result['body']);
	}

	/**
	 * Test trying to post at a pbe message
	 */
	public function testActionPbePost()
	{
		// Get the controller, call preview
		$controller = new Emailpost(new EventManager());
		$controller->action_pbe_post($this->data, false);

		// We will fail since the key does not exist
		$this->assertEquals('It appears that you already replied to this email.  If you need to modify your post please use the web interface, if you are making another reply to this topic please reply to the latest notification', $_SESSION['email_error'], $_SESSION['email_error']);
	}

	/**
	 * Test trying to start a pbe topic, its not setup so this will fail as well ;)
	 */
	public function testActionPbeTopic()
	{
		// Get the controller, call preview
		$controller = new Emailpost(new EventManager());
		$controller->action_pbe_topic($this->data);

		// We will fail since the key does not exist
		$this->assertEquals('Attempted to start a new topic to a non existing board, potential hacking attempt', $_SESSION['email_error'], $_SESSION['email_error']);
	}
}


text:
/**
 * css-less
 * ==========
 *
 * Собирает *css*-файлы вместе со *less*-файлами по deps'ам, обрабатывает инклуды и ссылки, сохраняет в виде `?.css`.
 *
 * **Опции**
 *
 * * *String* **target** — Результирующий таргет. По умолчанию `?.css`.
 * * *Object* **variables** — Дополнительные переменные окружения для `less`.
 * * *String* **filesTarget** — files-таргет, на основе которого получается список исходных файлов
 *   (его предоставляет технология `files`). По умолчанию — `?.files`.
 * * *Boolean* **relativeUrl** — создавать относительные пути (по умлочанию `true` - содавать)
 *
 * **Пример**
 *
 * ```javascript
 * nodeConfig.addTech(require('enb-less/techs/css-less'));
 * ```
 */
var vow = require('vow');
var less = require('less');
var urlRegexp = /url\(['"]{0,1}([^'"\)]*)['"]{0,1}\)/gm;

module.exports = require('enb/techs/css').buildFlow()
    .name('css-less')
    .target('target', '?.css')
    .defineOption('compress', false)
    .defineOption('relativeUrl', true)
    .defineOption('prefix', '')
    .defineOption('variables')
    .useFileList(['css', 'less'])
    .builder(function (sourceFiles) {
        var _this = this;
        var defer = vow.defer();
        var options = {};
        var variables = this._variables;
        var relativeUrl = this._relativeUrl;

        var css = sourceFiles.map(function (file) {
            var path = _this.node.relativePath(file.fullname);
            if (file.name.indexOf('.less') !== -1) {

                var body = require('fs').readFileSync(_this.node.resolvePath(path)).toString();

                if (relativeUrl) {
                    var urls = body.match(urlRegexp);
                    if (urls !== undefined) {
                        body = body.replace(/url\((?!data:image)['"]{0,1}([^'"\)]*)['"]{0,1}\)/gm,
                            [ 'url("',
                              require('path').dirname(path),
                              '/$1")'
                            ].join(''));
                    }
                }

                // get body of less files, but relative @import is not normal work
                return [
                    '/* ' + path + ':begin */\n',
                    body,
                    '/* ' + path + ':end */\n'
                ].join('');

            } else {
                return '@import "' + path + '";';
            }
        }).join('\n');

        if (variables) {
            Object.keys(variables).forEach(function (key) {
                options[key] = variables[key];
            }.bind(this));
        }

        less.render(css, options, function (err, css) {
            if (err) {
                // т.к. enb при сборке не показывает ошибок из reject
                // придется отсавить тут console.log до update enb с фиксом этого бага
                console.log(err);
                defer.reject(err);
            } else {
                defer.resolve(css);
            }
        });

        return defer.promise()
            .then(function (css) {
                return _this._processIncludes(css, _this.node.resolvePath(_this.targetName));
            });
    })
    .methods({
        _configureRenderer: function (renderer) {
            return renderer;
        }
    })
    .createTech();


text:
<!DOCTYPE html>

  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="author" content="Reid Netterville III">
  <title>Toquepala</title>
  <link rel="icon" href="../favicon.ico" type="image/ico">
  <link rel="stylesheet" href="styles/geranium.css" type="text/css">

Toquepala

  <button type="button" class="bttn" onclick="echiNacea('n0')">n0</button>
  <button type="button" class="bttn" onclick="echiNacea('k6')">k6</button>
  <button type="button" class="bttn" onclick="echiNacea('j17')">j17</button>
  <button type="button" class="bttn" onclick="echiNacea('k6x5')">k6x5</button>
  <button type="button" class="bttn" onclick="echiNacea('j17y2')">j17y2</button>
  <button type="button" class="bttn" onclick="echiNacea('j3')">j3</button>
  <button type="button" class="bttn" onclick="echiNacea('j34k6')">j34k6</button>
  <button type="button" class="bttn" onclick="echiNacea('j17k2')">j17k2</button>
  <button type="button" class="bttn" onclick="echiNacea('n26y5')">n26y5</button>
  <button type="button" class="bttn" onclick="echiNacea('k26x5')">k26x5</button>
  <button type="button" class="bttn" onclick="echiNacea('j6')">j6</button>
  <button type="button" class="bttn" onclick="echiNacea('j36')">j36</button>
  <button type="button" class="bttn" onclick="echiNacea('k56')">k56</button>
  <button type="button" class="bttn" onclick="echiNacea('j136y7')">j136y7</button>
  <button type="button" class="bttn" onclick="echiNacea('k56x4')">k56x4</button>
  <button type="button" class="bttn" onclick="echiNacea('n167x4')">n167x4</button>
  <button type="button" class="bttn" onclick="echiNacea('j3k5x4')">j3k5x4</button>
  <button type="button" class="bttn" onclick="echiNacea('j167y2')">j167y2</button>
  <button type="button" class="bttn" onclick="echiNacea('j2k56x4')">j2k56x4</button>
  <button type="button" class="bttn" onclick="echiNacea('k157x6')">k157x6</button>
  <button type="button" class="bttn" onclick="echiNacea('k1j6')">k1j6</button>
  <button type="button" class="bttn" onclick="echiNacea('n345')">n345</button>
  <button type="button" class="bttn" onclick="echiNacea('j2')">j2</button>
  <button type="button" class="bttn" onclick="echiNacea('j26')">j26</button>
  <button type="button" class="bttn" onclick="echiNacea('j236')">j236</button>
  <button type="button" class="bttn" onclick="echiNacea('j23')">j23</button>
  <button type="button" class="bttn" onclick="echiNacea('j23k6')">j23k6</button>
  <button type="button" class="bttn" onclick="echiNacea('j2y3')">j2y3</button>
  <button type="button" class="bttn" onclick="echiNacea('j2k6')">j2k6</button>
  <button type="button" class="bttn" onclick="echiNacea('j2k56')">j2k56</button>
  <button type="button" class="bttn" onclick="echiNacea('j26y3')">j26y3</button>
  <button type="button" class="bttn" onclick="echiNacea('j246y3')">j246y3</button>
  <button type="button" class="bttn" onclick="echiNacea('j2k6x5')">j2k6x5</button>
  <button type="button" class="bttn" onclick="echiNacea('j26y34')">j26y34</button>
  <button type="button" class="bttn" onclick="echiNacea('j2k6y3')">j2k6y3</button>
  <button type="button" class="bttn" onclick="echiNacea('j3k6')">j3k6</button>
  <button type="button" class="bttn" onclick="echiNacea('n45y2')">n45y2</button>
  <button type="button" class="bttn" onclick="echiNacea('j3k56x4')">j3k56x4</button>
  <button type="button" class="bttn" onclick="echiNacea('k2j6')">k2j6</button>
  <button type="button" class="bttn" onclick="echiNacea('n5y2')">n5y2</button>
  <button type="button" class="bttn" onclick="echiNacea('k26')">k26</button>
  <button type="button" class="bttn" onclick="echiNacea('k256')">k256</button>

  <svg id="area84" width="420" height="240"></svg>

  <button type="button" class="bttn" onclick="echiNacea('n0')">n0</button>
  <button type="button" class="bttn" onclick="echiNacea('j5')">j5</button>
  <button type="button" class="bttn" onclick="echiNacea('k34')">k34</button>
  <button type="button" class="bttn" onclick="echiNacea('j5y6')">j5y6</button>
  <button type="button" class="bttn" onclick="echiNacea('k34x2')">k34x2</button>
  <button type="button" class="bttn" onclick="echiNacea('k1')">k1</button>
  <button type="button" class="bttn" onclick="echiNacea('k17j5')">k17j5</button>
  <button type="button" class="bttn" onclick="echiNacea('j2k34')">j2k34</button>
  <button type="button" class="bttn" onclick="echiNacea('n25x6')">n25x6</button>
  <button type="button" class="bttn" onclick="echiNacea('j25y6')">j25y6</button>
  <button type="button" class="bttn" onclick="echiNacea('k5')">k5</button>
  <button type="button" class="bttn" onclick="echiNacea('k15')">k15</button>
  <button type="button" class="bttn" onclick="echiNacea('j56')">j56</button>
  <button type="button" class="bttn" onclick="echiNacea('k135x4')">k135x4</button>
  <button type="button" class="bttn" onclick="echiNacea('j56y7')">j56y7</button>
  <button type="button" class="bttn" onclick="echiNacea('n345y7')">n345y7</button>
  <button type="button" class="bttn" onclick="echiNacea('k1j6y7')">k1j6y7</button>
  <button type="button" class="bttn" onclick="echiNacea('k345x2')">k345x2</button>
  <button type="button" class="bttn" onclick="echiNacea('k2j56y7')">k2j56y7</button>
  <button type="button" class="bttn" onclick="echiNacea('j346y5')">j346y5</button>
  <button type="button" class="bttn" onclick="echiNacea('j3k5')">j3k5</button>
  <button type="button" class="bttn" onclick="echiNacea('n167')">n167</button>
  <button type="button" class="bttn" onclick="echiNacea('k2')">k2</button>
  <button type="button" class="bttn" onclick="echiNacea('k25')">k25</button>
  <button type="button" class="bttn" onclick="echiNacea('k125')">k125</button>
  <button type="button" class="bttn" onclick="echiNacea('k12')">k12</button>
  <button type="button" class="bttn" onclick="echiNacea('k12j5')">k12j5</button>
  <button type="button" class="bttn" onclick="echiNacea('k2x1')">k2x1</button>
  <button type="button" class="bttn" onclick="echiNacea('k2j5')">k2j5</button>
  <button type="button" class="bttn" onclick="echiNacea('k2j56')">k2j56</button>
  <button type="button" class="bttn" onclick="echiNacea('k25x1')">k25x1</button>
  <button type="button" class="bttn" onclick="echiNacea('k257x1')">k257x1</button>
  <button type="button" class="bttn" onclick="echiNacea('k2j5y6')">k2j5y6</button>
  <button type="button" class="bttn" onclick="echiNacea('k25x17')">k25x17</button>
  <button type="button" class="bttn" onclick="echiNacea('k2j5x1')">k2j5x1</button>
  <button type="button" class="bttn" onclick="echiNacea('k1j5')">k1j5</button>
  <button type="button" class="bttn" onclick="echiNacea('n67x2')">n67x2</button>
  <button type="button" class="bttn" onclick="echiNacea('k1j56y7')">k1j56y7</button>
  <button type="button" class="bttn" onclick="echiNacea('j2k5')">j2k5</button>
  <button type="button" class="bttn" onclick="echiNacea('n6x2')">n6x2</button>
  <button type="button" class="bttn" onclick="echiNacea('j25')">j25</button>
  <button type="button" class="bttn" onclick="echiNacea('j256')">j256</button>

Copyright © 2015-2016 Reid Netterville III


text:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Estudio extends CI_Model {

	private $id;
	private $institucion;
	private $pais;
	private $fecha_graduacion;

	public function __construct($value = null) {
		parent::__construct();
		$this->load->database();
		if ($value != null) {
			if (is_array($value))
				settype($value, 'object');

			if (is_object($value)) {
				$this->id = isset($value->id) ? $value->id : null;
				$this->institucion = isset($value->institucion) ? $value->institucion : null;
				$this->pais = isset($value->pais) ? $value->pais : null;
				$this->fecha_graduacion = isset($value->fecha_graduacion) ? $value->fecha_graduacion : null;
			}
		}
	}

	public function __get($key) {
		switch ($key) {
			case 'id':
			case 'institucion':
			case 'pais':
			case 'fecha_graduacion':
			return $this->$key;
			default:
			return parent::__get($key);
		}
	}

	public function validar($persona) {
		$errores = [];
		if ($this->institucion == null){
			$errores[] = 'La institución no puede ser vacía';
		}

		if ($this->pais == null) {
			$errores[] = 'El país no puede ser vacío';
		}

		if ($this->fecha_graduacion == null) {
			$errores['fecha_graduacion'] = ['required'];
		}
		// Acá habría que validar también que sea una fecha correcta
		// y que esté entre $persona->fecha_nacimiento y la fecha actual.

		return empty($errores) ? TRUE : $errores;
	}

	public function registrar($persona) {

		$data = [
			'persona' => $persona->numero_documento,
			'institucion' => $this->institucion,
			'pais' => $this->pais,
			'fecha_graduacion' => $this->fecha_graduacion
		];

		if ($this->db->insert('estudio', $data) !== FALSE) {
			$this->id = $this->db->insert_id();
			return TRUE;
		} else {
			return FALSE;
		}

	}

	public function obtener_estudios_por_persona($persona) {
		$this->load->model('Pregrado');
		$this->load->model('Posgrado');

		$estudios = [];

		$this->db->from('estudio')
			->join('pregrado', 'estudio.id = pregrado.estudio')
			->where('persona', $persona->numero_documento);

		$pregrados = $this->db->get()->result();

		foreach ($pregrados as $pregrado) {
			$estudios = new Pregrado($pregrado);
		}

		$this->db->from('estudio')
			->join('posgrado', 'estudio.id = posgrado.estudio')
			->where('persona', $persona->numero_documento);

		$posgrados = $this->db->get()->result();

		foreach ($posgrados as $posgrado) {
			$estudios = new Posgrado($posgrado);
		}

		return $estudios;
	}

}


text:
<!doctype html>

    <title>common/containers/Election.js</title>
    <link rel="stylesheet" href="./../../../public/style.css" />
    <link rel="icon" type="image/png" href="./../../../public/favicon.png" />
    <meta name="viewport" content="width=device-width, initial-scale=1">

              elections-2016

                common/containers/Election.js

js

client/index.js

js

common/routes.js

js

common/actions/actionCreators.js

js

common/components/Root.js

js

common/containers/connectToApi.js

js

common/store/configureStore.js

js

common/utils/urlManager.js

This container renders the 'Election Central' page.

import _ from 'lodash'
import { geoAlbersUsa } from 'd3-geo'
import React, { Component } from 'react'
import connectToApi from './connectToApi.js'
import Timer from './../components/Timer.js'
import BreakingBar from './../components/BreakingBar.js'
import Header from './../components/Header.js'
import Footer from './../components/Footer.js'
import Promo from './../components/Promo.js'
import TestStatus from './../components/TestStatus.js'
import BalanceOfPowerArc from './../components/BalanceOfPowerArc.js'
import Hero from './../components/Hero.js'
import ElectoralCollegeBar from './../components/ElectoralCollegeBar.js'
import Map from './../components/Map.js'
import SwingStates from './../components/SwingStates.js'
import {
	sortByProductRequirements,
} from './../utils/Candidates.js'
import FeatureGroup from './../components/FeatureGroup.js'
import urlManager from './../utils/urlManager.js'
import getReports from './../utils/getReports.js'
import getStatesShapefile from './../utils/getStatesShapefile.js'
import nameUtil from './../utils/nameUtil.js'
import swingStatesSelection from './../../data/swing-states.json'
import Legend from './../components/Legend.js'
import LinkButton from './../components/LinkButton.js'

const STATES = getStatesShapefile()

We'll keep these urls here for testing. A description:

this one returns a 500,
const url = 'NO'

this one returns json but the data is incomplete,
const url = '2016-11-08/rezcentral'

and this one is the correct url - it returns everything.

// eslint-disable-next-line max-len
const url = '2016-11-08/prezcentral?reports=Trend-s,Trend-h&races=MA-24805,NH-31459,MA-24803,MA-22949'

Note the @connectToApi decorator. This higher-order component (HOC)
is pretty essential. Make sure to familiarize yourself with its inner
workings.

@connectToApi
class Election extends Component {

These four static functions return strings that the connectToApi
HOC will pick up.

	static getOmnitureTitle() {
		return nameUtil.election.omnitureTitle()
	}

	static getSection() {
		return ''
	}

	static getTitle() {
		return nameUtil.election.htmlTitle()
	}

	static apiUrl() {
		return url
	}

	render() {

		const { props } = this

timerProps has data to power the updater clock. results is the
API election results for this container. The HOC fetches data from
this container's apiUrl function.

		const { timerProps, results } = props

Get the reports.

		const reports = _.get(results, 'data.reports', [])

Get breaking news.

		const breakingNews = _.first(results.breakingNews) || {}

Get senate / house reports.

		const senateReport = _.find(getReports(reports), { officeType: 'S' })
		const houseReport = _.find(getReports(reports), { officeType: 'H' })

Get all races.

		const races = _.get(results, 'data.races', [])

Get all presidential units:

		const presUnits = _(races)

get all races where officeName='President',

			.filter({ officeName: 'President' })

get the reporting units,

			.map('reportingUnits')

and flatten.

			.flatten()
			.value()

Get presidential summary.

		const presSummaryUnit = _.find(presUnits, { statePostal: 'US' })

Get all 51 state units.

		const presStates = _.reject(presUnits, { statePostal: 'US' })

Specify list of swing states.

		const swingStates = _(presStates)
			.filter(v => _.includes(swingStatesSelection, v.statePostal))
			.sortBy(v => _.indexOf(swingStatesSelection, v.statePostal))
			.value()

Create the map (if we have data).

		const map = presStates.length ? (<Map
			shapefile={STATES}
			data={presStates}
			unitName='stateName'
			projection={geoAlbersUsa()}
			tooltipSortingDelegate={sortByProductRequirements}
			dropdownName='state'
			displayName='stateName'
			buttonText={nameUtil.presidentMA.name()}
			buttonUrl={urlManager().race({
				officeName: 'President', statePostal: 'MA', source: 'MA' })}
			labelsName='STUSPS' />) : null

Get test status.

		const isTest = _.some(races, 'test')

Get featured races.

		const featured = _(races)
			.reject({ officeName: 'President' })
			.map((race, key) => <FeatureGroup {...{ race, key }} />)
			.value()

		return (
			<div className='election-is-open'>
				<TestStatus isTest={isTest} />
				<BreakingBar alert={breakingNews} />
				<Header />
				<main id='content'>
					<Hero
						title='Election Home'
						className='lead-img'
						isElectionCtrl />
					<Timer {...timerProps} />
					<div className='container-inset'>
						<div className='container-sm'>
							<ElectoralCollegeBar {...presSummaryUnit} />
						</div>
					</div>
					<div className='container-lg'>
						{map}
						<SwingStates states={swingStates} />
						<Legend isPresidential races={presStates} />
					</div>
					<div className='container-downpage'>
						<div className='container-lg'>
							<h3 className='subhed benton-bold'>
								<span>Featured races</span>
							</h3>
							<div className='r-row--full'>
								<div className='r-col r-feature'>
									<BalanceOfPowerArc
										{...{
											...senateReport,
											total: 100,
											name: 'US Senate balance of power',
										}} />
									<LinkButton
										text='See full results'
										url={urlManager().office({
											officeName: 'US Senate',
											source: 'balanceofpower' })} />
								</div>
								<div className='r-col r-feature'>
									<BalanceOfPowerArc
										{...{
											...houseReport,
											total: 435,
											name: 'US House balance of power',
										}} />
									<LinkButton
										text='See full results'
										url={urlManager().office({
											officeName: 'US House',
											source: 'balanceofpower' })} />
								</div>
								{featured}
							</div>
						</div>
					</div>
					<Promo />
				</main>
				<Footer />
			</div>
		)

	}

}

export default Election

          © Copyright 2017 The Boston Globe.

          Generated Wed, 22 Feb 2017 19:58:26 GMT


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
null

#### Original name
Sphaerella bambusae var. bambusae

### Remarks
null


text:
:title: Ferry Introduction
:description: Introduction
:keywords: ferry, introduction

.. _intro:

Big Data Development Environment using Docker
=============================================

Ferry helps you create big data clusters on your local machine. Define your big data stack using YAML and
share your application with :ref:`Dockerfiles <advanced>`. Ferry supports Hadoop, Cassandra, Spark, GlusterFS, and Open MPI.

Here's an example Hadoop cluster:

.. code-block:: yaml

   backend:
      - storage:
           personality: "hadoop"
           instances: 2
           layers:
              - "hive"
   connectors:
      - personality: "hadoop-client"

Then get started by typing ``ferry start hadoop``. This will automatically create a two node
Hadoop cluster and a single Linux client. You can customize the Linux client during runtime or define your own using a Dockerfile. In addition to Hadoop, Ferry also supports Spark, Cassandra, GlusterFS, and Open MPI.

Ferry is useful for:

- Data scientists that want to experiment and learn about big data technologies
- Developers that need a locally accessible big data development environment
- Users that want to share big data application quickly and safely

Ferry provides several useful commands for your applications:

- Start and stop services
- View status and create snapshots
- SSH into clients
- Copy over log files to a host directory

For example, let's inspect all the running services

.. code-block:: bash

   $ ferry ps
   UUID Storage  Compute  Connectors  Status   Base  Time
   ---- ------- --------- ---------- ------- ------- ----
   sa-2    se-6 [u'se-7']       se-8 removed hadoop    --
   sa-1    se-3 [u'se-4']       se-5 stopped openmpi   --
   sa-0    se-0 [u'se-1']       se-2 running cassandra --

Ferry is under active development, so follow us on `Twitter <https://twitter.com/open_core_io/>`_ to keep up to date.

If you're interested in collaborating or have any questions, feel free to send an email to info@opencore.io.