Class 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 search context.
      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 given SearchContext.
      static org.openqa.selenium.WebDriver unpackWebDriverFromSearchContext​(org.openqa.selenium.SearchContext searchContext)
      This method extract an instance of WebDriver from the given SearchContext.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 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

        @Nullable
        public static 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 ContextAware 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 ContextAware and WrapsDriver