Class WebDriverUnpackUtility
- java.lang.Object
-
- io.appium.java_client.pagefactory.utils.WebDriverUnpackUtility
-
public final class WebDriverUnpackUtility extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ContentType
getCurrentContentType(org.openqa.selenium.SearchContext context)
Detects content type by the provided searchcontext
.static <T> java.util.Optional<T>
unpackObjectFromSearchContext(org.openqa.selenium.SearchContext searchContext, java.lang.Class<T> cls)
This method extracts an instance of the given interface from the givenSearchContext
.static org.openqa.selenium.WebDriver
unpackWebDriverFromSearchContext(org.openqa.selenium.SearchContext searchContext)
This method extract an instance ofWebDriver
from the givenSearchContext
.
-
-
-
Method Detail
-
unpackObjectFromSearchContext
public static <T> java.util.Optional<T> unpackObjectFromSearchContext(@Nullable org.openqa.selenium.SearchContext searchContext, java.lang.Class<T> cls)
This method extracts an instance of the given interface from the givenSearchContext
. It is expected that theSearchContext
itself or the object it wraps implements it.- Parameters:
searchContext
- is an instance ofSearchContext
. It may be the instance ofWebDriver
orWebElement
or some other user's extension/implementation. Note: if you want to use your own implementation then it should implementWrapsDriver
orWrapsElement
cls
- interface whose instance is going to be extracted.- Returns:
- Either an instance of the given interface or Optional.empty().
-
unpackWebDriverFromSearchContext
@Nullable public static org.openqa.selenium.WebDriver unpackWebDriverFromSearchContext(@Nullable org.openqa.selenium.SearchContext searchContext)
This method extract an instance ofWebDriver
from the givenSearchContext
.- Parameters:
searchContext
- is an instance ofSearchContext
. It may be the instance ofWebDriver
orWebElement
or some other user's extension/implementation. Note: if you want to use your own implementation then it should implementWrapsDriver
orWrapsElement
- Returns:
- the instance of
WebDriver
. Note: if the givenSearchContext
is notWebDriver
and it doesn't implementWrapsDriver
orWrapsElement
then this method returns null.
-
getCurrentContentType
public static ContentType getCurrentContentType(org.openqa.selenium.SearchContext context)
Detects content type by the provided searchcontext
.- Parameters:
context
- is an instance ofSearchContext
. It may be the instance ofWebDriver
orWebElement
or some other user's extension/implementation. Note: if you want to use your own implementation then it should implementContextAware
orWrapsDriver
orHasBrowserCheck
- Returns:
- current content type. It depends on current context. If current context is
NATIVE_APP it will return
ContentType.NATIVE_MOBILE_SPECIFIC
.ContentType.HTML_OR_DEFAULT
will be returned if the current context is WEB_VIEW.ContentType.HTML_OR_DEFAULT
also will be returned if the givenSearchContext
instance doesn't implementContextAware
andWrapsDriver
-
-