<commit_before>package com.thoughtworks.calabash.android;

import org.jruby.RubyArray;
import org.jruby.RubyHash;

import java.util.ArrayList;

import static com.thoughtworks.calabash.android.CalabashLogger.warn;

public class WebElements extends ArrayList<UIElement> {
    public WebElements(RubyArray elementsArray, String query, CalabashWrapper calabashWrapper) {
        query = query.trim();
        for (Object element : elementsArray) {
            RubyHash object = (RubyHash) element;
            this.add(new UIElement(object, query, calabashWrapper));
        }
    }

    /**
     * touch the webview element, if there are multiple elements, only the first one will be touched
     *
     * @throws CalabashException
     */
    public void touch() throws CalabashException {
        getFirstElement().touch();
    }

    private UIElement getFirstElement() throws CalabashException {
        ensureCollectionIsNotEmpty();
        if (this.size() > 1) {
            warn("There are multiple webview elements, so considering only the first element");
        }
        return this.get(0);
    }

    /**
     * set text to the webview element, if there are multiple elements, only the first one will be considered
     *
     * @param text
     * @throws CalabashException
     */
    public void setText(String text) throws CalabashException {
        getFirstElement().setText(text);
    }

    /**
     * fetch the text content of the weblement
     *
     * @return inner text of the element
     */
    public String getText() throws CalabashException {
        return getFirstElement().getTextContent();
    }

    /**
     * fetch the getValue of the webelement
     *
     * @return getValue of the element
     * @throws CalabashException
     */
    public String getValue() throws CalabashException {
        return getFirstElement().getValue();
    }

    /**
     * @return bounds of the webelement
     */
    public Rect getRect() throws CalabashException {
        return getFirstElement().getRect();
    }

    /**
     * @return the css class of the webelement
     */
    public String getElementClass() throws CalabashException {
        return getFirstElement().getElementClass();
    }

    /**
     * @return the css id of the webelement
     * @throws CalabashException
     */
    public String getId() throws CalabashException {
        return getFirstElement().getId();
    }

    private void ensureCollectionIsNotEmpty() throws CalabashException {
        if (this.size() == 0) {
            throw new CalabashException("Cannot perform action on an empty list");
        }
    }
}<commit_msg>adding get property on webelement so that custom properties can be obtained<commit_after>package com.thoughtworks.calabash.android;

import org.jruby.RubyArray;
import org.jruby.RubyHash;

import java.util.ArrayList;

import static com.thoughtworks.calabash.android.CalabashLogger.warn;

public class WebElements extends ArrayList<UIElement> {
    public WebElements(RubyArray elementsArray, String query, CalabashWrapper calabashWrapper) {
        query = query.trim();
        for (Object element : elementsArray) {
            RubyHash object = (RubyHash) element;
            this.add(new UIElement(object, query, calabashWrapper));
        }
    }

    /**
     * touch the webview element, if there are multiple elements, only the first one will be touched
     *
     * @throws CalabashException
     */
    public void touch() throws CalabashException {
        getFirstElement().touch();
    }

    private UIElement getFirstElement() throws CalabashException {
        ensureCollectionIsNotEmpty();
        if (this.size() > 1) {
            warn("There are multiple webview elements, so considering only the first element");
        }
        return this.get(0);
    }

    /**
     * set text to the webview element, if there are multiple elements, only the first one will be considered
     *
     * @param text
     * @throws CalabashException
     */
    public void setText(String text) throws CalabashException {
        getFirstElement().setText(text);
    }

    /**
     * fetch the text content of the weblement
     *
     * @return inner text of the element
     */
    public String getText() throws CalabashException {
        return getFirstElement().getTextContent();
    }

    /**
     * fetch the getValue of the webelement
     *
     * @return getValue of the element
     * @throws CalabashException
     */
    public String getValue() throws CalabashException {
        return getFirstElement().getValue();
    }

    /**
     * @return bounds of the webelement
     */
    public Rect getRect() throws CalabashException {
        return getFirstElement().getRect();
    }

    /**
     * @return the css class of the webelement
     */
    public String getElementClass() throws CalabashException {
        return getFirstElement().getElementClass();
    }

    /**
     * @return the css id of the webelement
     * @throws CalabashException
     */
    public String getId() throws CalabashException {
        return getFirstElement().getId();
    }

    /**
     * get a custom property on the webelement
     * @param propertyName the property name of the element
     * @return the property value
     * @throws CalabashException
     */
    public Object getProperty(String propertyName) throws CalabashException {
        return getFirstElement().getProperty(propertyName);
    }

    private void ensureCollectionIsNotEmpty() throws CalabashException {
        if (this.size() == 0) {
            throw new CalabashException("Cannot perform action on an empty list");
        }
    }
}
{'fraction_non_alphanumeric': 0.0865571453806748, 'fraction_numerical': 0.0010598834128245894, 'mean_word_length': 2.6017811704834606, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6341720', 'n_tokens_mistral': 1521, 'n_tokens_neox': 1475, 'n_words': 462}