Class WebDriverUnpackUtility

java.lang.Object
io.appium.java_client.pagefactory.utils.WebDriverUnpackUtility

public final class WebDriverUnpackUtility extends Object
  • Method Details

    • unpackObjectFromSearchContext

      public static <T> Optional<T> unpackObjectFromSearchContext(@Nullable org.openqa.selenium.SearchContext searchContext, Class<T> cls)
      This method extracts an instance of the given interface from the given SearchContext. It is expected that the SearchContext itself or the object it wraps implements it.
      Parameters:
      searchContext - is an instance of SearchContext. It may be the instance of WebDriver or WebElement or some other user's extension/implementation. Note: if you want to use your own implementation then it should implement WrapsDriver or WrapsElement
      cls - 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 of WebDriver from the given SearchContext.
      Parameters:
      searchContext - is an instance of SearchContext. It may be the instance of WebDriver or WebElement or some other user's extension/implementation. Note: if you want to use your own implementation then it should implement WrapsDriver or WrapsElement
      Returns:
      the instance of WebDriver. Note: if the given SearchContext is not WebDriver and it doesn't implement WrapsDriver or WrapsElement then this method returns null.
    • getCurrentContentType

      public static ContentType getCurrentContentType(org.openqa.selenium.SearchContext context)
      Detects content type by the provided search context.
      Parameters:
      context - is an instance of SearchContext. It may be the instance of WebDriver or WebElement or some other user's extension/implementation. Note: if you want to use your own implementation then it should implement SupportsContextSwitching or WrapsDriver or HasBrowserCheck
      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 given SearchContext instance doesn't implement SupportsContextSwitching and WrapsDriver