@@ -0,0 +1,2730 @@
+package nl.hsac.fitnesse.fixture.util;%0A%0Aimport org.openqa.selenium.By;%0Aimport org.openqa.selenium.JavascriptExecutor;%0Aimport org.openqa.selenium.SearchContext;%0Aimport org.openqa.selenium.WebDriver;%0Aimport org.openqa.selenium.WebElement;%0Aimport org.openqa.selenium.internal.WrapsDriver;%0A%0Aimport java.util.Arrays;%0Aimport java.util.Collections;%0Aimport java.util.List;%0A%0A/**%0A * Selenium By that finds elements by executing Javascript functions.%0A */%0Apublic class JavascriptBy extends By %7B%0A    private final String rootElement;%0A    private final String script;%0A    private final Object%5B%5D scriptParameters;%0A%0A    /**%0A     * Creates new, where 'root element' will be %3Ccode%3Enull%3C/code%3E.%0A     * @param aScript script to find with.%0A     * @param parameters additional (after 'root element') arguments to the script.%0A     */%0A    public JavascriptBy(String aScript, Object... parameters) %7B%0A        this(null, aScript, parameters);%0A    %7D%0A%0A    /**%0A     * Creates new.%0A     * @param aRootElement first argument to the script.%0A     * @param aScript script to find with.%0A     * @param parameters additional (after 'root element') arguments to the script.%0A     */%0A    public JavascriptBy(String aRootElement, String aScript, Object... parameters) %7B%0A        rootElement = aRootElement;%0A        script = aScript;%0A        List%3CObject%3E params = Arrays.asList(parameters);%0A        params.add(0, rootElement);%0A        scriptParameters = params.toArray();%0A    %7D%0A%0A    @Override%0A    public List%3CWebElement%3E findElements(SearchContext searchContext) %7B%0A        List%3CWebElement%3E result;%0A        JavascriptExecutor executor = null;%0A        if (searchContext instanceof JavascriptExecutor) %7B%0A            executor = (JavascriptExecutor) searchContext;%0A        %7D else %7B%0A            if (searchContext instanceof WrapsDriver) %7B%0A                WrapsDriver wraps = (WrapsDriver) searchContext;%0A                WebDriver wrapped = wraps.getWrappedDriver();%0A                if (wrapped instanceof JavascriptExecutor) %7B%0A                    executor = (JavascriptExecutor) wrapped;%0A                %7D%0A            %7D%0A        %7D%0A        if (executor == null) %7B%0A            throw new RuntimeException(%22Unable to get: %22 + JavascriptExecutor.class.getName()%0A                    + %22 from: %22 + searchContext.getClass().getName());%0A        %7D%0A        Object results = executor.executeScript(script, scriptParameters);%0A        if (results instanceof List) %7B%0A            result = (List%3CWebElement%3E) results;%0A        %7D else %7B%0A            if (results == null) %7B%0A                result = Collections.emptyList();%0A            %7D else %7B%0A                throw new RuntimeException(%22Script returned something else than a list: %22 + results);%0A            %7D%0A        %7D%0A        return result;%0A    %7D%0A%7D%0A

Add Javascript based By