Class WebDriverRunner
- java.lang.Object
-
- com.codeborne.selenide.WebDriverRunner
-
-
Field Summary
Fields Modifier and Type Field Description static WebDriverContainerwebdriverContainer
-
Constructor Summary
Constructors Constructor Description WebDriverRunner()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddListener(org.openqa.selenium.support.events.WebDriverEventListener listener)Use this method BEFORE opening a browser to add custom event listeners to webdriver.static voidclearBrowserCache()Delete all the browser cookiesstatic voidcloseWebDriver()Close the browser if it's openstatic java.lang.StringcurrentFrameUrl()static Driverdriver()static org.openqa.selenium.WebDrivergetAndCheckWebDriver()Get the underlying instance of Selenium WebDriver, and assert that it's still alive.static SelenideDrivergetSelenideDriver()static SelenideProxyServergetSelenideProxy()Get selenide proxy.static org.openqa.selenium.WebDrivergetWebDriver()Get the underlying instance of Selenium WebDriver.static booleanhasWebDriverStarted()static booleanisChrome()Is Selenide configured to use Chrome browserstatic booleanisEdge()Is Selenide configured to use Microsoft EDGE browserstatic booleanisFirefox()Is Selenide configured to use Firefox browserstatic booleanisHeadless()Is Selenide configured to use headless browser (HtmlUnit or PhantomJS)static booleanisHtmlUnit()Is Selenide configured to use HtmlUnit browserstatic booleanisIE()Is Selenide configured to use Internet Explorer browserstatic booleanisJBrowser()Is Selenide configured to use JBrowser browserstatic booleanisLegacyFirefox()Is Selenide configured to use legacy Firefox driverstatic booleanisOpera()Is Selenide configured to use Opera browserstatic booleanisPhantomjs()Is Selenide configured to use PhantomJS browserstatic booleanisSafari()Is Selenide configured to user Safari browserstatic voidsetProxy(org.openqa.selenium.Proxy webProxy)Sets Selenium Proxy instancestatic voidsetWebDriver(org.openqa.selenium.WebDriver webDriver)Tell Selenide use your provided WebDriver instance.static voidsetWebDriver(org.openqa.selenium.WebDriver webDriver, SelenideProxyServer selenideProxy)static java.lang.Stringsource()static booleansupportsJavascript()Does this browser support javascriptstatic booleansupportsModalDialogs()Does this browser support "alert" and "confirm" dialogs.static java.lang.Stringurl()
-
-
-
Field Detail
-
webdriverContainer
public static WebDriverContainer webdriverContainer
-
-
Method Detail
-
addListener
public static void addListener(org.openqa.selenium.support.events.WebDriverEventListener listener)
Use this method BEFORE opening a browser to add custom event listeners to webdriver.- Parameters:
listener- your listener of webdriver events
-
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, SelenideProxyServer selenideProxy)
-
getWebDriver
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(org.openqa.selenium.Proxy webProxy)
Sets Selenium Proxy instance
-
getAndCheckWebDriver
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
public static SelenideProxyServer getSelenideProxy()
Get selenide proxy. It's activated only if Configuration.proxyEnabled == true- Returns:
- null if proxy server is not started
-
getSelenideDriver
public static SelenideDriver getSelenideDriver()
-
driver
public static Driver driver()
-
closeWebDriver
public static void closeWebDriver()
Close the browser if it's open
-
hasWebDriverStarted
public static boolean hasWebDriverStarted()
- Returns:
- true if instance of Selenium WebDriver is started in current thread
-
isFirefox
public static boolean isFirefox()
Is Selenide configured to use Firefox browser
-
isLegacyFirefox
public static boolean isLegacyFirefox()
Is Selenide configured to use legacy Firefox driver
-
isChrome
public static boolean isChrome()
Is Selenide configured to use Chrome browser
-
isIE
public static boolean isIE()
Is Selenide configured to use Internet Explorer browser
-
isEdge
public static boolean isEdge()
Is Selenide configured to use Microsoft EDGE browser
-
isSafari
public static boolean isSafari()
Is Selenide configured to user Safari browser
-
isHeadless
public static boolean isHeadless()
Is Selenide configured to use headless browser (HtmlUnit or PhantomJS)
-
supportsModalDialogs
public static boolean supportsModalDialogs()
Does this browser support "alert" and "confirm" dialogs.
-
supportsJavascript
public static boolean supportsJavascript()
Does this browser support javascript
-
isHtmlUnit
public static boolean isHtmlUnit()
Is Selenide configured to use HtmlUnit browser
-
isPhantomjs
public static boolean isPhantomjs()
Is Selenide configured to use PhantomJS browser
-
isOpera
public static boolean isOpera()
Is Selenide configured to use Opera browser
-
isJBrowser
public static boolean isJBrowser()
Is Selenide configured to use JBrowser browser
-
clearBrowserCache
public static void clearBrowserCache()
Delete all the browser cookies
-
source
public static java.lang.String source()
- Returns:
- the source (HTML) of current page
-
url
public static java.lang.String url()
- Returns:
- the URL of current page
-
currentFrameUrl
public static java.lang.String currentFrameUrl()
- Returns:
- the URL of current frame
-
-