Class SeleniumElementFactory

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T extends MultiWebElementBased>
      T
      autowireSeleniumElement​(T multiWebElementBased, java.util.List<org.openqa.selenium.WebElement> webElements)
      Autowires the given multiWebElementBased and sets the given web elements by calling MultiWebElementBased.setWebElements(List).
      <T extends SingleWebElementBased>
      T
      autowireSeleniumElement​(T singleWebElementBased, org.openqa.selenium.WebElement webElement)
      Autowires the given singleWebelementBased and sets the given web element by calling SingleWebElementBased.setWebElement(WebElement).
      <T> T getSeleniumElement​(WebElementProvider webElementProvider, com.google.common.reflect.TypeToken<T> typeToken, java.lang.Object... args)  
      <T> T getSeleniumElement​(WebElementProvider webElementProvider, java.lang.Class<T> type, java.lang.Object... args)
      Returns a Selenium element for the web element(s) provided by the given webElementProvider.
      <T> T getSeleniumElement​(java.util.List<org.openqa.selenium.WebElement> webElements, com.google.common.reflect.TypeToken<T> typeToken, java.lang.Object... args)  
      <T> T getSeleniumElement​(java.util.List<org.openqa.selenium.WebElement> webElements, java.lang.Class<T> type, java.lang.Object... args)
      Returns a Selenium element for the given web elements.
      <T> T getSeleniumElement​(org.openqa.selenium.WebElement webElement, com.google.common.reflect.TypeToken<T> typeToken, java.lang.Object... args)  
      <T> T getSeleniumElement​(org.openqa.selenium.WebElement webElement, java.lang.Class<T> type, java.lang.Object... args)
      Returns a Selenium element for the given web element.
      protected void injectTypeArgument​(java.lang.Object bean, com.google.common.reflect.TypeToken<?> typeToken)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SeleniumElementFactory

        public SeleniumElementFactory()
    • Method Detail

      • getSeleniumElement

        public <T> T getSeleniumElement​(WebElementProvider webElementProvider,
                                        java.lang.Class<T> type,
                                        java.lang.Object... args)
        Returns a Selenium element for the web element(s) provided by the given webElementProvider. For the given type the corresponding bean is fetched.
        This method first consults the BeanFactory.getBean(Class, Object...) by passing the given type and args. Depending on the interface which the bean implements, the corresponding WebElementProvider method is called in order to determine the web element(s). The web element(s) is/are set by this method, so clients do not have to care about the initialization.
        Type Parameters:
        T - The resulting bean type
        Parameters:
        webElementProvider - the web element provider. The type of the bean decides which method of the provider is called.
        type - The type of the element which should be built
        args - The type arguments
        Returns:
        the Selenium element
        Throws:
        java.lang.IllegalStateException - thrown if the bean for the given type does not implement SingleWebElementBased or MultiWebElementBased.
        Since:
        2.0.0
      • getSeleniumElement

        public <T> T getSeleniumElement​(WebElementProvider webElementProvider,
                                        com.google.common.reflect.TypeToken<T> typeToken,
                                        java.lang.Object... args)
      • getSeleniumElement

        public <T> T getSeleniumElement​(org.openqa.selenium.WebElement webElement,
                                        java.lang.Class<T> type,
                                        java.lang.Object... args)
        Returns a Selenium element for the given web element. For the given type the corresponding bean is fetched. The bean has to implement SingleWebElementBased, otherwise an IllegalStateException is thrown.
        Type Parameters:
        T - The resulting bean type
        Parameters:
        webElement - the web element
        type - The type of the element which should be built
        args - The type arguments
        Returns:
        the Selenium element
        Throws:
        java.lang.IllegalStateException - thrown if the bean for the given type does not implement SingleWebElementBased
        Since:
        2.0.0
      • getSeleniumElement

        public <T> T getSeleniumElement​(org.openqa.selenium.WebElement webElement,
                                        com.google.common.reflect.TypeToken<T> typeToken,
                                        java.lang.Object... args)
      • getSeleniumElement

        public <T> T getSeleniumElement​(java.util.List<org.openqa.selenium.WebElement> webElements,
                                        java.lang.Class<T> type,
                                        java.lang.Object... args)
        Returns a Selenium element for the given web elements. For the given type the corresponding bean is fetched. The bean has to implement MultiWebElementBased, otherwise an IllegalStateException is thrown.
        Type Parameters:
        T - The resulting bean type
        Parameters:
        webElements - the web elements
        type - The type of the element which should be built
        args - The type arguments
        Returns:
        the Selenium element
        Throws:
        java.lang.IllegalStateException - thrown if the bean for the given type does not implement MultiWebElementBased
        Since:
        2.0.0
      • getSeleniumElement

        public <T> T getSeleniumElement​(java.util.List<org.openqa.selenium.WebElement> webElements,
                                        com.google.common.reflect.TypeToken<T> typeToken,
                                        java.lang.Object... args)
      • injectTypeArgument

        protected void injectTypeArgument​(java.lang.Object bean,
                                          com.google.common.reflect.TypeToken<?> typeToken)
      • autowireSeleniumElement

        public <T extends SingleWebElementBased> T autowireSeleniumElement​(T singleWebElementBased,
                                                                           org.openqa.selenium.WebElement webElement)
        Autowires the given singleWebelementBased and sets the given web element by calling SingleWebElementBased.setWebElement(WebElement).
        Type Parameters:
        T - the bean type
        Parameters:
        singleWebElementBased - the element to be initialized
        webElement - the web element on which the given SingleWebElementBased is based on.
        Returns:
        the passed singleWebElementBased parameter
        Since:
        2.0.0
      • autowireSeleniumElement

        public <T extends MultiWebElementBased> T autowireSeleniumElement​(T multiWebElementBased,
                                                                          java.util.List<org.openqa.selenium.WebElement> webElements)
        Autowires the given multiWebElementBased and sets the given web elements by calling MultiWebElementBased.setWebElements(List).
        Type Parameters:
        T - the bean type
        Parameters:
        multiWebElementBased - the element to be initialized
        webElements - the web elements on which the given MultiWebElementBased is based on.
        Returns:
        the passed multiWebElementBased parameter
        Since:
        2.0.0