Package com.anhtester.keywords
Class WebUI
java.lang.Object
com.anhtester.keywords.WebUI
Keyword WebUI is a generic class that is a preprocessed library with many custom functions from Selenium and Java.
Returns is a Class containing Static functions. Callback is used by taking the class name and dotting the function name (WebUI.method)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidClick Accept on Alertstatic voidaddScreenshotToReport(String screenName) Take entire-page screenshot and add to Extent report and Allure reportstatic voidcheckContainsValueOnTableByColumn(int column, String value) Check the value of each column of the table when searching according to the CONTAINS condition (contains)static voidcheckContainsValueOnTableByColumn(int column, String value, String xpathToTRtagname) Check the value of each column of the table when searching according to the CONTAINS condition with custom xpathstatic voidcheckEqualsValueOnTableByColumn(int column, String value) Check the value of each column of the table when searching according to EQUAL conditions (equals)static voidclearAndFillText(org.openqa.selenium.By by, String value) Clear all text of the element then set the text on that element.static voidclearText(org.openqa.selenium.By by) Clear all text of the element.static voidclearTextCtrlA(org.openqa.selenium.By by) Clear all text of the element with press Ctrl A > Deletestatic voidclickElement(org.openqa.selenium.By by) Click on the specified element.static voidclickElement(org.openqa.selenium.By by, int timeout) Click on element with timeoutstatic voidclickElementWithJs(org.openqa.selenium.By by) Click on Elements on the web with Javascript (click implicitly without fear of being hidden)static voidclickLinkText(String linkText) Click on the link on website with textstatic voidClose current Windowstatic intCount files in Download Directorystatic voiddeleteAllFileInDirectory(String pathDirectory) Delete all files in Download Directorystatic voidDelete all files in Download Directorystatic voidClick Dismiss on Alertstatic booleandragAndDrop(org.openqa.selenium.By fromElement, org.openqa.selenium.By toElement) Drag and drop an element onto another element.static booleandragAndDropHTML5(org.openqa.selenium.By fromElement, org.openqa.selenium.By toElement) Drag and drop an element onto another element.static booleandragAndDropToOffset(org.openqa.selenium.By fromElement, int X, int Y) Drag an object and drop it to an offset location.static StringgetAttributeElement(org.openqa.selenium.By by, String attributeName) Get the value from the element's attributestatic StringgetCssValueElement(org.openqa.selenium.By by, String cssName) Get CSS value of an elementstatic StringGet current URL from current driverstatic StringgetHTML5MessageField(org.openqa.selenium.By by) Get HTML5 message of elementstatic org.openqa.selenium.JavascriptExecutorGet the JavascriptExecutor object createdgetListElementsText(org.openqa.selenium.By by) Get list text of specified elementsstatic org.openqa.selenium.PointgetLocationElement(org.openqa.selenium.By by) Get location of specified elementstatic intgetOptionDynamicTotal(org.openqa.selenium.By objectListItem) Get total number of options the given web element has.static StringGet current web page's titlestatic StringGet the Download Directory pathstatic StringgetQRCodeFromImage(org.openqa.selenium.By by) Get code text of QR Code imagestatic org.openqa.selenium.DimensiongetSizeElement(org.openqa.selenium.By by) Get size of specified elementstatic StringgetTagNameElement(org.openqa.selenium.By by) Get tag name (HTML tag) of specified elementstatic StringGet text on Alertstatic StringgetTextElement(org.openqa.selenium.By by) Get text of an elementstatic voidgetToUrlAuthentication(String url, String username, String password) Login as Authentication on URLstatic ArrayListgetValueTableByColumn(int column) Get the value of a column from the tablestatic org.openqa.selenium.WebElementgetWebElement(org.openqa.selenium.By by) Convert the By object to the WebElementstatic List<org.openqa.selenium.WebElement>getWebElements(org.openqa.selenium.By by) Find multiple elements with the locator By objectstatic org.openqa.selenium.WebElementhighLightElement(org.openqa.selenium.By by) Fills the border color of the specified element.static booleanhoverOnElement(org.openqa.selenium.By by) Simulate users hovering a mouse over the given element.static booleanisElementVisible(org.openqa.selenium.By by, int timeout) Verify element is visible.static voidlogConsole(Object object) Print out the message in the Console logstatic voidMaximize windowstatic voidMinimize windowstatic booleanmouseHover(org.openqa.selenium.By by) Simulate users hovering a mouse over the given element.static booleanmoveToElement(org.openqa.selenium.By toElement) Move to the given element.static booleanmoveToOffset(int X, int Y) Move to an offset location.static voidnavigateToUrl(String URL) Navigate to the specified web page.static org.openqa.selenium.chrome.ChromeOptionsAllow browser popup notifications on the websitestatic org.openqa.selenium.chrome.ChromeOptionsBlock browser popup notifications on the websitestatic voidOpen new Tabstatic voidOpen new Windowstatic voidopenWebsite(String URL) Navigate to the specified URL.static StringprintPage(int endPage) Print the current page in the browser.static voidReload the current web page.static voidrightClickElement(org.openqa.selenium.By by) Right-click on the Element object on the webstatic voidscreenshotElement(org.openqa.selenium.By by, String elementName) Take a screenshot at the element location.static voidscrollToElementAtBottom(org.openqa.selenium.By by) Scroll an element into the visible area of the browser window.static voidscrollToElementAtBottom(org.openqa.selenium.WebElement webElement) Scroll an element into the visible area of the browser window.static voidscrollToElementAtTop(org.openqa.selenium.By by) Scroll an element into the visible area of the browser window.static voidscrollToElementAtTop(org.openqa.selenium.WebElement webElement) Scroll an element into the visible area of the browser window.static voidscrollToPosition(int X, int Y) Scroll to an offset locationstatic voidselectOptionByIndex(org.openqa.selenium.By by, int index) Select the options with the given index.static voidselectOptionByText(org.openqa.selenium.By by, String text) Select the options with the given label (displayed text).static voidselectOptionByValue(org.openqa.selenium.By by, String value) Select the options with the given value.static booleanselectOptionDynamic(org.openqa.selenium.By objectListItem, String text) Select value in dropdown dynamic (not pure Select Option)static voidsendKeys(org.openqa.selenium.By by, org.openqa.selenium.Keys keys) Simulates keystroke events on the specified element, as though you typed the value key-by-key.static voidsendKeys(org.openqa.selenium.Keys keys) Simulates keystroke events at the current position, as though you typed the value key-by-key.static voidSet the value of an input fieldstatic voidSet the value of an input field and press the key on the keyboardstatic voidsetTextAlert(String text) Set text on Alertstatic voidsetWindowPosition(int X, int Y) Move the window to the selected position X, Y from the top left corner 0static voidsetWindowSize(int widthPixel, int heightPixel) Set window sizes.static voidsleep(double second) Forced wait with unit of Secondsstatic voidSmart Waits contains waitForPageLoaded and sleep functionsstatic voidStop the Soft Assert of TestNGstatic voidSwitch to Default Contentstatic voidswitchToFrameByElement(org.openqa.selenium.By by) Switch to iframe by Element is this iframe tagstatic voidswitchToFrameByIdOrName(String IdOrName) Switch to iframe by ID or Name of iframe tagstatic voidswitchToFrameByIndex(int index) Switch to iframe by index of iframe tagstatic voidSwitch to Last Windowstatic voidSwitch to Main Windowstatic voidswitchToMainWindow(String originalWindow) Switch to Main Window by IDstatic voidswitchToWindowOrTabByPosition(int position) Switch to iframe by position of iframe tagstatic voidswitchToWindowOrTabByTitle(String title) Switch to popup window by titlestatic voidSwitch to popup window by URLstatic voidtakeElementScreenshot(org.openqa.selenium.By by, String screenName) Take a screenshot of a specific web element.static voidtakeFullPageScreenshot(String screenName) Take entire-page screenshot, including overflow parts.static voiduploadFileWithLocalForm(org.openqa.selenium.By by, String filePath) Uploading files with a click shows a form to select local files on your computerstatic voiduploadFileWithSendKeys(org.openqa.selenium.By by, String filePath) Upload files by dragging the link directly into the input boxstatic booleanverifyAlertPresent(int timeOut) Verify if alert does presentstatic booleanverifyContains(String value1, String value2) Verify if the first object contains the second object.static booleanverifyContains(String value1, String value2, String message) Verify if the first object contains the second object.static booleanverifyDownloadFileContainsName(String fileName, int timeoutSeconds) Verify the file is downloaded (CONTAIN)static booleanverifyDownloadFileEqualsName(String fileName, int timeoutSeconds) Verify the file is downloaded (EQUALS)static booleanverifyElementAttributeValue(org.openqa.selenium.By by, String attributeName, String attributeValue) Verify if the web element has an attribute with the specified name and value.static booleanverifyElementChecked(org.openqa.selenium.By by) Verify if the given web element is checked.static booleanverifyElementChecked(org.openqa.selenium.By by, String message) Verify if the given web element is checked.static booleanverifyElementClickable(org.openqa.selenium.By by) Verify if the given element is clickable.static booleanverifyElementClickable(org.openqa.selenium.By by, int timeout) Verify if the given element is clickable.static booleanverifyElementClickable(org.openqa.selenium.By by, int timeout, String message) Verify if the given element is clickable.static booleanverifyElementExists(org.openqa.selenium.By by) Verify if a web element is present (findElements.size > 0).static booleanverifyElementHasAttribute(org.openqa.selenium.By by, String attributeName, int timeOut) Verify if the web element has an attribute with the specified name.static booleanverifyElementNotPresent(org.openqa.selenium.By by) Verify if the given web element does NOT present on the DOM.static booleanverifyElementNotPresent(org.openqa.selenium.By by, int timeout) Verify if the given web element does NOT present on the DOM.static booleanverifyElementNotPresent(org.openqa.selenium.By by, int timeout, String message) Verify if the given web element does NOT present on the DOM.static booleanverifyElementNotPresent(org.openqa.selenium.By by, String message) Verify if the given web element does NOT present on the DOM.static booleanverifyElementNotVisible(org.openqa.selenium.By by) Verify if the given web element is NOT visible.static booleanverifyElementNotVisible(org.openqa.selenium.By by, int timeout) Verify if the given web element is NOT visible.static booleanverifyElementNotVisible(org.openqa.selenium.By by, int timeout, String message) Verify if the given web element is NOT visible.static booleanverifyElementNotVisible(org.openqa.selenium.By by, String message) Verify if the given web element is NOT visible.static booleanverifyElementPresent(org.openqa.selenium.By by) Verify if the given web element does present on DOM.static booleanverifyElementPresent(org.openqa.selenium.By by, int timeout) Verify if the given web element does present on DOM.static booleanverifyElementPresent(org.openqa.selenium.By by, int timeout, String message) Verify if the given web element does present on DOM.static booleanverifyElementPresent(org.openqa.selenium.By by, String message) Verify if the given web element does present on DOM.static booleanverifyElementText(org.openqa.selenium.By by, String text) Verify text of an element.static booleanverifyElementTextContains(org.openqa.selenium.By by, String text) Verify text of an element.static booleanverifyElementTextContains(org.openqa.selenium.By by, String text, FailureHandling flowControl) Verify text of an element.static booleanverifyElementTextEquals(org.openqa.selenium.By by, String text) Verify text of an element.static booleanverifyElementTextEquals(org.openqa.selenium.By by, String text, FailureHandling flowControl) Verify text of an element.static booleanverifyElementVisible(org.openqa.selenium.By by) Verify if the given web element is visible.static booleanverifyElementVisible(org.openqa.selenium.By by, int timeout) Verify if the given web element is visible.static booleanverifyElementVisible(org.openqa.selenium.By by, int timeout, String message) Verify if the given web element is visible.static booleanverifyElementVisible(org.openqa.selenium.By by, String message) Verify if the given web element is visible.static booleanverifyEquals(Object value1, Object value2) Verify if two object are equal.static booleanverifyEquals(Object value1, Object value2, String message) Verify if two object are equal.static booleanverifyFileContainsInDownloadDirectory(String fileName) Verify files in the Download Directory contain the specified file (CONTAIN)static booleanverifyFileDownloadedWithJS_Contains(String fileName) Verify the file is downloaded with JavascriptExecutor (CONTAINS)static booleanverifyFileDownloadedWithJS_Equals(String fileName) Verify the file is downloaded with JavascriptExecutor (EQUALS)static booleanverifyFileEqualsInDownloadDirectory(String fileName) Verify files in the Download Directory contain the specified file (EQUALS)static BooleanverifyHTML5RequiredField(org.openqa.selenium.By by) Verify HTML5 message of element required fieldstatic BooleanverifyHTML5ValidValueField(org.openqa.selenium.By by) Verify the HTML5 message of the element has a value of Validstatic booleanverifyOptionDynamicExist(org.openqa.selenium.By by, String text) Verify All Options contains the specified text (select option)static voidverifyOptionTotal(org.openqa.selenium.By by, int total) Verify the number of options equals the specified totalstatic booleanverifyPageContainsText(String text) Verify if the given text presents anywhere in the page source.static booleanVerifyPageTitle(String pageTitle) Verify the web page's title equals with the specified titlestatic booleanverifySelectedByIndex(org.openqa.selenium.By by, int index) Verify if the options at the given index are selected.static booleanverifySelectedByText(org.openqa.selenium.By by, String text) Verify if the options at the given text are selected.static booleanverifySelectedByValue(org.openqa.selenium.By by, String value) Verify if the options at the given value are selected.static booleanverifyTotalOfWindowsOrTab(int number) Get the total number of popup windows the given web page.static booleanverifyTrue(Boolean condition) Verify the condition is true.static booleanverifyTrue(Boolean condition, String message) Verify the condition is true.static booleanWait for an alert to present.static booleanwaitForAlertPresent(int timeOut) Wait for an alert to present.static voidWait for Angular to finish loading with default time from configstatic org.openqa.selenium.WebElementwaitForElementClickable(org.openqa.selenium.By by) Wait for the given element to be clickable.static org.openqa.selenium.WebElementwaitForElementClickable(org.openqa.selenium.By by, long timeOut) Wait for the given element to be clickable within the given time (in seconds).static booleanwaitForElementHasAttribute(org.openqa.selenium.By by, String attributeName) Wait until the given web element has an attribute with the specified name.static org.openqa.selenium.WebElementwaitForElementPresent(org.openqa.selenium.By by) Wait for the given element to presentstatic org.openqa.selenium.WebElementwaitForElementPresent(org.openqa.selenium.By by, long timeOut) Wait for the given element to present within the given time (in seconds).static org.openqa.selenium.WebElementwaitForElementVisible(org.openqa.selenium.By by) Wait until the given web element is visible.static org.openqa.selenium.WebElementwaitForElementVisible(org.openqa.selenium.By by, int timeOut) Wait until the given web element is visible within the timeout.static voidWait for JQuery to finish loading with default time from configstatic voidWait for a page to load with the default time from the configstatic voidwaitForPageLoaded(int timeOut) Wait for a page to load within the given time (in seconds)
-
Constructor Details
-
WebUI
public WebUI()
-
-
Method Details
-
stopSoftAssertAll
public static void stopSoftAssertAll()Stop the Soft Assert of TestNG -
smartWait
public static void smartWait()Smart Waits contains waitForPageLoaded and sleep functions -
addScreenshotToReport
Take entire-page screenshot and add to Extent report and Allure report- Parameters:
screenName- Screenshot name
-
takeElementScreenshot
Take a screenshot of a specific web element. The captured image will be saved in '.png' format.- Parameters:
screenName- Screenshot name
-
takeFullPageScreenshot
Take entire-page screenshot, including overflow parts. The captured image will be saved in '.png' format. This method simulates a scroll action to take a number of shots and merge them together to make a full-page screenshot.- Parameters:
screenName- Screenshot name
-
getPathDownloadDirectory
Get the Download Directory path- Returns:
- the download directory path
-
countFilesInDownloadDirectory
public static int countFilesInDownloadDirectory()Count files in Download Directory- Returns:
- files total in download directory
-
verifyFileContainsInDownloadDirectory
Verify files in the Download Directory contain the specified file (CONTAIN)- Parameters:
fileName- the specified file- Returns:
- true if file is contain in download directory, else is false
-
verifyFileEqualsInDownloadDirectory
Verify files in the Download Directory contain the specified file (EQUALS)- Parameters:
fileName- the specified file- Returns:
- true if file is contain in download directory, else is false
-
verifyDownloadFileContainsName
Verify the file is downloaded (CONTAIN)- Parameters:
fileName- the specified filetimeoutSeconds- System will wait at most timeout (seconds) to return result- Returns:
- true if file is downloaded, else is false
-
verifyDownloadFileEqualsName
Verify the file is downloaded (EQUALS)- Parameters:
fileName- the specified filetimeoutSeconds- System will wait at most timeout (seconds) to return result- Returns:
- true if file is downloaded, else is false
-
deleteAllFileInDownloadDirectory
public static void deleteAllFileInDownloadDirectory()Delete all files in Download Directory -
deleteAllFileInDirectory
Delete all files in Download Directory- Parameters:
pathDirectory- the Download Directory path
-
verifyFileDownloadedWithJS_Equals
@Step("Verify File Downloaded With JS [Equals]: {0}") public static boolean verifyFileDownloadedWithJS_Equals(String fileName) Verify the file is downloaded with JavascriptExecutor (EQUALS)- Parameters:
fileName- the specified file- Returns:
- true if file is downloaded, else is false
-
verifyFileDownloadedWithJS_Contains
@Step("Verify File Downloaded With JS [Contains]: {0}") public static boolean verifyFileDownloadedWithJS_Contains(String fileName) Verify the file is downloaded with JavascriptExecutor (CONTAINS)- Parameters:
fileName- the specified file- Returns:
- true if file is downloaded, else is false
-
getToUrlAuthentication
@Step("Get to URL {0} with authentication") public static void getToUrlAuthentication(String url, String username, String password) Login as Authentication on URL- Parameters:
url-username-password-
-
getQRCodeFromImage
@Step("Get QR code from image {0}") public static String getQRCodeFromImage(org.openqa.selenium.By by) Get code text of QR Code image- Parameters:
by- là an element of object type By- Returns:
- text of QR Code
-
verifyHTML5RequiredField
@Step("Verify HTML5 message of element {0} required field") public static Boolean verifyHTML5RequiredField(org.openqa.selenium.By by) Verify HTML5 message of element required field- Parameters:
by- is an element of type By- Returns:
- true/false corresponds to required
-
verifyHTML5ValidValueField
@Step("Verify HTML5 message of element {0} valid") public static Boolean verifyHTML5ValidValueField(org.openqa.selenium.By by) Verify the HTML5 message of the element has a value of Valid- Parameters:
by- is an element of type By- Returns:
- true/false corresponds to Valid
-
getHTML5MessageField
@Step("Get HTML5 message of element {0}") public static String getHTML5MessageField(org.openqa.selenium.By by) Get HTML5 message of element- Parameters:
by- is an element of type By- Returns:
- the Text string value of the notification (String)
-
setWindowSize
public static void setWindowSize(int widthPixel, int heightPixel) Set window sizes.- Parameters:
widthPixel- is Width with PixelheightPixel- is Height with Pixel
-
setWindowPosition
public static void setWindowPosition(int X, int Y) Move the window to the selected position X, Y from the top left corner 0- Parameters:
X- (int) - horizontalY- (int) - vertical
-
maximizeWindow
public static void maximizeWindow()Maximize window -
minimizeWindow
public static void minimizeWindow()Minimize window -
screenshotElement
Take a screenshot at the element location. Do not capture the entire screen.- Parameters:
by- is an element of type ByelementName- to name the .png image file
-
printPage
Print the current page in the browser. Note: Only works in headless mode- Parameters:
endPage- is the total number of pages to print. Adjective 1.- Returns:
- is content of page form PDF file
-
getJsExecutor
public static org.openqa.selenium.JavascriptExecutor getJsExecutor()Get the JavascriptExecutor object created- Returns:
- JavascriptExecutor
-
getWebElement
public static org.openqa.selenium.WebElement getWebElement(org.openqa.selenium.By by) Convert the By object to the WebElement- Parameters:
by- is an element of type By- Returns:
- Returns a WebElement object
-
getWebElements
Find multiple elements with the locator By object- Parameters:
by- is an element of type By- Returns:
- Returns a List of WebElement objects
-
logConsole
Print out the message in the Console log- Parameters:
object- passes any object
-
sleep
public static void sleep(double second) Forced wait with unit of Seconds- Parameters:
second- is a positive integer corresponding to the number of Seconds
-
notificationsAllow
@Step("Allow Notifications") public static org.openqa.selenium.chrome.ChromeOptions notificationsAllow()Allow browser popup notifications on the website- Returns:
- the value set Allow - belongs to the ChromeOptions object
-
notificationsBlock
@Step("Blocked Notifications") public static org.openqa.selenium.chrome.ChromeOptions notificationsBlock()Block browser popup notifications on the website- Returns:
- the value of the setup Block - belongs to the ChromeOptions object
-
uploadFileWithLocalForm
@Step("Upload File with open Local Form") public static void uploadFileWithLocalForm(org.openqa.selenium.By by, String filePath) Uploading files with a click shows a form to select local files on your computer- Parameters:
by- is an element of type ByfilePath- the absolute path to the file on your computer
-
uploadFileWithSendKeys
@Step("Upload File with SendKeys") public static void uploadFileWithSendKeys(org.openqa.selenium.By by, String filePath) Upload files by dragging the link directly into the input box- Parameters:
by- passes an element of object type ByfilePath- absolute path to the file
-
getCurrentUrl
Get current URL from current driver- Returns:
- the current URL as String
-
getPageTitle
Get current web page's title- Returns:
- the current URL as String
-
VerifyPageTitle
Verify the web page's title equals with the specified title- Parameters:
pageTitle- The title of the web page that needs verifying- Returns:
- the current URL as String
-
verifyPageContainsText
@Step("Verify Page sources Contains Text {0}") public static boolean verifyPageContainsText(String text) Verify if the given text presents anywhere in the page source.- Parameters:
text-- Returns:
- true/false
-
verifyElementChecked
@Step("Verify Element Checked {0}") public static boolean verifyElementChecked(org.openqa.selenium.By by) Verify if the given web element is checked.- Parameters:
by- Represent a web element as the By object- Returns:
- true if the element is checked, otherwise false.
-
verifyElementChecked
@Step("Verify Element Checked {0}") public static boolean verifyElementChecked(org.openqa.selenium.By by, String message) Verify if the given web element is checked.- Parameters:
by- Represent a web element as the By objectmessage- the custom message if false- Returns:
- true if the element is checked, otherwise false.
-
selectOptionDynamic
@Step("Select Option Dynamic by Text {0}") public static boolean selectOptionDynamic(org.openqa.selenium.By objectListItem, String text) Select value in dropdown dynamic (not pure Select Option)- Parameters:
objectListItem- is the locator of the list item as a By objecttext- the value to select as Text of the item- Returns:
- click to select a specified item with Text value
-
verifyOptionDynamicExist
@Step("Verify Option Dynamic Exist by Text {0}") public static boolean verifyOptionDynamicExist(org.openqa.selenium.By by, String text) Verify All Options contains the specified text (select option)- Parameters:
by- Represent a web element as the By objecttext- the specified text- Returns:
- true if all option contains the specified text
-
getOptionDynamicTotal
@Step("Get total of Option Dynamic with list element {0}") public static int getOptionDynamicTotal(org.openqa.selenium.By objectListItem) Get total number of options the given web element has. (select option)- Parameters:
objectListItem- Represent a web element as the By object- Returns:
- total number of options
-
selectOptionByText
@Step("Select Option by Text {0}") public static void selectOptionByText(org.openqa.selenium.By by, String text) Select the options with the given label (displayed text).- Parameters:
by- Represent a web element as the By objecttext- the specified text of option
-
selectOptionByValue
@Step("Select Option by Value {0}") public static void selectOptionByValue(org.openqa.selenium.By by, String value) Select the options with the given value.- Parameters:
by- Represent a web element as the By objectvalue- the specified value of option
-
selectOptionByIndex
@Step("Select Option by Index {0}") public static void selectOptionByIndex(org.openqa.selenium.By by, int index) Select the options with the given index.- Parameters:
by- Represent a web element as the By objectindex- the specified index of option
-
verifyOptionTotal
@Step("Verify Option Total equals {0}") public static void verifyOptionTotal(org.openqa.selenium.By by, int total) Verify the number of options equals the specified total- Parameters:
by- Represent a web element as the By objecttotal- the specified options total
-
verifySelectedByText
@Step("Verify Selected Option by Text {0}") public static boolean verifySelectedByText(org.openqa.selenium.By by, String text) Verify if the options at the given text are selected.- Parameters:
by- Represent a web element as the By objecttext- the specified options text- Returns:
- true if options given selected, else is false
-
verifySelectedByValue
@Step("Verify Selected Option by Value {0}") public static boolean verifySelectedByValue(org.openqa.selenium.By by, String value) Verify if the options at the given value are selected.- Parameters:
by- Represent a web element as the By objectvalue- the specified options value- Returns:
- true if options given selected, else is false
-
verifySelectedByIndex
@Step("Verify Selected Option by Index {0}") public static boolean verifySelectedByIndex(org.openqa.selenium.By by, int index) Verify if the options at the given index are selected.- Parameters:
by- Represent a web element as the By objectindex- the specified options index- Returns:
- true if options given selected, else is false
-
switchToFrameByIndex
@Step("Switch to Frame by Index: {0}") public static void switchToFrameByIndex(int index) Switch to iframe by index of iframe tag- Parameters:
index- index of iframe tag
-
switchToFrameByIdOrName
@Step("Switch to Frame by ID or Name: {0}") public static void switchToFrameByIdOrName(String IdOrName) Switch to iframe by ID or Name of iframe tag- Parameters:
IdOrName- ID or Name of iframe tag
-
switchToFrameByElement
@Step("Switch to Frame by Element {0}") public static void switchToFrameByElement(org.openqa.selenium.By by) Switch to iframe by Element is this iframe tag- Parameters:
by- iframe tag
-
switchToDefaultContent
@Step("Switch to Default Content") public static void switchToDefaultContent()Switch to Default Content -
switchToWindowOrTabByPosition
@Step("Switch to Window or Tab by Position: {0}") public static void switchToWindowOrTabByPosition(int position) Switch to iframe by position of iframe tag- Parameters:
position- index of iframe tag
-
switchToWindowOrTabByTitle
@Step("Switch to Window or Tab by Title: {0}") public static void switchToWindowOrTabByTitle(String title) Switch to popup window by title- Parameters:
title- title of popup window
-
switchToWindowOrTabByUrl
@Step("Switch to Window or Tab by Url: {0}") public static void switchToWindowOrTabByUrl(String url) Switch to popup window by URL- Parameters:
url- url of popup window
-
closeCurrentWindow
@Step("Close current Window") public static void closeCurrentWindow()Close current Window -
verifyTotalOfWindowsOrTab
@Step("Verify total of Windows or Tab") public static boolean verifyTotalOfWindowsOrTab(int number) Get the total number of popup windows the given web page.- Parameters:
number- the specified number- Returns:
- true/false
-
openNewTab
@Step("Open new Tab") public static void openNewTab()Open new Tab -
openNewWindow
@Step("Open new Window") public static void openNewWindow()Open new Window -
switchToMainWindow
@Step("Switch to Main Window") public static void switchToMainWindow()Switch to Main Window -
switchToMainWindow
@Step("Switch to Main Window by ID {0}") public static void switchToMainWindow(String originalWindow) Switch to Main Window by ID- Parameters:
originalWindow- ID of main window
-
switchToLastWindow
@Step("Switch to Last Window") public static void switchToLastWindow()Switch to Last Window -
acceptAlert
@Step("Click Accept on Alert") public static void acceptAlert()Click Accept on Alert -
dismissAlert
@Step("Click Dismiss on Alert") public static void dismissAlert()Click Dismiss on Alert -
getTextAlert
Get text on Alert -
setTextAlert
Set text on Alert -
verifyAlertPresent
@Step("Verify Alert present with timeout {0}") public static boolean verifyAlertPresent(int timeOut) Verify if alert does present- Parameters:
timeOut- Timeout waiting for alert to present.(in seconds)- Returns:
- true/false
-
getListElementsText
@Step("Get List Element {0}") public static List<String> getListElementsText(org.openqa.selenium.By by) Get list text of specified elements- Parameters:
by- Represent a web element as the By object- Returns:
- Text list of specified elements
-
verifyElementExists
@Step("Verify element exists {0}") public static boolean verifyElementExists(org.openqa.selenium.By by) Verify if a web element is present (findElements.size > 0).- Parameters:
by- Represent a web element as the By object- Returns:
- true/false
-
verifyEquals
@Step("Verify Equals: {0} ---AND--- {1}") public static boolean verifyEquals(Object value1, Object value2) Verify if two object are equal.- Parameters:
value1- The object onevalue2- The object two- Returns:
- true/false
-
verifyEquals
@Step("Verify Equals: {0} ---AND--- {1}") public static boolean verifyEquals(Object value1, Object value2, String message) Verify if two object are equal.- Parameters:
value1- The object onevalue2- The object twomessage- The custom message if false- Returns:
- true/false
-
verifyContains
@Step("Verify Contains: {0} ---AND--- {1}") public static boolean verifyContains(String value1, String value2) Verify if the first object contains the second object.- Parameters:
value1- The first objectvalue2- The second object- Returns:
- true/false
-
verifyContains
@Step("Verify Contains: {0} ---AND--- {1}") public static boolean verifyContains(String value1, String value2, String message) Verify if the first object contains the second object.- Parameters:
value1- The first objectvalue2- The second objectmessage- The custom message if false- Returns:
- true/false
-
verifyTrue
Verify the condition is true.- Returns:
- true/false
-
verifyTrue
@Step("Verify TRUE with condition: {0}") public static boolean verifyTrue(Boolean condition, String message) Verify the condition is true.- Parameters:
message- the custom message if false- Returns:
- true/false
-
verifyElementText
Verify text of an element. (equals)- Parameters:
by- Represent a web element as the By objecttext- Text of the element to verify.- Returns:
- true if the element has the desired text, otherwise false.
-
verifyElementTextEquals
@Step("Verify text of an element [Equals]") public static boolean verifyElementTextEquals(org.openqa.selenium.By by, String text, FailureHandling flowControl) Verify text of an element. (equals)- Parameters:
by- Represent a web element as the By objecttext- Text of the element to verify.flowControl- Specify failure handling schema (STOP_ON_FAILURE, CONTINUE_ON_FAILURE, OPTIONAL) to determine whether the execution should be allowed to continue or stop- Returns:
- true if the element has the desired text, otherwise false.
-
verifyElementTextEquals
@Step("Verify text of an element [Equals]") public static boolean verifyElementTextEquals(org.openqa.selenium.By by, String text) Verify text of an element. (equals)- Parameters:
by- Represent a web element as the By objecttext- Text of the element to verify.- Returns:
- true if the element has the desired text, otherwise false.
-
verifyElementTextContains
@Step("Verify text of an element [Contains]") public static boolean verifyElementTextContains(org.openqa.selenium.By by, String text, FailureHandling flowControl) Verify text of an element. (contains)- Parameters:
by- Represent a web element as the By objecttext- Text of the element to verify.flowControl- Specify failure handling schema (STOP_ON_FAILURE, CONTINUE_ON_FAILURE, OPTIONAL) to determine whether the execution should be allowed to continue or stop- Returns:
- true if the element has the desired text, otherwise false.
-
verifyElementTextContains
@Step("Verify text {1} of element [Contains] {0}") public static boolean verifyElementTextContains(org.openqa.selenium.By by, String text) Verify text of an element. (contains)- Parameters:
by- Represent a web element as the By objecttext- Text of the element to verify.- Returns:
- true if the element has the desired text, otherwise false.
-
verifyElementClickable
@Step("Verify element Clickable {0}") public static boolean verifyElementClickable(org.openqa.selenium.By by) Verify if the given element is clickable.- Parameters:
by- Represent a web element as the By object- Returns:
- true/false
-
verifyElementClickable
@Step("Verify element Clickable {0} with timeout {1} second") public static boolean verifyElementClickable(org.openqa.selenium.By by, int timeout) Verify if the given element is clickable. (in seconds)- Parameters:
by- Represent a web element as the By objecttimeout- System will wait at most timeout (seconds) to return result- Returns:
- true/false
-
verifyElementClickable
@Step("Verify element Clickable {0}") public static boolean verifyElementClickable(org.openqa.selenium.By by, int timeout, String message) Verify if the given element is clickable. (in seconds)- Parameters:
by- Represent a web element as the By objecttimeout- System will wait at most timeout (seconds) to return resultmessage- the custom message if false- Returns:
- true/false
-
verifyElementPresent
@Step("Verify element present {0}") public static boolean verifyElementPresent(org.openqa.selenium.By by) Verify if the given web element does present on DOM.- Parameters:
by- Represent a web element as the By object- Returns:
- true/false
-
verifyElementPresent
@Step("Verify element present {0} with timeout {1} second") public static boolean verifyElementPresent(org.openqa.selenium.By by, int timeout) Verify if the given web element does present on DOM. (in seconds)- Parameters:
by- Represent a web element as the By objecttimeout- System will wait at most timeout (seconds) to return result- Returns:
- true/false
-
verifyElementPresent
@Step("Verify element present {0}") public static boolean verifyElementPresent(org.openqa.selenium.By by, String message) Verify if the given web element does present on DOM.- Parameters:
by- Represent a web element as the By objectmessage- the custom message if false- Returns:
- true/false
-
verifyElementPresent
@Step("Verify element present {0} with timeout {1} second") public static boolean verifyElementPresent(org.openqa.selenium.By by, int timeout, String message) Verify if the given web element does present on DOM. (in seconds)- Parameters:
by- Represent a web element as the By objecttimeout- System will wait at most timeout (seconds) to return resultmessage- the custom message if false- Returns:
- true/false
-
verifyElementNotPresent
@Step("Verify element NOT present {0}") public static boolean verifyElementNotPresent(org.openqa.selenium.By by) Verify if the given web element does NOT present on the DOM.- Parameters:
by- Represent a web element as the By object- Returns:
- true/false
-
verifyElementNotPresent
@Step("Verify element NOT present {0} with timeout {1} second") public static boolean verifyElementNotPresent(org.openqa.selenium.By by, int timeout) Verify if the given web element does NOT present on the DOM. (in seconds)- Parameters:
by- Represent a web element as the By objecttimeout- System will wait at most timeout (seconds) to return result- Returns:
- true/false
-
verifyElementNotPresent
@Step("Verify element NOT present {0}") public static boolean verifyElementNotPresent(org.openqa.selenium.By by, String message) Verify if the given web element does NOT present on the DOM.- Parameters:
by- Represent a web element as the By objectmessage- the custom message if false- Returns:
- true/false
-
verifyElementNotPresent
@Step("Verify element NOT present {0} with timeout {1} second") public static boolean verifyElementNotPresent(org.openqa.selenium.By by, int timeout, String message) Verify if the given web element does NOT present on the DOM. (in seconds)- Parameters:
by- Represent a web element as the By objecttimeout- System will wait at most timeout (seconds) to return resultmessage- the custom message if false- Returns:
- true/false
-
isElementVisible
@Step("Verify element visible {0}") public static boolean isElementVisible(org.openqa.selenium.By by, int timeout) Verify element is visible. (in seconds)- Parameters:
by- Represent a web element as the By objecttimeout- System will wait at most timeout (seconds) to return result- Returns:
- true/false
-
verifyElementVisible
@Step("Verify element visible {0}") public static boolean verifyElementVisible(org.openqa.selenium.By by) Verify if the given web element is visible.- Parameters:
by- Represent a web element as the By object- Returns:
- true/false
-
verifyElementVisible
@Step("Verify element visible {0} with timeout {1} second") public static boolean verifyElementVisible(org.openqa.selenium.By by, int timeout) Verify if the given web element is visible. (in seconds)- Parameters:
by- Represent a web element as the By objecttimeout- System will wait at most timeout (seconds) to return result- Returns:
- true/false
-
verifyElementVisible
@Step("Verify element visible {0}") public static boolean verifyElementVisible(org.openqa.selenium.By by, String message) Verify if the given web element is visible.- Parameters:
by- Represent a web element as the By objectmessage- the custom message if false- Returns:
- true/false
-
verifyElementVisible
@Step("Verify element visible {0} with timeout {1} second") public static boolean verifyElementVisible(org.openqa.selenium.By by, int timeout, String message) Verify if the given web element is visible. (in seconds)- Parameters:
by- Represent a web element as the By objecttimeout- System will wait at most timeout (seconds) to return resultmessage- the custom message if false- Returns:
- true/false
-
verifyElementNotVisible
@Step("Verify element NOT visible {0}") public static boolean verifyElementNotVisible(org.openqa.selenium.By by) Verify if the given web element is NOT visible.- Parameters:
by- Represent a web element as the By object- Returns:
- true/false
-
verifyElementNotVisible
@Step("Verify element NOT visible {0} with timeout {1} second") public static boolean verifyElementNotVisible(org.openqa.selenium.By by, int timeout) Verify if the given web element is NOT visible. (in seconds)- Parameters:
by- Represent a web element as the By objecttimeout- System will wait at most timeout (seconds) to return result- Returns:
- true/false
-
verifyElementNotVisible
@Step("Verify element NOT visible {0}") public static boolean verifyElementNotVisible(org.openqa.selenium.By by, String message) Verify if the given web element is NOT visible.- Parameters:
by- Represent a web element as the By objectmessage- the custom message if false- Returns:
- true/false
-
verifyElementNotVisible
@Step("Verify element NOT visible {0} with timeout {1} second") public static boolean verifyElementNotVisible(org.openqa.selenium.By by, int timeout, String message) Verify if the given web element is NOT visible. (in seconds)- Parameters:
by- Represent a web element as the By objecttimeout- System will wait at most timeout (seconds) to return resultmessage- the custom message if false- Returns:
- true/false
-
scrollToElementAtTop
@Step("Scroll to element {0}") public static void scrollToElementAtTop(org.openqa.selenium.By by) Scroll an element into the visible area of the browser window. (at TOP)- Parameters:
by- Represent a web element as the By object
-
scrollToElementAtBottom
@Step("Scroll to element {0}") public static void scrollToElementAtBottom(org.openqa.selenium.By by) Scroll an element into the visible area of the browser window. (at BOTTOM)- Parameters:
by- Represent a web element as the By object
-
scrollToElementAtTop
@Step("Scroll to element {0}") public static void scrollToElementAtTop(org.openqa.selenium.WebElement webElement) Scroll an element into the visible area of the browser window. (at TOP)- Parameters:
webElement- Represent a web element as the By object
-
scrollToElementAtBottom
@Step("Scroll to element {0}") public static void scrollToElementAtBottom(org.openqa.selenium.WebElement webElement) Scroll an element into the visible area of the browser window. (at BOTTOM)- Parameters:
webElement- Represent a web element as the By object
-
scrollToPosition
@Step("Scroll to position X={0}, Y={1}") public static void scrollToPosition(int X, int Y) Scroll to an offset location- Parameters:
X- x offsetY- y offset
-
hoverOnElement
@Step("Hover on element {0}") public static boolean hoverOnElement(org.openqa.selenium.By by) Simulate users hovering a mouse over the given element.- Parameters:
by- Represent a web element as the By object- Returns:
- true/false
-
mouseHover
@Step("Mouse hover on element {0}") public static boolean mouseHover(org.openqa.selenium.By by) Simulate users hovering a mouse over the given element.- Parameters:
by- Represent a web element as the By object- Returns:
- true/false
-
dragAndDrop
@Step("Drag from element {0} to element {1}") public static boolean dragAndDrop(org.openqa.selenium.By fromElement, org.openqa.selenium.By toElement) Drag and drop an element onto another element.- Parameters:
fromElement- represent the drag-able elementtoElement- represent the drop-able element- Returns:
- true/false
-
dragAndDropHTML5
@Step("Drag HTML5 from element {0} to element {1}") public static boolean dragAndDropHTML5(org.openqa.selenium.By fromElement, org.openqa.selenium.By toElement) Drag and drop an element onto another element. (HTML5)- Parameters:
fromElement- represent the drag-able elementtoElement- represent the drop-able element- Returns:
- true/false
-
dragAndDropToOffset
@Step("Drag from element {0} to X={1}, Y={2}") public static boolean dragAndDropToOffset(org.openqa.selenium.By fromElement, int X, int Y) Drag an object and drop it to an offset location.- Parameters:
fromElement- represent the drag-able elementX- x offsetY- y offset- Returns:
- true/false
-
moveToElement
@Step("Move to element {0}") public static boolean moveToElement(org.openqa.selenium.By toElement) Move to the given element.- Parameters:
toElement- Represent a web element as the By object- Returns:
- true/false
-
moveToOffset
@Step("Move to offset X={0}, Y={1}") public static boolean moveToOffset(int X, int Y) Move to an offset location.- Parameters:
X- x offsetY- y offset- Returns:
- true/false
-
reloadPage
@Step("Reload page") public static void reloadPage()Reload the current web page. -
highLightElement
@Step("Highlight on element") public static org.openqa.selenium.WebElement highLightElement(org.openqa.selenium.By by) Fills the border color of the specified element.- Parameters:
by- passes the element object in the form By- Returns:
- Colors red borders for Elements on the website
-
openWebsite
Navigate to the specified URL.- Parameters:
URL- the specified url
-
setText
Set the value of an input field- Parameters:
by- an element of object type Byvalue- the value to fill in the text box
-
setText
@Step("Set text on text box and press key") public static void setText(org.openqa.selenium.By by, String value, org.openqa.selenium.Keys keys) Set the value of an input field and press the key on the keyboard- Parameters:
by- an element of object type Byvalue- the value to fill in the text boxkeys- key on the keyboard to press
-
sendKeys
@Step("Set text on text box and press key") public static void sendKeys(org.openqa.selenium.By by, org.openqa.selenium.Keys keys) Simulates keystroke events on the specified element, as though you typed the value key-by-key.- Parameters:
by- an element of object type Bykeys- key on the keyboard to press
-
sendKeys
@Step("Set text on text box and press key") public static void sendKeys(org.openqa.selenium.Keys keys) Simulates keystroke events at the current position, as though you typed the value key-by-key.- Parameters:
keys- key on the keyboard to press
-
clearText
@Step("Clear value in text box") public static void clearText(org.openqa.selenium.By by) Clear all text of the element.- Parameters:
by- an element of object type By
-
clearTextCtrlA
@Step("Clear text in text box with Ctrl A") public static void clearTextCtrlA(org.openqa.selenium.By by) Clear all text of the element with press Ctrl A > Delete- Parameters:
by- an element of object type By
-
clearAndFillText
@Step("Clear and Fill text on text box") public static void clearAndFillText(org.openqa.selenium.By by, String value) Clear all text of the element then set the text on that element.- Parameters:
by- an element of object type Byvalue- the value to fill in the text box
-
clickElement
@Step("Click on the element {0}") public static void clickElement(org.openqa.selenium.By by) Click on the specified element.- Parameters:
by- an element of object type By
-
clickElement
@Step("Click on the element {0} with timeout {1}s") public static void clickElement(org.openqa.selenium.By by, int timeout) Click on element with timeout- Parameters:
by- an element of object type By
-
clickElementWithJs
@Step("Click on the element by Javascript {0}") public static void clickElementWithJs(org.openqa.selenium.By by) Click on Elements on the web with Javascript (click implicitly without fear of being hidden)- Parameters:
by- an element of object type By
-
clickLinkText
Click on the link on website with text- Parameters:
linkText- is the visible text of a link
-
rightClickElement
@Step("Right click on element {0}") public static void rightClickElement(org.openqa.selenium.By by) Right-click on the Element object on the web- Parameters:
by- an element of object type By
-
getTextElement
Get text of an element- Parameters:
by- an element of object type By- Returns:
- text of a element
-
getAttributeElement
@Step("Get attribute {1} of element {0}") public static String getAttributeElement(org.openqa.selenium.By by, String attributeName) Get the value from the element's attribute- Parameters:
by- an element of object type ByattributeName- attribute name- Returns:
- element's attribute value
-
getCssValueElement
@Step("Get CSS value {1} of element {0}") public static String getCssValueElement(org.openqa.selenium.By by, String cssName) Get CSS value of an element- Parameters:
by- Represent a web element as the By objectcssName- is CSS attribute name- Returns:
- value of CSS attribute
-
getSizeElement
@Step("Get Size of element {0}") public static org.openqa.selenium.Dimension getSizeElement(org.openqa.selenium.By by) Get size of specified element- Parameters:
by- Represent a web element as the By object- Returns:
- Dimension
-
getLocationElement
@Step("Get Location of element {0}") public static org.openqa.selenium.Point getLocationElement(org.openqa.selenium.By by) Get location of specified element- Parameters:
by- Represent a web element as the By object- Returns:
- Point
-
getTagNameElement
@Step("Get Tag Name of element {0}") public static String getTagNameElement(org.openqa.selenium.By by) Get tag name (HTML tag) of specified element- Parameters:
by- Represent a web element as the By object- Returns:
- Tag name as String
-
checkEqualsValueOnTableByColumn
@Step("Check data by EQUALS type after searching on the Table by Column.") public static void checkEqualsValueOnTableByColumn(int column, String value) Check the value of each column of the table when searching according to EQUAL conditions (equals)- Parameters:
column- column positionvalue- value to compare
-
checkContainsValueOnTableByColumn
@Step("Check data by CONTAINS type after searching on the Table by Column.") public static void checkContainsValueOnTableByColumn(int column, String value) Check the value of each column of the table when searching according to the CONTAINS condition (contains)- Parameters:
column- column positionvalue- value to compare
-
checkContainsValueOnTableByColumn
@Step("Check data by CONTAINS type after searching on the Table by Column.") public static void checkContainsValueOnTableByColumn(int column, String value, String xpathToTRtagname) Check the value of each column of the table when searching according to the CONTAINS condition with custom xpath- Parameters:
column- column positionvalue- value to comparexpathToTRtagname- xpath value up to TR tag
-
getValueTableByColumn
Get the value of a column from the table- Parameters:
column- column position- Returns:
- array of values of a column
-
waitForElementVisible
public static org.openqa.selenium.WebElement waitForElementVisible(org.openqa.selenium.By by, int timeOut) Wait until the given web element is visible within the timeout.- Parameters:
by- an element of object type BytimeOut- maximum timeout as second- Returns:
- a WebElement object ready to be visible
-
waitForElementVisible
public static org.openqa.selenium.WebElement waitForElementVisible(org.openqa.selenium.By by) Wait until the given web element is visible.- Parameters:
by- an element of object type By- Returns:
- a WebElement object ready to be visible
-
waitForElementClickable
public static org.openqa.selenium.WebElement waitForElementClickable(org.openqa.selenium.By by, long timeOut) Wait for the given element to be clickable within the given time (in seconds).- Parameters:
by- an element of object type BytimeOut- maximum timeout as seconds- Returns:
- a WebElement object ready to CLICK
-
waitForElementClickable
public static org.openqa.selenium.WebElement waitForElementClickable(org.openqa.selenium.By by) Wait for the given element to be clickable.- Parameters:
by- an element of object type By- Returns:
- a WebElement object ready to CLICK
-
waitForElementPresent
public static org.openqa.selenium.WebElement waitForElementPresent(org.openqa.selenium.By by, long timeOut) Wait for the given element to present within the given time (in seconds).- Parameters:
by- an element of object type BytimeOut- maximum timeout as seconds- Returns:
- an existing WebElement object
-
waitForElementPresent
public static org.openqa.selenium.WebElement waitForElementPresent(org.openqa.selenium.By by) Wait for the given element to present- Parameters:
by- an element of object type By- Returns:
- an existing WebElement object
-
waitForAlertPresent
public static boolean waitForAlertPresent()Wait for an alert to present. -
waitForAlertPresent
public static boolean waitForAlertPresent(int timeOut) Wait for an alert to present.- Parameters:
timeOut- Timeout waiting for an alert to present.
-
waitForElementHasAttribute
Wait until the given web element has an attribute with the specified name.- Parameters:
by- an element of object type ByattributeName- The name of the attribute to wait for.- Returns:
- true/false
-
verifyElementAttributeValue
@Step("Verify element {0} with attribute {1} has value is {2}") public static boolean verifyElementAttributeValue(org.openqa.selenium.By by, String attributeName, String attributeValue) Verify if the web element has an attribute with the specified name and value.- Parameters:
by- an element of object type ByattributeName- The name of the attribute to wait for.attributeValue- The value of attribute- Returns:
- true/false
-
verifyElementHasAttribute
@Step("Verify element {0} has attribute {1} with timeout {2} second") public static boolean verifyElementHasAttribute(org.openqa.selenium.By by, String attributeName, int timeOut) Verify if the web element has an attribute with the specified name.- Parameters:
by- Represent a web element.attributeName- The name of the attribute to wait for.timeOut- System will wait at most timeout (seconds) to return result- Returns:
- true/false
-
waitForPageLoaded
public static void waitForPageLoaded()Wait for a page to load with the default time from the config -
waitForPageLoaded
public static void waitForPageLoaded(int timeOut) Wait for a page to load within the given time (in seconds) -
waitForJQueryLoad
public static void waitForJQueryLoad()Wait for JQuery to finish loading with default time from config -
waitForAngularLoad
public static void waitForAngularLoad()Wait for Angular to finish loading with default time from config
-