Package com.shaft.gui.browser
Class BrowserActions
java.lang.Object
com.shaft.driver.internal.FluentWebDriverAction
com.shaft.gui.browser.BrowserActions
-
Constructor Summary
ConstructorDescriptionBrowserActions
(DriverFactoryHelper helper) BrowserActions
(org.openqa.selenium.WebDriver driver) BrowserActions
(org.openqa.selenium.WebDriver driver, boolean isSilent) -
Method Summary
Modifier and TypeMethodDescriptionAdds a cookie to the current browsing context.and()
Attempts to capture a page snapshot archive in the format of a .mht file Works only for Chromium based driver instances For other driver types attempts to attach the current page source (for web) or accessibility tree (for mobile)Use this action to return a full page screenshot.captureScreenshot
(Screenshots type) Use this action to return a page screenshot.Use this action to return a page snapshot.Closes the current browser windowDeletes all the cookies of the current browsing context.deleteCookie
(String cookieName) Deletes the cookie data matching with the provided cookie name for the current browsing context.Resize the window to fill the current screenvoid
Set
<org.openqa.selenium.Cookie> Gets all cookies for the current browsing context.Returns the handle for currently active context.Returns a list of unique handles for all the currently open contexts.org.openqa.selenium.Cookie
Gets a cookie with a given name.getCookieDomain
(String cookieName) Gets the cookie domain.getCookiePath
(String cookieName) Gets the cookie path.getCookieValue
(String cookieName) Gets the cookie value.Gets the current page URL and returns it as a stringGets the current window title and returns it as a stringorg.openqa.selenium.html5.LocalStorage
Gets the current page source and returns it as a stringorg.openqa.selenium.html5.SessionStorage
Gets the current window handle and returns it as a stringReturns a list of unique handles for all the currently open windows.Gets the current window size and returns it as a stringGets the current window position and returns it as a stringGets the current window size and returns it as a stringGets the current window size and returns it as a stringintercept
(Predicate<org.openqa.selenium.remote.http.HttpRequest> requestPredicate, org.openqa.selenium.remote.http.HttpResponse mockedResponse) Maximizes current window size based on screen size minus 5%mock
(Predicate<org.openqa.selenium.remote.http.HttpRequest> requestPredicate, org.openqa.selenium.remote.http.HttpResponse mockedResponse) Navigates one step back from the browsers historyNavigates one step forward from the browsers historynavigateToURL
(String targetUrl) Navigates to targetUrl in case the current URL is different, else refreshes the current pagenavigateToURL
(String targetUrl, String targetUrlAfterRedirection) Navigates to targetUrl in case the current URL is different, else refreshes the current page.navigateToURL
(String targetUrl, org.openqa.selenium.WindowType windowType) navigateToURLWithBasicAuthentication
(String targetUrl, String username, String password, String targetUrlAfterAuthentication) Attempts to refresh the current pagesetContext
(String context) Switches focus to another contextsetWindowSize
(int width, int height) Resizes the current window size based on the provided width and heightswitchToWindow
(String nameOrHandle) Switches focus to another windowwaitUntilNumberOfWindowsToBe
(int numberOfWindows) waitUntilTitleContains
(String title) waitUntilTitleIs
(String title) waitUntilTitleNotContains
(String title) waitUntilUrlMatches
(String urlRegex) waitUntilUrlToBe
(String url) Methods inherited from class com.shaft.driver.internal.FluentWebDriverAction
alert, browser, element, initialize, initialize, initialize, initialize, performAlertAction, performBrowserAction, performElementAction, performTouchAction, touch, waitUntil
-
Constructor Details
-
BrowserActions
public BrowserActions() -
BrowserActions
public BrowserActions(org.openqa.selenium.WebDriver driver) -
BrowserActions
public BrowserActions(org.openqa.selenium.WebDriver driver, boolean isSilent) -
BrowserActions
-
-
Method Details
-
and
- Overrides:
and
in classFluentWebDriverAction
-
assertThat
-
verifyThat
-
capturePageSnapshot
Attempts to capture a page snapshot archive in the format of a .mht file Works only for Chromium based driver instances For other driver types attempts to attach the current page source (for web) or accessibility tree (for mobile)- Returns:
- a self-reference to be used to chain actions
-
getCurrentURL
Gets the current page URL and returns it as a string- Returns:
- the URL that's currently open in the current page
-
getCurrentWindowTitle
Gets the current window title and returns it as a string- Returns:
- the title of the current window
-
getPageSource
Gets the current page source and returns it as a string- Returns:
- the source of the current page
-
getWindowHandle
Gets the current window handle and returns it as a string- Returns:
- the window handle for the current window
-
getWindowPosition
Gets the current window position and returns it as a string- Returns:
- the position of the current window
-
getWindowSize
Gets the current window size and returns it as a string- Returns:
- the size of the current window
-
getWindowHeight
Gets the current window size and returns it as a string- Returns:
- the height of the current window
-
getWindowWidth
Gets the current window size and returns it as a string- Returns:
- the width of the current window
-
refreshCurrentPage
Attempts to refresh the current page- Returns:
- a self-reference to be used to chain actions
-
closeCurrentWindow
Closes the current browser window- Returns:
- a self-reference to be used to chain actions
-
maximizeWindow
Maximizes current window size based on screen size minus 5%- Returns:
- a self-reference to be used to chain actions
-
setWindowSize
Resizes the current window size based on the provided width and height- Parameters:
width
- the desired new width of the target windowheight
- the desired new height of the target window- Returns:
- a self-reference to be used to chain actions
-
getLocalStorage
public org.openqa.selenium.html5.LocalStorage getLocalStorage() -
getSessionStorage
public org.openqa.selenium.html5.SessionStorage getSessionStorage() -
mock
public BrowserActions mock(Predicate<org.openqa.selenium.remote.http.HttpRequest> requestPredicate, org.openqa.selenium.remote.http.HttpResponse mockedResponse) -
intercept
public BrowserActions intercept(Predicate<org.openqa.selenium.remote.http.HttpRequest> requestPredicate, org.openqa.selenium.remote.http.HttpResponse mockedResponse) -
fullScreenWindow
Resize the window to fill the current screen- Returns:
- a self-reference to be used to chain actions
-
switchToWindow
Switches focus to another window- Parameters:
nameOrHandle
- The name of the window or the handle as returned by ElementActions.getWindowHandle(WebDriver driver)- Returns:
- a self-reference to be used to chain actions
-
addCookie
Adds a cookie to the current browsing context.- Parameters:
key
- The cookie's namevalue
- The cookie's name- Returns:
- a self-reference to be used to chain actions
-
getCookie
Gets a cookie with a given name.- Parameters:
cookieName
- The cookie's name.- Returns:
- the cookie.
-
getAllCookies
Gets all cookies for the current browsing context.- Returns:
- A Set of cookies for the current browsing context.
-
getCookieDomain
Gets the cookie domain.- Parameters:
cookieName
- The cookie's name.- Returns:
- te cookie domain;
-
getCookieValue
Gets the cookie value.- Parameters:
cookieName
- The cookie's name.- Returns:
- the cookie value;
-
getCookiePath
Gets the cookie path.- Parameters:
cookieName
- The cookie's name.- Returns:
- the cookie path;
-
deleteCookie
Deletes the cookie data matching with the provided cookie name for the current browsing context.- Parameters:
cookieName
- The name of the cookie to delete.- Returns:
- a self-reference to be used to chain actions.
-
deleteAllCookies
Deletes all the cookies of the current browsing context.- Returns:
- a self-reference to be used to chain actions.
-
captureScreenshot
Use this action to return a full page screenshot. This is a synonym tocaptureScreenshot(Screenshots type)
if you pass `Screenshots.FULL`- Returns:
- a self-reference for chainable actions
-
captureScreenshot
Use this action to return a page screenshot. If you want to capture a screenshot then use this method instead- Parameters:
type
- can either be `Screenshots.FULL`, or `Screenshots.VIEWPORT`- Returns:
- a self-reference for chainable actions
-
captureSnapshot
Use this action to return a page snapshot. A page snapshot is a single .mht file that contains the full page DOM and any related assets to help you view the page as a whole. If you want to capture a screenshot then use this method instead @see FluentBrowserActions#captureScreenshot()- Returns:
- a self-reference for chainable actions
-
generateLightHouseReport
public void generateLightHouseReport() -
waitForLazyLoading
-
waitUntilTitleIs
-
waitUntilTitleContains
-
waitUntilTitleNotContains
-
waitUntilUrlContains
-
waitUntilUrlNotContains
-
waitUntilUrlToBe
-
waitUntilUrlNotToBe
-
waitUntilUrlMatches
-
waitUntilNumberOfWindowsToBe
-
getContext
Returns the handle for currently active context. This can be used to switch to this context at a later time.- Returns:
- The current context handle
-
setContext
Switches focus to another context- Parameters:
context
- The name of the context or the handle as returned by ElementActions.getContext(WebDriver driver)- Returns:
- a self-reference to be used to chain actions
-
getWindowHandles
Returns a list of unique handles for all the currently open windows. This can be used to switch to any of these windows at a later time.- Returns:
- list of window handles
-
getContextHandles
Returns a list of unique handles for all the currently open contexts. This can be used to switch to any of these contexts at a later time.- Returns:
- list of context handles
-