@ParametersAreNonnullByDefault
public class WebDriverRunner
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static WebDriverContainer |
webdriverContainer |
Constructor and Description |
---|
WebDriverRunner() |
Modifier and Type | Method and Description |
---|---|
static void |
addListener(org.openqa.selenium.support.events.WebDriverEventListener listener)
Deprecated.
Use
addListener(WebDriverListener) instead |
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 |
clearBrowserCache()
Delete all the browser cookies
|
static void |
closeWebDriver()
Close the browser if it's open.
|
static void |
closeWindow()
Close the current window, quitting the browser if it's the last window currently open.
|
static java.lang.String |
currentFrameUrl() |
static Driver |
driver() |
static org.openqa.selenium.WebDriver |
getAndCheckWebDriver()
Get the underlying instance of Selenium WebDriver, and assert that it's still alive.
|
static DownloadsFolder |
getBrowserDownloadsFolder() |
static SelenideProxyServer |
getSelenideProxy()
Get selenide proxy.
|
static org.openqa.selenium.WebDriver |
getWebDriver()
Get the underlying instance of Selenium WebDriver.
|
static boolean |
hasWebDriverStarted() |
static boolean |
isChrome()
Is Selenide configured to use Chrome browser
|
static boolean |
isEdge()
Is Selenide configured to use Microsoft EDGE browser
|
static boolean |
isFirefox()
Is Selenide configured to use Firefox browser
|
static boolean |
isHeadless()
Is Selenide configured to use headless browser
|
static boolean |
isIE()
Is Selenide configured to use Internet Explorer browser
|
static boolean |
isOpera()
Is Selenide configured to use Opera browser
|
static void |
removeListener(org.openqa.selenium.support.events.WebDriverEventListener listener)
Deprecated.
Use
removeListener(WebDriverListener) instead |
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,
SelenideProxyServer selenideProxy) |
static void |
setWebDriver(org.openqa.selenium.WebDriver webDriver,
SelenideProxyServer selenideProxy,
DownloadsFolder browserDownloadsFolder) |
static java.lang.String |
source() |
static boolean |
supportsJavascript()
Does this browser support javascript
|
static java.lang.String |
url() |
static void |
using(org.openqa.selenium.WebDriver driver,
java.lang.Runnable lambda) |
public static WebDriverContainer webdriverContainer
@Deprecated public static void addListener(org.openqa.selenium.support.events.WebDriverEventListener listener)
addListener(WebDriverListener)
instead@Deprecated public static void removeListener(org.openqa.selenium.support.events.WebDriverEventListener listener)
removeListener(WebDriverListener)
insteadpublic static void addListener(org.openqa.selenium.support.events.WebDriverListener listener)
listener
- your listener of webdriver eventspublic static void removeListener(org.openqa.selenium.support.events.WebDriverListener listener)
public static void setWebDriver(org.openqa.selenium.WebDriver 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
public static void setWebDriver(org.openqa.selenium.WebDriver webDriver, @Nullable SelenideProxyServer selenideProxy)
public static void setWebDriver(org.openqa.selenium.WebDriver webDriver, @Nullable SelenideProxyServer selenideProxy, DownloadsFolder browserDownloadsFolder)
@CheckReturnValue @Nonnull public static org.openqa.selenium.WebDriver getWebDriver()
public static void setProxy(@Nullable org.openqa.selenium.Proxy webProxy)
@CheckReturnValue @Nonnull public static org.openqa.selenium.WebDriver getAndCheckWebDriver()
@CheckReturnValue @Nullable public static SelenideProxyServer getSelenideProxy()
@CheckReturnValue @Nonnull public static Driver driver()
@CheckReturnValue @Nonnull public static DownloadsFolder getBrowserDownloadsFolder()
public static void closeWindow()
WebDriver.close()
public static void closeWebDriver()
Close the browser if it's open.
NB! Method quits this driver, closing every associated window.
WebDriver.quit()
@CheckReturnValue public static boolean hasWebDriverStarted()
public static void using(org.openqa.selenium.WebDriver driver, java.lang.Runnable lambda)
@CheckReturnValue public static boolean isFirefox()
@CheckReturnValue public static boolean isChrome()
@CheckReturnValue public static boolean isIE()
@CheckReturnValue public static boolean isEdge()
@CheckReturnValue public static boolean isHeadless()
@CheckReturnValue public static boolean supportsJavascript()
@CheckReturnValue public static boolean isOpera()
public static void clearBrowserCache()
@CheckReturnValue @Nonnull public static java.lang.String source()
@CheckReturnValue @Nonnull public static java.lang.String url()
@CheckReturnValue @Nonnull public static java.lang.String currentFrameUrl()