Class WebDriverRunner

java.lang.Object
com.codeborne.selenide.WebDriverRunner

@ParametersAreNonnullByDefault public class WebDriverRunner extends Object
A static facade for accessing WebDriver instance for current threads
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    addListener(org.openqa.selenium.support.events.WebDriverEventListener listener)
    Deprecated.
    static void
    addListener(org.openqa.selenium.support.events.WebDriverListener listener)
    Use this method BEFORE opening a browser to add custom event listeners to webdriver.
    static void
    Delete all the browser cookies
    static void
    Close the browser if it's open.
    static void
    Close the current window, quitting the browser if it's the last window currently open.
    static String
     
    static com.codeborne.selenide.Driver
     
    static org.openqa.selenium.WebDriver
    Get the underlying instance of Selenium WebDriver, and assert that it's still alive.
    static com.codeborne.selenide.DownloadsFolder
     
    static com.codeborne.selenide.proxy.SelenideProxyServer
    Get selenide proxy.
    static org.openqa.selenium.WebDriver
    Get the underlying instance of Selenium WebDriver.
    static boolean
     
    static boolean
    Is Selenide configured to use Chrome browser
    static boolean
    Is Selenide configured to use Microsoft EDGE browser
    static boolean
    Is Selenide configured to use Firefox browser
    static boolean
    Is Selenide configured to use headless browser
    static boolean
    Is Selenide configured to use Internet Explorer browser
    static void
    removeListener(org.openqa.selenium.support.events.WebDriverEventListener listener)
    Deprecated.
    static void
    removeListener(org.openqa.selenium.support.events.WebDriverListener listener)
     
    static void
    setProxy(org.openqa.selenium.Proxy webProxy)
    Sets Selenium Proxy instance
    static void
    setWebDriver(org.openqa.selenium.WebDriver webDriver)
    Tell Selenide use your provided WebDriver instance.
    static void
    setWebDriver(org.openqa.selenium.WebDriver webDriver, com.codeborne.selenide.proxy.SelenideProxyServer selenideProxy)
     
    static void
    setWebDriver(org.openqa.selenium.WebDriver webDriver, com.codeborne.selenide.proxy.SelenideProxyServer selenideProxy, com.codeborne.selenide.DownloadsFolder browserDownloadsFolder)
     
    static String
     
    static boolean
    Does this browser support javascript
    static String
    url()
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • WebDriverRunner

      public WebDriverRunner()
  • Method Details

    • addListener

      @Deprecated public static void addListener(org.openqa.selenium.support.events.WebDriverEventListener listener)
      Deprecated.
    • removeListener

      @Deprecated public static void removeListener(org.openqa.selenium.support.events.WebDriverEventListener listener)
      Deprecated.
    • addListener

      public static void addListener(org.openqa.selenium.support.events.WebDriverListener listener)
      Use this method BEFORE opening a browser to add custom event listeners to webdriver.
      Parameters:
      listener - your listener of webdriver events
      Since:
      6.0.0
    • removeListener

      public static void removeListener(org.openqa.selenium.support.events.WebDriverListener listener)
      Since:
      6.0.0
    • setWebDriver

      public static void setWebDriver(org.openqa.selenium.WebDriver webDriver)
      Tell Selenide use your provided WebDriver instance. Use it if you need a custom logic for creating WebDriver.

      It's recommended not to use implicit wait with this driver, because Selenide handles timing issues explicitly.

      NB! Be sure to call this method before calling open(url). Otherwise, Selenide will create its own WebDriver instance and would not close it.

      NB! When using your custom webdriver, you are responsible for closing it. Selenide will not take care of it.

      NB! Webdriver instance should be created and used in the same thread. A typical error is to create webdriver instance in one thread and use it in another. Selenide does not support it. If you really need using multiple threads, please use #com.codeborne.selenide.WebDriverProvider

      P.S. Alternatively, you can run tests with system property

        -Dbrowser=com.my.WebDriverFactory

      which should implement interface #com.codeborne.selenide.WebDriverProvider

    • setWebDriver

      public static void setWebDriver(org.openqa.selenium.WebDriver webDriver, @Nullable com.codeborne.selenide.proxy.SelenideProxyServer selenideProxy)
    • setWebDriver

      public static void setWebDriver(org.openqa.selenium.WebDriver webDriver, @Nullable com.codeborne.selenide.proxy.SelenideProxyServer selenideProxy, com.codeborne.selenide.DownloadsFolder browserDownloadsFolder)
    • getWebDriver

      @CheckReturnValue @Nonnull public static org.openqa.selenium.WebDriver getWebDriver()
      Get the underlying instance of Selenium WebDriver. This can be used for any operations directly with WebDriver.
    • setProxy

      public static void setProxy(@Nullable org.openqa.selenium.Proxy webProxy)
      Sets Selenium Proxy instance
    • getAndCheckWebDriver

      @CheckReturnValue @Nonnull public static org.openqa.selenium.WebDriver getAndCheckWebDriver()
      Get the underlying instance of Selenium WebDriver, and assert that it's still alive.
      Returns:
      new instance of WebDriver if the previous one has been closed meanwhile.
    • getSelenideProxy

      @CheckReturnValue @Nonnull public static com.codeborne.selenide.proxy.SelenideProxyServer getSelenideProxy()
      Get selenide proxy. It's activated only if Configuration.proxyEnabled == true
    • driver

      @CheckReturnValue @Nonnull public static com.codeborne.selenide.Driver driver()
    • getBrowserDownloadsFolder

      @CheckReturnValue @Nullable public static com.codeborne.selenide.DownloadsFolder getBrowserDownloadsFolder()
    • closeWindow

      public static void closeWindow()
      Close the current window, quitting the browser if it's the last window currently open.
      See Also:
      • WebDriver.close()
    • closeWebDriver

      public static void closeWebDriver()

      Close the browser if it's open.


      NB! Method quits this driver, closing every associated window.

      See Also:
      • WebDriver.quit()
    • hasWebDriverStarted

      @CheckReturnValue public static boolean hasWebDriverStarted()
      Returns:
      true if instance of Selenium WebDriver is started in current thread
    • isFirefox

      @CheckReturnValue public static boolean isFirefox()
      Is Selenide configured to use Firefox browser
    • isChrome

      @CheckReturnValue public static boolean isChrome()
      Is Selenide configured to use Chrome browser
    • isIE

      @CheckReturnValue public static boolean isIE()
      Is Selenide configured to use Internet Explorer browser
    • isEdge

      @CheckReturnValue public static boolean isEdge()
      Is Selenide configured to use Microsoft EDGE browser
    • isHeadless

      @CheckReturnValue public static boolean isHeadless()
      Is Selenide configured to use headless browser
    • supportsJavascript

      @CheckReturnValue public static boolean supportsJavascript()
      Does this browser support javascript
    • clearBrowserCache

      public static void clearBrowserCache()
      Delete all the browser cookies
    • source

      @CheckReturnValue @Nonnull public static String source()
      Returns:
      the source (HTML) of current page
    • url

      @CheckReturnValue @Nonnull public static String url()
      Returns:
      the URL of current page
    • currentFrameUrl

      @CheckReturnValue @Nonnull public static String currentFrameUrl()
      Returns:
      the URL of current frame