Class WebDriverUtils
- java.lang.Object
-
- eu.tsystems.mms.tic.testframework.utils.WebDriverUtils
-
public final class WebDriverUtils extends java.lang.ObjectProvides some utilities for handling the SeleniumWebDriver
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static org.openqa.selenium.WebElementfindElementByLocation(org.openqa.selenium.WebDriver driver, int x, int y)Finds an element by it's location using Selenium features and utilitiesstatic booleanfindWindowAndSwitchTo(java.lang.String windowTitle)Deprecated.UseIWebDriverManager.switchToWindow(Predicate)insteadstatic booleanfindWindowAndSwitchTo(java.lang.String windowTitle, java.lang.String urlContains, org.openqa.selenium.WebDriver driver, java.lang.String... excludeWindowHandles)Deprecated.UseIWebDriverManager.switchToWindow(Predicate)insteadstatic booleanfindWindowAndSwitchTo(java.lang.String windowTitle, org.openqa.selenium.WebDriver driver, java.lang.String... excludeWindowHandles)Deprecated.UseIWebDriverManager.switchToWindow(Predicate)insteadstatic org.openqa.selenium.WebDrivergetLowestWebDriver(org.openqa.selenium.WebDriver driver)Will search for the deepestWebDriverin the Wrapped-WebDriver-Chainstatic java.lang.StringgetSessionId(org.openqa.selenium.WebDriver driver)Deprecated.UseWebDriverSessionsManager.getSessionContext(WebDriver)instead // TODO Should be package privatestatic org.openqa.selenium.RectanglegetViewport(org.openqa.selenium.WebDriver webDriver)Deprecated.UseJSUtils.getViewport(WebDriver)insteadstatic WebDriverKeepAliveSequencekeepWebDriverAlive(org.openqa.selenium.WebDriver driver, int intervalSleepTimeInSeconds, int durationInSeconds)Initialize aWebDriverKeepAliveSequenceand runs it withTimerin given interval.static voidremoveKeepAliveForWebDriver(org.openqa.selenium.WebDriver driver)Removes an activeWebDriverKeepAliveSequenceif present.static booleanswitchToWindow(java.util.function.Predicate<org.openqa.selenium.WebDriver> predicate)static booleanswitchToWindow(org.openqa.selenium.WebDriver mainWebDriver, java.util.function.Predicate<org.openqa.selenium.WebDriver> predicate)
-
-
-
Method Detail
-
switchToWindow
public static boolean switchToWindow(java.util.function.Predicate<org.openqa.selenium.WebDriver> predicate)
-
switchToWindow
public static boolean switchToWindow(org.openqa.selenium.WebDriver mainWebDriver, java.util.function.Predicate<org.openqa.selenium.WebDriver> predicate)
-
findWindowAndSwitchTo
public static boolean findWindowAndSwitchTo(java.lang.String windowTitle)
Deprecated.UseIWebDriverManager.switchToWindow(Predicate)insteadFinds a window by matching title and will switch to it.- Parameters:
windowTitle-StringTitle of the window to switch to.- Returns:
- true if switching was successful.
-
findWindowAndSwitchTo
public static boolean findWindowAndSwitchTo(java.lang.String windowTitle, org.openqa.selenium.WebDriver driver, java.lang.String... excludeWindowHandles)Deprecated.UseIWebDriverManager.switchToWindow(Predicate)insteadFinds a window by matching title and will switch to it.- Parameters:
windowTitle-StringTitle of the window to switch to.driver-WebDriverobject or null (then the default session will be used)excludeWindowHandles-Stringarray of window handles that should not be switch to.- Returns:
- true if switching was successful.
-
findWindowAndSwitchTo
public static boolean findWindowAndSwitchTo(java.lang.String windowTitle, java.lang.String urlContains, org.openqa.selenium.WebDriver driver, java.lang.String... excludeWindowHandles)Deprecated.UseIWebDriverManager.switchToWindow(Predicate)insteadFinds a window by matching title and will switch to it.- Parameters:
windowTitle-StringTitle of the window to switch to.driver-WebDriverobject or null (then the default session will be used)excludeWindowHandles-Stringarray of window handles that should not be switch to.- Returns:
- true if switching was successful.
-
findElementByLocation
public static org.openqa.selenium.WebElement findElementByLocation(org.openqa.selenium.WebDriver driver, int x, int y)Finds an element by it's location using Selenium features and utilities- Parameters:
driver-WebDriverx- int - coordinatey- int - coordinate- Returns:
- org.openqa.selenium.WebElement
-
getLowestWebDriver
public static org.openqa.selenium.WebDriver getLowestWebDriver(org.openqa.selenium.WebDriver driver)
Will search for the deepestWebDriverin the Wrapped-WebDriver-Chain- Parameters:
driver-WebDriver- Returns:
- WebDriver
-
getSessionId
public static java.lang.String getSessionId(org.openqa.selenium.WebDriver driver)
Deprecated.UseWebDriverSessionsManager.getSessionContext(WebDriver)instead // TODO Should be package privateWill return Selenium session UUID ofWebDriversession- Parameters:
driver-WebDriver- Returns:
- String
-
getViewport
public static org.openqa.selenium.Rectangle getViewport(org.openqa.selenium.WebDriver webDriver)
Deprecated.UseJSUtils.getViewport(WebDriver)instead
-
keepWebDriverAlive
public static WebDriverKeepAliveSequence keepWebDriverAlive(org.openqa.selenium.WebDriver driver, int intervalSleepTimeInSeconds, int durationInSeconds)
Initialize aWebDriverKeepAliveSequenceand runs it withTimerin given interval. This will keep theWebDriveralive, when acting with another driver in same test or waiting for something to happen in main thread. NOTE: Please use this method with care AND clean up your Sequence by callingremoveKeepAliveForWebDriver(WebDriver)- Parameters:
driver-WebDriverintervalSleepTimeInSeconds- intdurationInSeconds- int- Returns:
- WebDriverKeepAliveSequence
-
removeKeepAliveForWebDriver
public static void removeKeepAliveForWebDriver(org.openqa.selenium.WebDriver driver)
Removes an activeWebDriverKeepAliveSequenceif present.- Parameters:
driver-WebDriverthe current driver
-
-