Package io.github.the_sdet.web
Class SeleniumUtils
java.lang.Object
io.github.the_sdet.web.Utils
io.github.the_sdet.web.SeleniumUtils
- Direct Known Subclasses:
AppiumUtils
Utility class for Selenium-based web automation tasks. This class provides
various methods to interact with web elements, take screenshots, handle
timeouts, and perform other common actions using the Selenium WebDriver API.
- Author:
- Pabitra Swain ([email protected])
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.openqa.selenium.WebDriverThe WebDriver instance used for web automation. -
Constructor Summary
ConstructorsConstructorDescriptionSeleniumUtils(org.openqa.selenium.WebDriver driver) Constructor to initialize SeleniumUtils. -
Method Summary
Modifier and TypeMethodDescriptionvoidclearAndEnterText(String xpath, String text) Clears the existing text and enters the specified text into the element identified by the given XPath.voidclearAndEnterText(org.openqa.selenium.By element, String text) Clears the existing text and enters the specified text into the element identified by the given XPath.voidClicks on the element identified by the given XPath.voidclick(org.openqa.selenium.By element) Clicks on the element identified by the given By selector.voidclick(org.openqa.selenium.WebElement element) Clicks on the specified WebElement.voidEnters the specified text into the element identified by the given XPath.voidEnters the specified text into the element identified by the given XPath.voidEnters value on to element identified by the specified XPathvoidEnters value on to element identified by the specified XPathorg.openqa.selenium.WebElementfindElementByCustomizeXpath(String rawXpath, String value) Finds the element using the customized XPath with one parameter.org.openqa.selenium.WebElementfindElementByCustomizeXpath(String rawXpath, String value1, String value2) Finds the element using the customized XPath with two parameters.org.openqa.selenium.WebElementfindElementByCustomizeXpath(String rawXpath, String value1, String value2, String value3) Finds the element using the customized XPath with three parameters.voidfocusOnElement(String xpath) Focuses on the element identified by the given XPath.voidfocusOnElement(org.openqa.selenium.By element) Focuses on the element identified by the given XPath.getAttributeValue(String xpath, String attributeName) Retrieves the value of the specified attribute of the element identified by the given XPath.getAttributeValue(org.openqa.selenium.By element, String attributeName) Retrieves the value of the specified attribute of the element identified by the given XPath.org.openqa.selenium.WebElementgetElement(String xpath) Retrieves the WebElement by Xpath.org.openqa.selenium.WebElementgetElement(org.openqa.selenium.By element) Retrieves the WebElementorg.openqa.selenium.WebElementgetElementByText(String xpath, String textContent) Retrieves the WebElement by text content from a list of matching WebElementsorg.openqa.selenium.WebElementgetElementByText(org.openqa.selenium.By element, String textContent) Retrieves the WebElement by text content from a list of matching WebElementsList<org.openqa.selenium.WebElement>getElements(String xpath) Retrieves the WebElements by Xpath.List<org.openqa.selenium.WebElement>getElements(String xpath, boolean waitForFirstElement) Retrieves the WebElements by Xpath.List<org.openqa.selenium.WebElement>getElements(String xpath, boolean waitForFirstElement, Duration duration) Retrieves the WebElements by Xpath.List<org.openqa.selenium.WebElement>getElements(org.openqa.selenium.By element) Retrieves the WebElements by Xpath.List<org.openqa.selenium.WebElement>getElements(org.openqa.selenium.By element, boolean waitForFirstElement) Retrieves the WebElements by Xpath.List<org.openqa.selenium.WebElement>getElements(org.openqa.selenium.By element, boolean waitForFirstElement, Duration duration) Retrieves the WebElements by Xpath.getElementScreenshot(String xpath) Retrieves a screenshot of the specified element.getElementScreenshot(org.openqa.selenium.By element) Retrieves a screenshot of the specified element.Retrieves the screenshot of the element identified by the given XPath as a Base64 encoded string.getElementScreenshotAsBase64(org.openqa.selenium.By element) Retrieves the screenshot of the element identified by the given XPath as a Base64 encoded string.byte[]getElementScreenshotAsByte(String xpath) Retrieves the screenshot of the element identified by the given XPath as a byte array.byte[]getElementScreenshotAsByte(org.openqa.selenium.By element) Retrieves the screenshot of the element identified by the given XPath as a byte array.getElementsTextContent(String xpath) Retrieves the text content of WebElements by Xpath.getElementsTextContent(String xpath, boolean waitForFirstElement) Retrieves the text content of WebElements by Xpath.getElementsTextContent(String xpath, boolean waitForFirstElement, Duration duration) Retrieves the text content of WebElements by Xpath.getElementsTextContent(org.openqa.selenium.By element) Retrieves the text content of WebElements by Xpath.getElementsTextContent(org.openqa.selenium.By element, boolean waitForFirstElement) Retrieves the text content of WebElements by Xpath.getElementsTextContent(org.openqa.selenium.By element, boolean waitForFirstElement, Duration duration) Retrieves the text content of WebElements by Xpath.getElementTextContent(String xpath) Retrieves the text content of WebElement by Xpath.getElementTextContent(org.openqa.selenium.By element) Retrieves the text content of WebElement by Xpath.Retrieves the full-page screenshot as a Base64 encoded string.byte[]Retrieves the full-page screenshot as a byte array.Retrieves a screenshot of the current page.Retrieves the screenshot of the current page as a Base64 encoded string.byte[]Retrieves the screenshot of the current page as a byte array.voidhoverOverElement(String xpath) Hovers over the element identified by the given XPath.voidhoverOverElement(org.openqa.selenium.By element) Hovers over the element identified by the given XPath.booleanChecks if the element identified by XPath is visible.booleanisVisible(org.openqa.selenium.By locator) Checks if the element identified by the given locator is visible.voidjavaScriptClick(String xpath) Clicks on the element identified by the given XPath using JavaScript.voidjavaScriptClick(org.openqa.selenium.By element) Clicks on the element identified by the given XPath using JavaScript.voidjavaScriptFillText(String xpath, String value) Enters value on to element identified by the specified XPath using JavaScript.voidjavaScriptFillText(org.openqa.selenium.By element, String value) Enters value on to element identified by the specified XPath using JavaScript.voidMaximizes the browser window.voidOpens the specified URL in the browser.voidSimulates pressing the Enter key.voidpressEnterOnElement(String xpath) Simulates pressing the Enter key on the element identified by the given XPath.voidpressEnterOnElement(org.openqa.selenium.By element) Simulates pressing the Enter key on the element identified by the given XPath.voidpressTab()Simulates pressing the Tab key.voidpressTabOnElement(String xpath) Simulates pressing the Tab key on the element identified by the given XPath.voidpressTabOnElement(org.openqa.selenium.By element) Simulates pressing the Tab key on the element identified by the given XPath.booleanscrollAndClick(String xpath) Scrolls to the element and performs a click.booleanscrollAndClick(org.openqa.selenium.By element) Scrolls to the element and performs a click.voidscrollByPercent(double percentage) Scrolls the page by the specified percentage.voidscrollElementIntoToView(String xpath) Scrolls the element identified by the given XPath into view.voidscrollElementIntoToView(org.openqa.selenium.By element) Scrolls the element identified by the given XPath into view.voidsetDefaultTimeOut(Duration duration) Sets the default timeout for implicit waits.voidsetScreenSize(int width, int height) Sets the screen size to the specified width and height.voidtakeElementScreenshot(String xpath, String filepath) Takes a screenshot of the specified element and saves it to the specified filepath.voidtakeElementScreenshot(org.openqa.selenium.By element, String filepath) Takes a screenshot of the specified element and saves it to the specified filepath.Takes a full-page screenshot of the current page.voidtakeFullPageScreenshot(String filepath) Takes a full-page screenshot of the current page and saves it to the specified filepath.voidtakeScreenshot(String filepath) Takes a screenshot of the current page and saves it to the specified filepath.booleanwaitAndCheckElementHasText(String xpath, Duration timeout, String expectedText) Waits for a specific seconds for the element to have text.booleanwaitAndCheckElementHasText(org.openqa.selenium.By element, Duration timeout, String expectedText) Waits for a specific seconds for the element to have text.booleanwaitAndCheckIsAlertPresent(Duration timeout) Waits for a specific seconds for an alert to be present.booleanwaitAndCheckIsClickable(String xpath, Duration duration) Waits for the element identified by XPath to be clickable.booleanwaitAndCheckIsClickable(org.openqa.selenium.By element, Duration duration) Waits for the element identified by XPath to be clickable.booleanwaitAndCheckIsClickableEnhanced(String xpath, Duration timeout) Waits for a specific seconds for the element to be clickable using a custom condition.booleanwaitAndCheckIsClickableEnhanced(org.openqa.selenium.By element, Duration timeout) Waits for a specific seconds for the element to be clickable using a custom condition.booleanwaitAndCheckIsElementAttributeHasValue(String xpath, Duration timeout, String attributeName, String expectedValue) Waits for a specific seconds for the element's attribute to have a certain value.booleanwaitAndCheckIsElementAttributeHasValue(org.openqa.selenium.By element, Duration timeout, String attributeName, String expectedValue) Waits for a specific seconds for the element's attribute to have a certain value.booleanwaitAndCheckIsElementSelected(String xpath, Duration timeout) Waits for a specific seconds for the element to be selected.booleanwaitAndCheckIsElementSelected(org.openqa.selenium.By element, Duration timeout) Waits for a specific seconds for the element to be selected.booleanwaitAndCheckIsInVisible(String xpath, Duration duration) Waits for the element identified by XPath to become invisible.booleanwaitAndCheckIsInVisible(org.openqa.selenium.By element, Duration duration) Waits for the element identified by the given locator to become invisible.booleanwaitAndCheckIsPresent(String xpath, Duration timeout) Waits for a specific seconds for the element to be present in the DOM.booleanwaitAndCheckIsPresent(org.openqa.selenium.By element, Duration timeout) Waits for a specific seconds for the element to be present in the DOM.booleanwaitAndCheckIsVisible(String xpath, Duration duration) Waits for the element identified by XPath to be visible.booleanwaitAndCheckIsVisible(org.openqa.selenium.By element, Duration duration) Waits for the element identified by XPath to be visible.booleanwaitAndCheckUrlContains(String expectedValue, Duration timeout) Waits for a specific seconds for the URL to contain the expected value.voidwaitAndClick(String xpath, Duration duration) Waits for the specified element to be clickable and then clicks on it.voidwaitAndClick(org.openqa.selenium.By element, int seconds) Waits for the specified element to be clickable and then clicks on it.org.openqa.selenium.WebElementwaitAndFindElement(String xpath) Waits for the element identified by XPath to be present within a default duration of 5 seconds.org.openqa.selenium.WebElementwaitAndFindElement(String xpath, Duration duration) Waits for the element identified by XPath to be present within a specified duration.org.openqa.selenium.WebElementwaitAndFindElement(org.openqa.selenium.By locator) Waits for the element identified by the given locator to be present within a default duration of 5 seconds.org.openqa.selenium.WebElementwaitAndFindElement(org.openqa.selenium.By locator, Duration duration) Waits for the element identified by the given locator to be present within a specified duration.voidPauses the execution for the specified duration.Methods inherited from class io.github.the_sdet.web.Utils
customizeXpath, customizeXpath, customizeXpath
-
Field Details
-
driver
protected org.openqa.selenium.WebDriver driverThe WebDriver instance used for web automation. This field holds the reference to the WebDriver object used by various utility methods in this class to perform web automation tasks.
-
-
Constructor Details
-
SeleniumUtils
public SeleniumUtils(org.openqa.selenium.WebDriver driver) Constructor to initialize SeleniumUtils.- Parameters:
driver- The WebDriver instance to use.
-
-
Method Details
-
openPage
Opens the specified URL in the browser.- Parameters:
url- The URL to open.
-
maximizeScreen
public void maximizeScreen()Maximizes the browser window. -
setScreenSize
public void setScreenSize(int width, int height) Sets the screen size to the specified width and height.- Parameters:
width- The width of the screen.height- The height of the screen.
-
click
Clicks on the element identified by the given XPath.- Parameters:
xpath- The XPath of the element to click.
-
fillText
Enters value on to element identified by the specified XPath- Parameters:
element- The locator of the elementvalue- Value to send
-
fillText
Enters value on to element identified by the specified XPath- Parameters:
xpath- The XPath of the elementvalue- Value to send
-
getElement
Retrieves the WebElement by Xpath.- Parameters:
xpath- The XPath of the element to retrieve.- Returns:
- The WebElement found.
-
getElement
public org.openqa.selenium.WebElement getElement(org.openqa.selenium.By element) Retrieves the WebElement- Parameters:
element- By object of element- Returns:
- The WebElement found.
-
getElementByText
Retrieves the WebElement by text content from a list of matching WebElements- Parameters:
xpath- Xpath of elementtextContent- text value to look for- Returns:
- The WebElement found.
-
getElementByText
public org.openqa.selenium.WebElement getElementByText(org.openqa.selenium.By element, String textContent) Retrieves the WebElement by text content from a list of matching WebElements- Parameters:
element- The locator of the elementtextContent- text value to look for- Returns:
- The WebElement found.
-
getElements
Retrieves the WebElements by Xpath.- Parameters:
xpath- The XPath of the element- Returns:
- The WebElements found as a list
-
getElements
Retrieves the WebElements by Xpath.- Parameters:
element- The locator of the element- Returns:
- The WebElements found as a list
-
getElements
Retrieves the WebElements by Xpath.- Parameters:
xpath- The XPath of the elementwaitForFirstElement- true if wait for first element- Returns:
- The WebElements found as a list
-
getElements
public List<org.openqa.selenium.WebElement> getElements(org.openqa.selenium.By element, boolean waitForFirstElement) Retrieves the WebElements by Xpath.- Parameters:
element- The locator of the elementwaitForFirstElement- true if wait for first element- Returns:
- The WebElements found as a list
-
getElements
public List<org.openqa.selenium.WebElement> getElements(String xpath, boolean waitForFirstElement, Duration duration) Retrieves the WebElements by Xpath.- Parameters:
xpath- The XPath of the elementwaitForFirstElement- true if wait for first elementduration- maximum wait- Returns:
- The WebElements found as a list
-
getElements
public List<org.openqa.selenium.WebElement> getElements(org.openqa.selenium.By element, boolean waitForFirstElement, Duration duration) Retrieves the WebElements by Xpath.- Parameters:
element- The locator of the elementwaitForFirstElement- true if wait for first elementduration- maximum wait- Returns:
- The WebElements found as a list
-
getElementTextContent
Retrieves the text content of WebElement by Xpath.- Parameters:
xpath- The XPath of the element- Returns:
- The text content of WebElement
-
getElementTextContent
Retrieves the text content of WebElement by Xpath.- Parameters:
element- The locator of the element- Returns:
- The text content of WebElement
-
getElementsTextContent
Retrieves the text content of WebElements by Xpath.- Parameters:
xpath- The XPath of the element- Returns:
- The text content of WebElements found as a list
-
getElementsTextContent
Retrieves the text content of WebElements by Xpath.- Parameters:
element- The locator of the element- Returns:
- The text content of WebElements found as a list
-
getElementsTextContent
Retrieves the text content of WebElements by Xpath.- Parameters:
xpath- The XPath of the elementwaitForFirstElement- true if wait for first element- Returns:
- The text content of WebElements found as a list
-
getElementsTextContent
public List<String> getElementsTextContent(org.openqa.selenium.By element, boolean waitForFirstElement) Retrieves the text content of WebElements by Xpath.- Parameters:
element- The locator of the elementwaitForFirstElement- true if wait for first element- Returns:
- The text content of WebElements found as a list
-
getElementsTextContent
public List<String> getElementsTextContent(String xpath, boolean waitForFirstElement, Duration duration) Retrieves the text content of WebElements by Xpath.- Parameters:
xpath- The XPath of the elementwaitForFirstElement- true if wait for first elementduration- maximum wait- Returns:
- The text content of WebElements found as a list
-
getElementsTextContent
public List<String> getElementsTextContent(org.openqa.selenium.By element, boolean waitForFirstElement, Duration duration) Retrieves the text content of WebElements by Xpath.- Parameters:
element- The locator of the elementwaitForFirstElement- true if wait for first elementduration- maximum wait- Returns:
- The text content of WebElements found as a list
-
click
public void click(org.openqa.selenium.WebElement element) Clicks on the specified WebElement.- Parameters:
element- The WebElement to click.
-
click
public void click(org.openqa.selenium.By element) Clicks on the element identified by the given By selector.- Parameters:
element- The By selector of the element to click.
-
javaScriptClick
Clicks on the element identified by the given XPath using JavaScript.- Parameters:
xpath- The XPath of the element to click.
-
javaScriptClick
public void javaScriptClick(org.openqa.selenium.By element) Clicks on the element identified by the given XPath using JavaScript.- Parameters:
element- The locator of the element to click.
-
javaScriptFillText
Enters value on to element identified by the specified XPath using JavaScript.- Parameters:
xpath- The XPath of the elementvalue- Value to send
-
javaScriptFillText
Enters value on to element identified by the specified XPath using JavaScript.- Parameters:
element- The locator of the elementvalue- Value to send
-
enterText
Enters the specified text into the element identified by the given XPath.- Parameters:
xpath- The XPath of the element.text- The text to enter.
-
enterText
Enters the specified text into the element identified by the given XPath.- Parameters:
element- The locator of the element.text- The text to enter.
-
getScreenshot
Retrieves a screenshot of the current page.- Returns:
- A File object representing the screenshot.
-
takeScreenshot
Takes a screenshot of the current page and saves it to the specified filepath.- Parameters:
filepath- The filepath where the screenshot should be saved.
-
getElementScreenshot
Retrieves a screenshot of the specified element.- Parameters:
xpath- The XPath of the element.- Returns:
- A File object representing the screenshot.
-
takeElementScreenshot
Takes a screenshot of the specified element and saves it to the specified filepath.- Parameters:
xpath- The XPath of the element.filepath- The filepath where the screenshot should be saved.
-
getElementScreenshot
Retrieves a screenshot of the specified element.- Parameters:
element- The locator of the element.- Returns:
- A File object representing the screenshot.
-
takeElementScreenshot
Takes a screenshot of the specified element and saves it to the specified filepath.- Parameters:
element- The locator of the element.filepath- The filepath where the screenshot should be saved.
-
takeFullPageScreenshot
Takes a full-page screenshot of the current page.- Returns:
- A File object representing the full-page screenshot.
-
takeFullPageScreenshot
Takes a full-page screenshot of the current page and saves it to the specified filepath.- Parameters:
filepath- The filepath where the screenshot should be saved.
-
getScreenshotAsBase64
Retrieves the screenshot of the current page as a Base64 encoded string.- Returns:
- The Base64 encoded string representation of the screenshot.
-
getElementScreenshotAsBase64
Retrieves the screenshot of the element identified by the given XPath as a Base64 encoded string.- Parameters:
xpath- The XPath of the element.- Returns:
- The Base64 encoded string representation of the screenshot.
-
getElementScreenshotAsBase64
Retrieves the screenshot of the element identified by the given XPath as a Base64 encoded string.- Parameters:
element- The locator of the element.- Returns:
- The Base64 encoded string representation of the screenshot.
-
getFullPageScreenshotAsBase64
Retrieves the full-page screenshot as a Base64 encoded string.- Returns:
- The Base64 encoded string representation of the full-page screenshot.
-
getScreenshotAsByte
public byte[] getScreenshotAsByte()Retrieves the screenshot of the current page as a byte array.- Returns:
- The byte array representing the screenshot.
-
getElementScreenshotAsByte
Retrieves the screenshot of the element identified by the given XPath as a byte array.- Parameters:
xpath- The XPath of the element.- Returns:
- The byte array representing the screenshot.
-
getElementScreenshotAsByte
public byte[] getElementScreenshotAsByte(org.openqa.selenium.By element) Retrieves the screenshot of the element identified by the given XPath as a byte array.- Parameters:
element- The locator of the element.- Returns:
- The byte array representing the screenshot.
-
getFullPageScreenshotAsByte
public byte[] getFullPageScreenshotAsByte()Retrieves the full-page screenshot as a byte array.- Returns:
- The byte array representing the full-page screenshot.
-
clearAndEnterText
Clears the existing text and enters the specified text into the element identified by the given XPath.- Parameters:
xpath- The XPath of the element.text- The text to enter.
-
clearAndEnterText
Clears the existing text and enters the specified text into the element identified by the given XPath.- Parameters:
element- The locator of the element.text- The text to enter.
-
waitAndClick
Waits for the specified element to be clickable and then clicks on it.- Parameters:
xpath- The XPath of the element to click.duration- The maximum time to wait for the element to be clickable, in seconds.
-
waitAndClick
public void waitAndClick(org.openqa.selenium.By element, int seconds) Waits for the specified element to be clickable and then clicks on it.- Parameters:
element- The locator of the element to click.seconds- The maximum time to wait for the element to be clickable, in seconds.
-
waitFor
Pauses the execution for the specified duration.- Parameters:
duration- wait duration.
-
setDefaultTimeOut
Sets the default timeout for implicit waits.- Parameters:
duration- The default timeout value, in seconds.
-
focusOnElement
Focuses on the element identified by the given XPath.- Parameters:
xpath- The XPath of the element to focus on.
-
focusOnElement
public void focusOnElement(org.openqa.selenium.By element) Focuses on the element identified by the given XPath.- Parameters:
element- The locator of the element to focus on.
-
hoverOverElement
public void hoverOverElement(org.openqa.selenium.By element) Hovers over the element identified by the given XPath.- Parameters:
element- The locator of the element to hover over.
-
hoverOverElement
Hovers over the element identified by the given XPath.- Parameters:
xpath- The XPath of the element to hover over.
-
pressTab
public void pressTab()Simulates pressing the Tab key. -
pressEnter
public void pressEnter()Simulates pressing the Enter key. -
pressTabOnElement
Simulates pressing the Tab key on the element identified by the given XPath.- Parameters:
xpath- The XPath of the element to press Tab on.
-
pressTabOnElement
public void pressTabOnElement(org.openqa.selenium.By element) Simulates pressing the Tab key on the element identified by the given XPath.- Parameters:
element- The locator of the element to press Tab on.
-
pressEnterOnElement
public void pressEnterOnElement(org.openqa.selenium.By element) Simulates pressing the Enter key on the element identified by the given XPath.- Parameters:
element- The locator of the element to press Enter on.
-
pressEnterOnElement
Simulates pressing the Enter key on the element identified by the given XPath.- Parameters:
xpath- The XPath of the element to press Enter on.
-
scrollElementIntoToView
Scrolls the element identified by the given XPath into view.- Parameters:
xpath- The XPath of the element to scroll into view.
-
scrollElementIntoToView
public void scrollElementIntoToView(org.openqa.selenium.By element) Scrolls the element identified by the given XPath into view.- Parameters:
element- The locator of the element to scroll into view.
-
scrollByPercent
public void scrollByPercent(double percentage) Scrolls the page by the specified percentage.- Parameters:
percentage- The percentage by which to scroll the page.
-
getAttributeValue
Retrieves the value of the specified attribute of the element identified by the given XPath.- Parameters:
xpath- The XPath of the element.attributeName- The name of the attribute.- Returns:
- The value of the attribute.
-
getAttributeValue
Retrieves the value of the specified attribute of the element identified by the given XPath.- Parameters:
element- The locator of the element.attributeName- The name of the attribute.- Returns:
- The value of the attribute.
-
findElementByCustomizeXpath
Finds the element using the customized XPath with one parameter.- Parameters:
rawXpath- The raw XPath pattern.value- The value to be replaced in the XPath.- Returns:
- The WebElement found.
-
findElementByCustomizeXpath
public org.openqa.selenium.WebElement findElementByCustomizeXpath(String rawXpath, String value1, String value2) Finds the element using the customized XPath with two parameters.- Parameters:
rawXpath- The raw XPath pattern.value1- The first value to be replaced in the XPath.value2- The second value to be replaced in the XPath.- Returns:
- The WebElement found.
-
findElementByCustomizeXpath
public org.openqa.selenium.WebElement findElementByCustomizeXpath(String rawXpath, String value1, String value2, String value3) Finds the element using the customized XPath with three parameters.- Parameters:
rawXpath- The raw XPath pattern.value1- The first value to be replaced in the XPath.value2- The second value to be replaced in the XPath.value3- The third value to be replaced in the XPath.- Returns:
- The WebElement found.
-
isVisible
Checks if the element identified by XPath is visible.- Parameters:
xpath- XPath identifying the element- Returns:
- true if the element is visible, false otherwise
-
isVisible
public boolean isVisible(org.openqa.selenium.By locator) Checks if the element identified by the given locator is visible.- Parameters:
locator- locator for identifying the element- Returns:
- true if the element is visible, false otherwise
-
waitAndCheckIsVisible
Waits for the element identified by XPath to be visible.- Parameters:
xpath- XPath identifying the elementduration- maximum duration to wait- Returns:
- true if the element becomes visible within the duration, false otherwise
-
waitAndCheckIsVisible
Waits for the element identified by XPath to be visible.- Parameters:
element- locator for identifying the elementduration- maximum duration to wait- Returns:
- true if the element becomes visible within the duration, false otherwise
-
waitAndCheckIsClickable
Waits for the element identified by XPath to be clickable.- Parameters:
xpath- XPath identifying the elementduration- maximum duration to wait- Returns:
- true if the element becomes clickable within the duration, false otherwise
-
waitAndCheckIsClickable
Waits for the element identified by XPath to be clickable.- Parameters:
element- locator for identifying the elementduration- maximum duration to wait- Returns:
- true if the element becomes clickable within the duration, false otherwise
-
waitAndCheckIsInVisible
Waits for the element identified by XPath to become invisible.- Parameters:
xpath- XPath identifying the elementduration- maximum duration to wait- Returns:
- true if the element becomes invisible within the duration, false otherwise
-
waitAndCheckIsInVisible
Waits for the element identified by the given locator to become invisible.- Parameters:
element- locator for identifying the elementduration- maximum duration to wait- Returns:
- true if the element becomes invisible within the duration, false otherwise
-
waitAndFindElement
Waits for the element identified by XPath to be present within a specified duration.- Parameters:
xpath- XPath identifying the elementduration- maximum duration to wait- Returns:
- WebElement representing the located element
-
waitAndFindElement
public org.openqa.selenium.WebElement waitAndFindElement(org.openqa.selenium.By locator, Duration duration) Waits for the element identified by the given locator to be present within a specified duration.- Parameters:
locator- locator for identifying the elementduration- maximum duration to wait- Returns:
- WebElement representing the located element
-
waitAndFindElement
Waits for the element identified by XPath to be present within a default duration of 5 seconds.- Parameters:
xpath- XPath identifying the element- Returns:
- WebElement representing the located element
-
waitAndFindElement
public org.openqa.selenium.WebElement waitAndFindElement(org.openqa.selenium.By locator) Waits for the element identified by the given locator to be present within a default duration of 5 seconds.- Parameters:
locator- locator for identifying the element- Returns:
- WebElement representing the located element
-
waitAndCheckElementHasText
public boolean waitAndCheckElementHasText(org.openqa.selenium.By element, Duration timeout, String expectedText) Waits for a specific seconds for the element to have text.- Parameters:
element- - By elementtimeout- - Duration timeoutexpectedText- - String expected text- Returns:
- boolean - true if element has expected text, false otherwise
-
waitAndCheckElementHasText
Waits for a specific seconds for the element to have text.- Parameters:
xpath- - Xpath of the Elementtimeout- - Duration timeoutexpectedText- - String expected text- Returns:
- boolean - true if element has expected text, false otherwise
-
waitAndCheckUrlContains
Waits for a specific seconds for the URL to contain the expected value.- Parameters:
expectedValue- - String expected URL valuetimeout- - Duration timeout- Returns:
- boolean - true if URL contains the expected value, false otherwise
-
waitAndCheckIsAlertPresent
Waits for a specific seconds for an alert to be present.- Parameters:
timeout- - Duration timeout- Returns:
- boolean - true if alert is present, false otherwise
-
waitAndCheckIsElementSelected
Waits for a specific seconds for the element to be selected.- Parameters:
element- - By elementtimeout- - Duration timeout- Returns:
- boolean - true if element is selected, false otherwise
-
waitAndCheckIsElementSelected
Waits for a specific seconds for the element to be selected.- Parameters:
xpath- - Xpath of the elementtimeout- - Duration timeout- Returns:
- boolean - true if element is selected, false otherwise
-
waitAndCheckIsElementAttributeHasValue
public boolean waitAndCheckIsElementAttributeHasValue(String xpath, Duration timeout, String attributeName, String expectedValue) Waits for a specific seconds for the element's attribute to have a certain value.- Parameters:
xpath- - Xpath of the elementtimeout- - durationattributeName- - String attribute nameexpectedValue- - String expected attribute value- Returns:
- boolean - true if the attribute has the expected value, false otherwise
-
waitAndCheckIsElementAttributeHasValue
public boolean waitAndCheckIsElementAttributeHasValue(org.openqa.selenium.By element, Duration timeout, String attributeName, String expectedValue) Waits for a specific seconds for the element's attribute to have a certain value.- Parameters:
element- - By elementtimeout- - durationattributeName- - String attribute nameexpectedValue- - String expected attribute value- Returns:
- boolean - true if the attribute has the expected value, false otherwise
-
waitAndCheckIsPresent
Waits for a specific seconds for the element to be present in the DOM.- Parameters:
xpath- - Xpath of the elementtimeout- - Duration timeout- Returns:
- boolean - true if element is present, false otherwise
-
waitAndCheckIsPresent
Waits for a specific seconds for the element to be present in the DOM.- Parameters:
element- - By elementtimeout- - Duration timeout- Returns:
- boolean - true if element is present, false otherwise
-
waitAndCheckIsClickableEnhanced
Waits for a specific seconds for the element to be clickable using a custom condition.- Parameters:
element- - By elementtimeout- - Duration timeout- Returns:
- boolean - true if the element is clickable, false otherwise
-
waitAndCheckIsClickableEnhanced
Waits for a specific seconds for the element to be clickable using a custom condition.- Parameters:
xpath- - Xpath of the elementtimeout- - Duration timeout- Returns:
- boolean - true if the element is clickable, false otherwise
-
scrollAndClick
public boolean scrollAndClick(org.openqa.selenium.By element) Scrolls to the element and performs a click.- Parameters:
element- - By element- Returns:
- boolean - true if the scroll and click were successful, false otherwise
-
scrollAndClick
Scrolls to the element and performs a click.- Parameters:
xpath- - Xpath of the element- Returns:
- boolean - true if the scroll and click were successful, false otherwise
-