com.atlassian.webdriver.utils
Class WebDriverUtil

java.lang.Object
  extended by com.atlassian.webdriver.utils.WebDriverUtil

public final class WebDriverUtil
extends Object

Since:
2.1

Method Summary
static
<T> T
as(org.openqa.selenium.WebDriver driver, Class<T> type)
          Get the underlying web driver instance from driver as instance of type.
static org.openqa.selenium.WebDriver getUnderlyingDriver(org.openqa.selenium.WebDriver driver)
          Retrieve the underlying WebDriver instance.
static boolean isChrome(org.openqa.selenium.WebDriver driver)
           
static boolean isFirefox(org.openqa.selenium.WebDriver driver)
           
static boolean isHtmlUnit(org.openqa.selenium.WebDriver driver)
           
static boolean isIE(org.openqa.selenium.WebDriver driver)
           
static boolean isInstance(org.openqa.selenium.WebDriver driver, Class<?> type)
          Check whether the underlying driver is instance of type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isFirefox

public static boolean isFirefox(@Nonnull
                                org.openqa.selenium.WebDriver driver)

isChrome

public static boolean isChrome(@Nonnull
                               org.openqa.selenium.WebDriver driver)

isHtmlUnit

public static boolean isHtmlUnit(@Nonnull
                                 org.openqa.selenium.WebDriver driver)

isIE

public static boolean isIE(@Nonnull
                           org.openqa.selenium.WebDriver driver)

getUnderlyingDriver

@Nonnull
public static org.openqa.selenium.WebDriver getUnderlyingDriver(@Nonnull
                                                                        org.openqa.selenium.WebDriver driver)
Retrieve the underlying WebDriver instance.

Parameters:
driver - the driver to examine
Returns:
the underlying web driver instance that is actually driving the test. This can be the same instance as driver, or some other instance that is wrapped by driver.

isInstance

public static boolean isInstance(@Nonnull
                                 org.openqa.selenium.WebDriver driver,
                                 @Nonnull
                                 Class<?> type)
Check whether the underlying driver is instance of type. This method attempts to retrieve the underlying web driver before performing the instance check.

Parameters:
driver - driver to check
type - type to check
Returns:
true, if the underlying driver is an instance of type, in which case as(WebDriver, Class) may be safely used on it
See Also:
getUnderlyingDriver(WebDriver)

as

public static <T> T as(@Nonnull
                       org.openqa.selenium.WebDriver driver,
                       @Nonnull
                       Class<T> type)
Get the underlying web driver instance from driver as instance of type.

Type Parameters:
T - type parameter
Parameters:
driver - driver to examine
type - type to cast to
Returns:
the underlying driver instance as T
Throws:
ClassCastException - if isInstance(WebDriver, Class) for given arguments returns false
See Also:
isInstance(org.openqa.selenium.WebDriver, Class)


Copyright © 2014 Atlassian. All rights reserved.