Class Helpers
- java.lang.Object
-
- com.adobe.cq.testing.selenium.pagewidgets.Helpers
-
public final class Helpers extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidassertHasOpenedURL(java.lang.String url)static voidclickActionButton(java.lang.String buttonLabel)Clicks on a button based on its label.static <T extends BaseComponent>
TclickBaseComponentAction(ActionComponent<T> actionComponent)Clicks (by execution ActionComponent#perform) on a ActionComponent (representing i.e.static <T extends Dialog>
TclickDialogAction(ActionComponent<T> button)Clicks (by execution ActionComponent#perform) on a ActionComponent (representing a button) for which it's expected a dialog is opened and returns the dialog when opened.static <T extends Dialog>
TclickDialogAction(com.codeborne.selenide.SelenideElement button, T dialog)Clicks on a button for which it's expected a dialog is opened and returns the dialog when opened.static voiddragOnPage(com.codeborne.selenide.SelenideElement dragElement, com.codeborne.selenide.SelenideElement targetElement)Drad and drop an element to another elementstatic voidexecuteIfPresent(com.codeborne.selenide.SelenideElement element, long pacing, long maxRetries, java.lang.Runnable runnableCode)static org.openqa.selenium.CookiegetCookie(java.lang.String cookieName)static com.fasterxml.jackson.databind.JsonNodegetCookieValue(java.lang.String cookieName)static java.lang.StringgetExpectedURL(java.lang.String url)Rewrite provided url in case it is an adobeaemcloud URL depending on being on Unified Shell or not.static booleanisElementTopMost(java.lang.String selector)This method will evaluate if the element is top most on it's position (top,left) An element could be behind another element with another z-index and webdriver.io isVisible() will return true anyway With that helper method it's possible to identify if the element is visible to the user It will not consider partial overlays, the check is done at the top,left position.static booleanisUnifiedShellFrame()static java.util.List<java.lang.String>listOpenURLs()static voidremoveImpersonateCookie()static voidsetAffinityCookie(com.adobe.cq.testing.client.CQClient client)static voidsetAffinityCookie(java.lang.String affinity)static voidsetImpersonateCookie(java.lang.String impUser)static voidswitchToAemContentFrame()static booleanswitchToURL(java.lang.String expectedUrl)static booleanswitchToURL(java.lang.String expectedUrl, boolean disableExpectedURLRewriting)static voidwaitDocumentLoadCompleted()Await that the document load is fully completed.static voidwaitDOMIdled(long pollingInterval)Await that page source (DOM) isn't changed within consecutive polling interval.static voidwaitFirstContentPaint()Await until the window.performance metrics contains the First Content Paint.static booleanwaitForAlert(int timeout)Waits until alert is visible.static voidwaitForElementAnimationFinished(com.codeborne.selenide.SelenideElement target)static voidwaitForElementAnimationFinished(java.lang.String selector)Waits until animation for the element is finished.static booleanwaitForListSizeChange(int originalSize, com.codeborne.selenide.ElementsCollection list, int timeout)Waits for the change of the size of a list, i.e.static voidwaitForOpen()Waits till a coral-dialog is open.static booleanwaitIfPresentAtMost(com.codeborne.selenide.SelenideElement element, long pacing, long maxRetries)static voidwaitMetricsIdled(long pollingInterval, java.lang.String name)Await that number of window.performance metrics related name changed within consecutive polling interval.static voidwaitNetworkIdled(long pollingInterval)Await that all open network connections are completed within consecutive polling interval.
-
-
-
Method Detail
-
waitForAlert
public static boolean waitForAlert(int timeout)
Waits until alert is visible.- Parameters:
timeout- - timeout in milliseconds.- Returns:
- true if it has an alert.
-
waitForElementAnimationFinished
public static void waitForElementAnimationFinished(java.lang.String selector)
Waits until animation for the element is finished.- Parameters:
selector- The element sector
-
waitForElementAnimationFinished
public static void waitForElementAnimationFinished(com.codeborne.selenide.SelenideElement target)
- Parameters:
target- the element that is targeted.
-
listOpenURLs
public static java.util.List<java.lang.String> listOpenURLs()
- Returns:
- list of urls current opened in the controlled browser.
-
assertHasOpenedURL
public static void assertHasOpenedURL(java.lang.String url)
-
switchToURL
public static boolean switchToURL(java.lang.String expectedUrl, boolean disableExpectedURLRewriting)- Parameters:
expectedUrl- the pattern to find in the url.disableExpectedURLRewriting- to switch of Unified Shell rewriting if possible (i.e. publish URL).- Returns:
- true if switchTo the window with the given URL matcher happened.
-
switchToURL
public static boolean switchToURL(java.lang.String expectedUrl)
- Parameters:
expectedUrl- the pattern to find in the url.- Returns:
- true if switchTo the window with the given URL matcher happened.
-
getExpectedURL
public static java.lang.String getExpectedURL(java.lang.String url)
Rewrite provided url in case it is an adobeaemcloud URL depending on being on Unified Shell or not.- Parameters:
url- The URL to be adapted in case being on Unified Shell- Returns:
- The adpated URL
-
waitForOpen
public static void waitForOpen()
Waits till a coral-dialog is open.
-
clickActionButton
public static void clickActionButton(java.lang.String buttonLabel)
Clicks on a button based on its label.- Parameters:
buttonLabel- The label of the button
-
clickDialogAction
public static <T extends Dialog> T clickDialogAction(com.codeborne.selenide.SelenideElement button, T dialog)
Clicks on a button for which it's expected a dialog is opened and returns the dialog when opened.- Type Parameters:
T- type ofDialog- Parameters:
button- The button to click on and the dialog is expected to opendialog- The dialog that should be opened by button click- Returns:
- The provided dialog when it was opened by button click
-
clickDialogAction
public static <T extends Dialog> T clickDialogAction(ActionComponent<T> button)
Clicks (by execution ActionComponent#perform) on a ActionComponent (representing a button) for which it's expected a dialog is opened and returns the dialog when opened.- Type Parameters:
T- The dialog class extending Dialog that is expected to by click to the button- Parameters:
button- The ActionComponent representing the button to click on and the dialog is expected to open- Returns:
- The dialog provided for the ActionComponent instantiation when it was opened by button click
-
clickBaseComponentAction
public static <T extends BaseComponent> T clickBaseComponentAction(ActionComponent<T> actionComponent)
Clicks (by execution ActionComponent#perform) on a ActionComponent (representing i.e. a button) for which it's expected an object extending BaseComponent is returned and returns the object when visible.- Type Parameters:
T- The component class extending BaseComponent that is expected by click to the action component- Parameters:
actionComponent- The ActionComponent representing the component (i.e. button) to click on and the returning component is expected to be returned- Returns:
- The component provided for the ActionComponent instantiation when it was opened by action component click
-
waitForListSizeChange
public static boolean waitForListSizeChange(int originalSize, com.codeborne.selenide.ElementsCollection list, int timeout)Waits for the change of the size of a list, i.e. to get an indication if a filter result list was updated already- Parameters:
originalSize- : The size of the original listlist- : The list to be checked for size changetimeout- : The timeout to wait for- Returns:
- if the size of the list was changed within the timeout
-
dragOnPage
public static void dragOnPage(com.codeborne.selenide.SelenideElement dragElement, com.codeborne.selenide.SelenideElement targetElement)Drad and drop an element to another element- Parameters:
dragElement- : The SelenideElement to be draggedtargetElement- : The SelenideElement the dragElement should be dropped
-
isElementTopMost
public static boolean isElementTopMost(java.lang.String selector)
This method will evaluate if the element is top most on it's position (top,left) An element could be behind another element with another z-index and webdriver.io isVisible() will return true anyway With that helper method it's possible to identify if the element is visible to the user It will not consider partial overlays, the check is done at the top,left position.- Parameters:
selector- - CSS selector for the element to check- Returns:
- true if element is top most else false. If element is not existing false
-
waitFirstContentPaint
public static void waitFirstContentPaint()
Await until the window.performance metrics contains the First Content Paint.
-
waitNetworkIdled
public static void waitNetworkIdled(long pollingInterval)
Await that all open network connections are completed within consecutive polling interval.- Parameters:
pollingInterval- polling interval for idle detection.
-
waitDocumentLoadCompleted
public static void waitDocumentLoadCompleted()
Await that the document load is fully completed.
-
waitDOMIdled
public static void waitDOMIdled(long pollingInterval)
Await that page source (DOM) isn't changed within consecutive polling interval.- Parameters:
pollingInterval- polling interval for idle detection.
-
waitMetricsIdled
public static void waitMetricsIdled(long pollingInterval, java.lang.String name)Await that number of window.performance metrics related name changed within consecutive polling interval.- Parameters:
pollingInterval- polling interval for idle detection.name- marker name
-
setAffinityCookie
public static void setAffinityCookie(com.adobe.cq.testing.client.CQClient client)
-
setAffinityCookie
public static void setAffinityCookie(java.lang.String affinity)
- Parameters:
affinity- force to set the affinity cookie on the browser to match the client one.
-
getCookie
public static org.openqa.selenium.Cookie getCookie(java.lang.String cookieName)
-
getCookieValue
public static com.fasterxml.jackson.databind.JsonNode getCookieValue(java.lang.String cookieName)
-
setImpersonateCookie
public static void setImpersonateCookie(java.lang.String impUser)
-
removeImpersonateCookie
public static void removeImpersonateCookie()
-
switchToAemContentFrame
public static void switchToAemContentFrame()
-
isUnifiedShellFrame
public static boolean isUnifiedShellFrame()
-
waitIfPresentAtMost
public static boolean waitIfPresentAtMost(com.codeborne.selenide.SelenideElement element, long pacing, long maxRetries)
-
executeIfPresent
public static void executeIfPresent(com.codeborne.selenide.SelenideElement element, long pacing, long maxRetries, java.lang.Runnable runnableCode)
-
-