public class WebBrowser
extends org.openqa.selenium.support.events.EventFiringWebDriver
WebDriverEventListener for logging purposes.org.openqa.selenium.WebDriver.ImeHandler, org.openqa.selenium.WebDriver.Navigation, org.openqa.selenium.WebDriver.Options, org.openqa.selenium.WebDriver.TargetLocator, org.openqa.selenium.WebDriver.Timeouts, org.openqa.selenium.WebDriver.Window| Modifier and Type | Field and Description |
|---|---|
protected static org.slf4j.Logger |
LOG |
protected TasProperties |
properties |
| Constructor and Description |
|---|
WebBrowser(org.openqa.selenium.WebDriver driver,
TasProperties properties) |
| Modifier and Type | Method and Description |
|---|---|
WebBrowser |
authenticatedSession(org.apache.commons.httpclient.HttpState httpState)
Inject auth cookie in current session so you don't need to login with LoginPage
|
void |
cleanUpAuthenticatedSession()
This is working in combination with
#authenticateSession(String, String) |
void |
clickJS(org.openqa.selenium.WebElement elementToClick)
Click
WebElement with JavaScript command |
void |
closeWindowAcceptingModalDialog()
Closes the window opened leaving the browser session opened
|
void |
closeWindowAndSwitchBack()
Closes the newly created win and swithes back to main
|
void |
closeWindowAndSwitchBackParametrized(String windowToSwitchTo,
String windowToClose)
Closes the window and returns to selected window
|
void |
deleteCookie(org.openqa.selenium.Cookie cookie)
Delete cookie based on given cookie.
|
void |
deleteCookies()
Function to delete the cookies in the browser
|
void |
doubleClickOnElement(org.openqa.selenium.WebElement element)
Double click on an element
|
void |
dragAndDrop(org.openqa.selenium.WebElement source,
int x,
int y)
Drag web element by x,y coordinates
|
void |
dragAndDrop(org.openqa.selenium.WebElement source,
org.openqa.selenium.WebElement target)
Drag the source element and drop into target element.
|
void |
executeJavaScript(String command)
Execute Javascript command
|
void |
executeJavaScript(String command,
org.openqa.selenium.WebElement element)
Execute Javascript command with
WebElement |
List<org.openqa.selenium.WebElement> |
findDisplayedElementsFromLocator(org.openqa.selenium.By selector)
This function will return list of visible elements found with the specified selector
|
org.openqa.selenium.WebElement |
findFirstDisplayedElement(org.openqa.selenium.By locator)
This function will return 1st visible element found with the specified selector
|
org.openqa.selenium.WebElement |
findFirstElementWithExactValue(List<org.openqa.selenium.WebElement> list,
String value)
This function will return 1st element found with the exact specified value
|
org.openqa.selenium.WebElement |
findFirstElementWithValue(org.openqa.selenium.By locator,
String value)
This function will return 1st element found with a specified value
|
org.openqa.selenium.WebElement |
findFirstElementWithValue(List<org.openqa.selenium.WebElement> list,
String value)
This function will return 1st element found which contains a specified value
|
void |
focusOnWebElement(org.openqa.selenium.WebElement webElement) |
org.openqa.selenium.Cookie |
getCookie(String name)
Get a cookie that matches the name.
|
String |
getPreviousUrl()
Gets the URL of the previously visited page.
|
void |
handleModalDialogAcceptingAlert() |
void |
handleModalDialogDismissingAlert() |
boolean |
isAlertPresent() |
boolean |
isElementDisplayed(org.openqa.selenium.By locator)
Returns true if the element is displayed else false.
|
boolean |
isElementDisplayed(org.openqa.selenium.WebElement element)
Returns true if the element is displayed else false.
|
boolean |
isElementDisplayed(org.openqa.selenium.WebElement element,
org.openqa.selenium.By locator)
Returns true if the element is displayed else false.
|
boolean |
isOptionSelectedForFilter(String option,
org.openqa.selenium.WebElement filterElement) |
void |
maximize()
Maximizes the current window if it is not already maximized
|
void |
mouseOver(org.openqa.selenium.WebElement element)
Recreating the action of hovering over a particular HTML element on a
page.
|
void |
mouseOver(org.openqa.selenium.WebElement element,
int xOffset,
int yOffset)
Recreating the action of hovering over with offset coordinates a
particular HTML element on a page.
|
void |
refresh()
Acts as a refresh page action similar to F5 key.
|
void |
rightClickOnElement(org.openqa.selenium.WebElement element)
Right click on an element
|
void |
scrollIntoView(org.openqa.selenium.WebElement element)
Scroll to WebElement
|
void |
scrollToElement(org.openqa.selenium.WebElement element)
Scroll to WebElement
|
void |
selectOptionFromFilterOptionsList(String option,
List<org.openqa.selenium.WebElement> filterOptionsList)
This function selects specified filter option from filter options list
|
void |
switchToDefaultContent()
Method to switch back from i-frame to default content.
|
void |
switchToFrame(String frameId)
Method to switch on to frames of content object.
|
void |
switchToWindow(String windowHandle)
This method transfers the control to the specific window as per the given
window handle.
|
void |
switchWindow()
Switches to the newly created window.
|
void |
switchWindow(int windowIndex)
Waits and switches to window based on index
|
void |
switchWindow(String winHandler)
Switches to window with specified url.
|
void |
waitInSeconds(int seconds)
Method to wait for given seconds.
|
org.openqa.selenium.WebElement |
waitUntilChildElementIsPresent(org.openqa.selenium.By parentLocator,
org.openqa.selenium.By childLocator)
Wait for child WebElement as a part of parent element to present
|
org.openqa.selenium.WebElement |
waitUntilChildElementIsPresent(org.openqa.selenium.By parentLocator,
org.openqa.selenium.By childLocator,
long timeOutInSeconds)
Wait for child WebElement as a part of parent element to present
|
org.openqa.selenium.WebElement |
waitUntilChildElementIsPresent(org.openqa.selenium.WebElement parentLocator,
org.openqa.selenium.By childLocator)
Wait for child WebElement as a part of parent element to present
|
org.openqa.selenium.WebElement |
waitUntilChildElementIsPresent(org.openqa.selenium.WebElement parentLocator,
org.openqa.selenium.By childLocator,
long timeOutInSeconds)
Wait for child WebElement as a part of parent element to present
|
org.openqa.selenium.WebElement |
waitUntilElementClickable(org.openqa.selenium.By locator,
long timeOutInSeconds)
Wait until the Clickable of given Element for given seconds.
|
org.openqa.selenium.WebElement |
waitUntilElementClickable(org.openqa.selenium.WebElement element)
Wait until the Clickable of given Element for given seconds.
|
org.openqa.selenium.WebElement |
waitUntilElementClickable(org.openqa.selenium.WebElement element,
long timeOutInSeconds)
Wait until the Clickable of given Element for given seconds.
|
void |
waitUntilElementContainsText(org.openqa.selenium.WebElement element,
String text)
Wait until the given text is present in the given Element
|
void |
waitUntilElementDeletedFromDom(org.openqa.selenium.By locator)
Wait Until element successfully deleting from DOM.
|
void |
waitUntilElementDeletedFromDom(org.openqa.selenium.By locator,
long timeOutInSeconds)
Wait Until element successfully deleting from DOM.
|
void |
waitUntilElementDisappears(org.openqa.selenium.By locator)
Wait until the invisibility of given Element for given seconds.
|
void |
waitUntilElementDisappears(org.openqa.selenium.By locator,
long timeOutInSeconds)
Wait until the invisibility of given Element for given seconds.
|
void |
waitUntilElementDisappearsWithRetry(org.openqa.selenium.By locator,
int secondsToWait)
Wait the element to disappear by refreshing the page
|
void |
waitUntilElementDoesNotContainText(org.openqa.selenium.WebElement element,
String text)
Wait until the given text is not present in the given Element
|
void |
waitUntilElementHasAttribute(org.openqa.selenium.WebElement element,
String attribute,
String value)
Wait until the element has attribute for the specified amount of time.
|
void |
waitUntilElementIsDisplayedWithRetry(org.openqa.selenium.By locator)
Wait the element is displayed by refreshing the page
|
void |
waitUntilElementIsDisplayedWithRetry(org.openqa.selenium.By locator,
int secondsToWait)
Wait the element is displayed by refreshing the page
|
org.openqa.selenium.WebElement |
waitUntilElementIsPresent(org.openqa.selenium.By locator)
Wait until element is present on the DOM of a page.
|
org.openqa.selenium.WebElement |
waitUntilElementIsPresent(org.openqa.selenium.By locator,
long timeOutInSeconds)
Wait until element is present on the DOM of a page.
|
void |
waitUntilElementIsVisibleWithRetry(org.openqa.selenium.By locator,
int retryCount)
Wait until element is visible with retry
|
List<org.openqa.selenium.WebElement> |
waitUntilElementsVisible(org.openqa.selenium.By locator)
Helper method to find and return a slow loading collection of
WebElement. |
List<org.openqa.selenium.WebElement> |
waitUntilElementsVisible(List<org.openqa.selenium.WebElement> elements)
Helper method to find and return a slow loading collection of
WebElement. |
org.openqa.selenium.WebElement |
waitUntilElementVisible(org.openqa.selenium.By locator)
Wait until the element is visible for the specified amount of time.
|
org.openqa.selenium.WebElement |
waitUntilElementVisible(org.openqa.selenium.By locator,
long timeOutInSeconds)
Wait until the element is visible for the specified amount of time.
|
org.openqa.selenium.WebElement |
waitUntilElementVisible(org.openqa.selenium.WebElement element)
Wait until the element is visible for the specified amount of time.
|
org.openqa.selenium.WebElement |
waitUntilElementVisible(org.openqa.selenium.WebElement element,
long timeOutInSeconds)
Wait until the element is visible for the specified amount of time.
|
void |
waitUntilWebElementIsDisplayedWithRetry(org.openqa.selenium.WebElement webElement)
Wait until one element is displayed by refreshing the page
|
void |
waitUntilWebElementIsDisplayedWithRetry(org.openqa.selenium.WebElement webElement,
int secondsToWait)
Wait until one element is displayed by refreshing the page
|
void |
waitUrlContains(String URLfraction,
long timeOutInSeconds)
Wait until url contains the given URL fraction.
|
close, executeAsyncScript, executeScript, findElement, findElements, get, getCurrentUrl, getKeyboard, getMouse, getPageSource, getScreenshotAs, getTitle, getTouch, getWindowHandle, getWindowHandles, getWrappedDriver, manage, navigate, perform, quit, register, resetInputState, switchTo, unregisterprotected static final org.slf4j.Logger LOG
protected TasProperties properties
public WebBrowser(org.openqa.selenium.WebDriver driver,
TasProperties properties)
public WebBrowser authenticatedSession(org.apache.commons.httpclient.HttpState httpState)
public void cleanUpAuthenticatedSession()
#authenticateSession(String, String)public void mouseOver(org.openqa.selenium.WebElement element)
element - WebElement targetpublic void mouseOver(org.openqa.selenium.WebElement element,
int xOffset,
int yOffset)
element - WebElement targetpublic void refresh()
public void waitUntilElementHasAttribute(org.openqa.selenium.WebElement element,
String attribute,
String value)
element - public org.openqa.selenium.WebElement waitUntilElementVisible(org.openqa.selenium.By locator)
locator - By locatorpublic org.openqa.selenium.WebElement waitUntilElementVisible(org.openqa.selenium.By locator,
long timeOutInSeconds)
locator - By locatortimeOutInSeconds - timeout in secondspublic org.openqa.selenium.WebElement waitUntilElementIsPresent(org.openqa.selenium.By locator,
long timeOutInSeconds)
locator - By locatortimeOutInSeconds - seconds to waitWebElementpublic org.openqa.selenium.WebElement waitUntilElementIsPresent(org.openqa.selenium.By locator)
locator - By locatorWebElementpublic org.openqa.selenium.WebElement waitUntilChildElementIsPresent(org.openqa.selenium.By parentLocator,
org.openqa.selenium.By childLocator,
long timeOutInSeconds)
parentLocator - By parent locatorchildLocator - By child locatortimeOutInSeconds - seconds to waitWebElementpublic org.openqa.selenium.WebElement waitUntilChildElementIsPresent(org.openqa.selenium.By parentLocator,
org.openqa.selenium.By childLocator)
parentLocator - By parent locatorchildLocator - By child locatorWebElementpublic org.openqa.selenium.WebElement waitUntilChildElementIsPresent(org.openqa.selenium.WebElement parentLocator,
org.openqa.selenium.By childLocator,
long timeOutInSeconds)
parentLocator - WebElement parent locatorchildLocator - By child locatortimeOutInSeconds - seconds to waitWebElementpublic org.openqa.selenium.WebElement waitUntilChildElementIsPresent(org.openqa.selenium.WebElement parentLocator,
org.openqa.selenium.By childLocator)
parentLocator - WebElement parent locatorchildLocator - By child locatorWebElementpublic org.openqa.selenium.WebElement waitUntilElementVisible(org.openqa.selenium.WebElement element)
element - WebElement web elementpublic org.openqa.selenium.WebElement waitUntilElementVisible(org.openqa.selenium.WebElement element,
long timeOutInSeconds)
element - WebElement web elementtimeOutInSeconds - timeout in secondspublic List<org.openqa.selenium.WebElement> waitUntilElementsVisible(org.openqa.selenium.By locator)
WebElement.criteria - By search criteriaWebElement HTML elementspublic List<org.openqa.selenium.WebElement> waitUntilElementsVisible(List<org.openqa.selenium.WebElement> elements)
WebElement.elements - WebElement search criteriaWebElement HTML elementspublic void waitUntilElementIsDisplayedWithRetry(org.openqa.selenium.By locator)
locator - By querypublic void waitUntilElementIsDisplayedWithRetry(org.openqa.selenium.By locator,
int secondsToWait)
locator - By querysecondsToWait - public void waitUntilElementDisappearsWithRetry(org.openqa.selenium.By locator,
int secondsToWait)
locator - By querysecondsToWait - public void waitUntilWebElementIsDisplayedWithRetry(org.openqa.selenium.WebElement webElement)
webElement - public void waitUntilWebElementIsDisplayedWithRetry(org.openqa.selenium.WebElement webElement,
int secondsToWait)
webElement - secondsToWait - public org.openqa.selenium.WebElement waitUntilElementClickable(org.openqa.selenium.WebElement element)
element - WebElementpublic org.openqa.selenium.WebElement waitUntilElementClickable(org.openqa.selenium.By locator,
long timeOutInSeconds)
locator - CSS LocatortimeOutInSeconds - Timeout In Secondspublic org.openqa.selenium.WebElement waitUntilElementClickable(org.openqa.selenium.WebElement element,
long timeOutInSeconds)
element - WebElementtimeOutInSeconds - Timeout In Secondspublic void waitUntilElementContainsText(org.openqa.selenium.WebElement element,
String text)
element - WebElementpublic void waitUrlContains(String URLfraction, long timeOutInSeconds)
URLfraction - timeOutInSeconds - public void waitUntilElementDeletedFromDom(org.openqa.selenium.By locator)
locator - By locatorpublic void waitUntilElementDeletedFromDom(org.openqa.selenium.By locator,
long timeOutInSeconds)
locator - By locatortimeOutInSeconds - time to waitpublic void waitUntilElementDisappears(org.openqa.selenium.By locator)
locator - CSS Locatorpublic void waitUntilElementDisappears(org.openqa.selenium.By locator,
long timeOutInSeconds)
locator - By LocatortimeOutInSeconds - timeout In Secondspublic boolean isElementDisplayed(org.openqa.selenium.By locator)
locator - By querypublic boolean isElementDisplayed(org.openqa.selenium.WebElement element)
element - By querypublic boolean isElementDisplayed(org.openqa.selenium.WebElement element,
org.openqa.selenium.By locator)
locator - WebElement query
By querypublic String getPreviousUrl()
public void switchToFrame(String frameId)
frameId - String identifierpublic void switchToDefaultContent()
public void switchWindow()
public void switchWindow(int windowIndex)
public void switchWindow(String winHandler)
public void closeWindowAndSwitchBack()
public void closeWindowAndSwitchBackParametrized(String windowToSwitchTo, String windowToClose)
public void closeWindowAcceptingModalDialog()
public void switchToWindow(String windowHandle)
windowHandle - identifierpublic org.openqa.selenium.Cookie getCookie(String name)
name - String cookie identifierpublic void deleteCookies()
public void deleteCookie(org.openqa.selenium.Cookie cookie)
cookie - Cookie object to be deleted.public void maximize()
public void dragAndDrop(org.openqa.selenium.WebElement source,
org.openqa.selenium.WebElement target)
source - Source WebElementtarget - Target WebElementpublic void dragAndDrop(org.openqa.selenium.WebElement source,
int x,
int y)
source - html WebElementx - coordinatey - coordinatepublic void doubleClickOnElement(org.openqa.selenium.WebElement element)
element - WebElementpublic void rightClickOnElement(org.openqa.selenium.WebElement element)
element - WebElementpublic org.openqa.selenium.WebElement findFirstDisplayedElement(org.openqa.selenium.By locator)
locator - By selector typeWebElement element to interactpublic org.openqa.selenium.WebElement findFirstElementWithValue(org.openqa.selenium.By locator,
String value)
locator - By identifierList of WebElementpublic org.openqa.selenium.WebElement findFirstElementWithValue(List<org.openqa.selenium.WebElement> list, String value)
list - List identifierList of WebElementpublic org.openqa.selenium.WebElement findFirstElementWithExactValue(List<org.openqa.selenium.WebElement> list, String value)
list - value - public List<org.openqa.selenium.WebElement> findDisplayedElementsFromLocator(org.openqa.selenium.By selector)
selector - By identifierList of WebElementpublic void selectOptionFromFilterOptionsList(String option, List<org.openqa.selenium.WebElement> filterOptionsList)
option - Option to be selectedfilterOptionsList - The filter Option Listpublic boolean isOptionSelectedForFilter(String option, org.openqa.selenium.WebElement filterElement)
public void scrollToElement(org.openqa.selenium.WebElement element)
element - WebElementpublic void scrollIntoView(org.openqa.selenium.WebElement element)
element - WebElementpublic void waitInSeconds(int seconds)
seconds - time in secondspublic void executeJavaScript(String command)
command - public void executeJavaScript(String command, org.openqa.selenium.WebElement element)
WebElementcommand - element - WebElementpublic void clickJS(org.openqa.selenium.WebElement elementToClick)
WebElement with JavaScript commandelementToClick - public boolean isAlertPresent()
public void handleModalDialogAcceptingAlert()
public void handleModalDialogDismissingAlert()
public void focusOnWebElement(org.openqa.selenium.WebElement webElement)
public void waitUntilElementIsVisibleWithRetry(org.openqa.selenium.By locator,
int retryCount)
locator - retryCount - public void waitUntilElementDoesNotContainText(org.openqa.selenium.WebElement element,
String text)
element - WebElementCopyright © 2005–2019 Alfresco Software. All rights reserved.