Package de.bmiag.tapir.selenium.element
Class SeleniumElementFactory
- java.lang.Object
-
- de.bmiag.tapir.selenium.element.SeleniumElementFactory
-
@Component("tapirSeleniumElementFactory") public class SeleniumElementFactory extends java.lang.Object
This factory creates the concrete Selenium implementations for tapir interfaces. It also provides the possibility to wrap proxies around the elements in order to retry search operations in specific cases. the factory is aware ofSingleWebElementBased
andMultiWebElementBased
and injects the web element(s) into the created bean.- Since:
- 2.0.0
- Author:
- Oliver Libutzki <[email protected]>, Nils Christian Ehmke <[email protected]>
- See Also:
SingleWebElementBased
,MultiWebElementBased
-
-
Constructor Summary
Constructors Constructor Description SeleniumElementFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends MultiWebElementBased>
TautowireSeleniumElement(T multiWebElementBased, java.util.List<org.openqa.selenium.WebElement> webElements)
Autowires the given multiWebElementBased and sets the given web elements by callingMultiWebElementBased.setWebElements(List)
.<T extends SingleWebElementBased>
TautowireSeleniumElement(T singleWebElementBased, org.openqa.selenium.WebElement webElement)
Autowires the given singleWebelementBased and sets the given web element by callingSingleWebElementBased.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)
-
-
-
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 theBeanFactory.getBean(Class, Object...)
by passing the given type and args. Depending on the interface which the bean implements, the correspondingWebElementProvider
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 builtargs
- The type arguments- Returns:
- the Selenium element
- Throws:
java.lang.IllegalStateException
- thrown if the bean for the given type does not implementSingleWebElementBased
orMultiWebElementBased
.- 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 implementSingleWebElementBased
, otherwise anIllegalStateException
is thrown.- Type Parameters:
T
- The resulting bean type- Parameters:
webElement
- the web elementtype
- The type of the element which should be builtargs
- The type arguments- Returns:
- the Selenium element
- Throws:
java.lang.IllegalStateException
- thrown if the bean for the given type does not implementSingleWebElementBased
- 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 implementMultiWebElementBased
, otherwise anIllegalStateException
is thrown.- Type Parameters:
T
- The resulting bean type- Parameters:
webElements
- the web elementstype
- The type of the element which should be builtargs
- The type arguments- Returns:
- the Selenium element
- Throws:
java.lang.IllegalStateException
- thrown if the bean for the given type does not implementMultiWebElementBased
- 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 callingSingleWebElementBased.setWebElement(WebElement)
.- Type Parameters:
T
- the bean type- Parameters:
singleWebElementBased
- the element to be initializedwebElement
- the web element on which the givenSingleWebElementBased
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 callingMultiWebElementBased.setWebElements(List)
.- Type Parameters:
T
- the bean type- Parameters:
multiWebElementBased
- the element to be initializedwebElements
- the web elements on which the givenMultiWebElementBased
is based on.- Returns:
- the passed multiWebElementBased parameter
- Since:
- 2.0.0
-
-