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 ContentTypegetCurrentContentType(org.openqa.selenium.SearchContext context)Detects content type by the provided searchcontext.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.static @Nullable org.openqa.selenium.WebDriverunpackWebDriverFromSearchContext(@Nullable org.openqa.selenium.SearchContext searchContext)This method extract an instance ofWebDriverfrom 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 theSearchContextitself or the object it wraps implements it.- Parameters:
searchContext- is an instance ofSearchContext. It may be the instance ofWebDriverorWebElementor some other user's extension/implementation. Note: if you want to use your own implementation then it should implementWrapsDriverorWrapsElementcls- interface whose instance is going to be extracted.- Returns:
- Either an instance of the given interface or Optional.empty().
-
unpackWebDriverFromSearchContext
public static @Nullable org.openqa.selenium.WebDriver unpackWebDriverFromSearchContext(@Nullable org.openqa.selenium.SearchContext searchContext)
This method extract an instance ofWebDriverfrom the givenSearchContext.- Parameters:
searchContext- is an instance ofSearchContext. It may be the instance ofWebDriverorWebElementor some other user's extension/implementation. Note: if you want to use your own implementation then it should implementWrapsDriverorWrapsElement- Returns:
- the instance of
WebDriver. Note: if the givenSearchContextis notWebDriverand it doesn't implementWrapsDriverorWrapsElementthen 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 ofWebDriverorWebElementor some other user's extension/implementation. Note: if you want to use your own implementation then it should implementSupportsContextSwitchingorWrapsDriverorHasBrowserCheck- 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_DEFAULTwill be returned if the current context is WEB_VIEW.ContentType.HTML_OR_DEFAULTalso will be returned if the givenSearchContextinstance doesn't implementSupportsContextSwitchingandWrapsDriver
-
-