Class Collection

    • Field Detail

      • COLLECTION_ITEM_ID_ATTRIBUTE

        public static final java.lang.String COLLECTION_ITEM_ID_ATTRIBUTE
        See Also:
        Constant Field Values
      • DEFAULT_ITEM_SELECTOR_PATTERN

        public static final java.lang.String DEFAULT_ITEM_SELECTOR_PATTERN
        See Also:
        Constant Field Values
      • DEFAULT_ALLITEMS_SELECTOR

        public static final java.lang.String DEFAULT_ALLITEMS_SELECTOR
        See Also:
        Constant Field Values
    • Constructor Detail

      • Collection

        public Collection​(java.lang.String selector)
        Constructor to create a CollectionComponent.
        Parameters:
        selector - selector for the collection
    • Method Detail

      • getId

        public java.lang.String getId()
        Returns:
        collection id of the current element.
      • getItems

        public com.codeborne.selenide.ElementsCollection getItems()
        Gets all the items that belong to the current collection.
        Returns:
        ElementsCollection the items currently loaded in the collection.
      • getSelectedItems

        public com.codeborne.selenide.ElementsCollection getSelectedItems()
        Gets all the selected items that belong to the current collection.
        Returns:
        ElementsCollection the items currently loaded and selected in the collection.
      • toggleSelectionItem

        public Collection toggleSelectionItem​(java.lang.String... collectionItemID)
        Toggle the item selection by clicking on its checkbox.
        Parameters:
        collectionItemID - collectionItemID - id of the item, as indicated by `data-foundation-collection-item-id`.
        Returns:
        self
      • isSelectable

        public boolean isSelectable​(java.lang.String collectionItemID)
        Checks if checkbox is visible to select item.
        Parameters:
        collectionItemID - id of the item, as indicated by `data-foundation-collection-item-id`.
        Returns:
        boolean
      • toggleItem

        protected Collection toggleItem​(com.codeborne.selenide.SelenideElement item)
        Parameters:
        item - the element on which toggle item is called, default it click on coral-checkbox.
        Returns:
        self
      • selectItem

        public Collection selectItem​(java.lang.String... collectionItemID)
        Uses the 'right' function to select element based on the provided view.
        Parameters:
        collectionItemID - id of the item, as indicated by `data-foundation-collection-item-id`.
        Returns:
        self
      • deselectItem

        public Collection deselectItem​(java.lang.String... collectionItemID)
        Uses the 'right' function to deselect element based on the provided view.
        Parameters:
        collectionItemID - id of the item, as indicated by `data-foundation-collection-item-id`.
        Returns:
        self
      • selectThumbnailItem

        public Collection selectThumbnailItem​(java.lang.String... collectionItemID)
        Selects the specified element based on the provided view, specific to a view that renders a list of thumbnail items.
        Parameters:
        collectionItemID - id of the item, as indicated by `data-foundation-collection-item-id`.
        Returns:
        self
      • deselectThumbnailItem

        public Collection deselectThumbnailItem​(java.lang.String... collectionItemID)
        De-selects the specified element based on the provided view, specific to a view that renders a list of thumbnail items.
        Parameters:
        collectionItemID - id of the item, as indicated by `data-foundation-collection-item-id`.
        Returns:
        self
      • getCollectionItem

        public com.codeborne.selenide.SelenideElement getCollectionItem​(java.lang.String collectionItemID)
        Get a collection item element.
        Parameters:
        collectionItemID - - The id used in data-foundation-collection-item-id
        Returns:
        the element matching the collection id.
      • hasCollectionItem

        public boolean hasCollectionItem​(java.lang.String collectionItemID)
        Check if a collection item element exists.
        Parameters:
        collectionItemID - - The id used in data-foundation-collection-item-id
        Returns:
        true if the item element exist.
      • selectActionOnCollectionItem

        public Collection selectActionOnCollectionItem​(java.lang.String collectionItemID,
                                                       java.lang.String actionTitle)
        Select an action on a specified collection item. This method currently assumes that the collection is based on the masonry.
        Parameters:
        collectionItemID - - The id used in `data-foundation-collection-item-id`.
        actionTitle - - The action title.
        Returns:
        self
      • hasItemAtIndex

        public boolean hasItemAtIndex​(int index)
        Determines if there is a collection item for the datasource element with the provided index. Only supported if the collection supports lazy loading.
        Parameters:
        index - - the datasource index of the element represented by the collection item.
        Returns:
        true if the collection has an item for the element with that index or false otherwise.
      • hasLazyItemAtIndex

        public boolean hasLazyItemAtIndex​(int index)
        Determines if there is a lazy loaded collection item for the datasource element with the provided index. Lazy loaded means the collection item is just a placeholder for the real item
        Parameters:
        index - - the datasource index of the element represented by the collection item.
        Returns:
        true if the collection has an item for the element with that index or false otherwise.
      • hasPendingItemAtIndex

        public boolean hasPendingItemAtIndex​(int index)
        Determines if there is a pending collection item for the datasource element with the provided index. Pending means the collection item is just a placeholder for the real item, but the request is made to get the real data for that element.
        Parameters:
        index - - the datasource index of the element represented by the collection item.
        Returns:
        true if the collection has an item for the element with that index or false otherwise.
      • hasMoreElements

        public boolean hasMoreElements()
        Waits for the collection to finish loading and checks if the "has more elements" marker is visible or not.
        Returns:
        true if the masonry shows the "has more elements" marker or false otherwise.
      • waitForLoadingItemAtIndex

        public Collection waitForLoadingItemAtIndex​(int index)
        Wait until the collection item for the element with the provided index has its metadata loaded. The element has its metadata loaded if the collection item is neither waiting nor pending.
        Parameters:
        index - - index of the item in the collection.
        Returns:
        self
      • activate

        public Collection activate​(java.lang.String itemId)
        Activates an item by clicking it.
        Parameters:
        itemId - the id of the item to activate;
        Returns:
        self
      • waitForItem

        public Collection waitForItem​(java.lang.String itemId,
                                      boolean reverse)
        Waits till an item with the provided id is present in the dom.
        Parameters:
        itemId - the id of the item to wait for
        reverse - flags if we check for existing or not
        Returns:
        self
      • waitForItemPreview

        public Collection waitForItemPreview​(java.lang.String itemId)
        Waits for the preview of the item to exist.
        Parameters:
        itemId - the id of the item we wait for
        Returns:
        self
      • columnPreview

        public CoralColumnPreview columnPreview()
        Returns:
        return the column preview.
      • isLazyLoadingSupported

        public boolean isLazyLoadingSupported()
        Returns:
        true if lazy loading is supported.
      • setLazyLoadingSupported

        public Collection setLazyLoadingSupported​(boolean lazyLoadingSupported)
        Parameters:
        lazyLoadingSupported - to set support of lazy loading.
        Returns:
        self
      • getHasMoreElementsSelector

        public java.lang.String getHasMoreElementsSelector()
        Returns:
        selector to find if it has more element.
      • setHasMoreElementsSelector

        public Collection setHasMoreElementsSelector​(java.lang.String selector)
        Parameters:
        selector - set the selector to find if it has more.
        Returns:
        self
      • getLazyItemClass

        public java.lang.String getLazyItemClass()
        Returns:
        the selector to find lazy loading.
      • setLazyItemClass

        public Collection setLazyItemClass​(java.lang.String selector)
        Parameters:
        selector - the lazy loading selector.
        Returns:
        self
      • getPendingItemClass

        public java.lang.String getPendingItemClass()
        Returns:
        the class used to marked pending item.
      • setPendingItemClass

        public Collection setPendingItemClass​(java.lang.String cssClass)
        Parameters:
        cssClass - set the css classname to mark pending item.
        Returns:
        self
      • setItemSelectorPattern

        public Collection setItemSelectorPattern​(java.lang.String itemSelectorPattern)
        Parameters:
        itemSelectorPattern - define a different way to select items.
        Returns:
        self
      • setAllItemsSelector

        public Collection setAllItemsSelector​(java.lang.String allItemsSelector)
        Parameters:
        allItemsSelector - define a different way to select all items.
        Returns:
        self