public class WebCommonMethods extends Object
Modifier and Type | Field and Description |
---|---|
static org.openqa.selenium.WebDriver |
driver
The driver.
|
static Robot |
robot
The robot.
|
static int |
sleepTimeAverage
The sleep time average.
|
static int |
sleepTimeAverage2
The sleep time average2.
|
static int |
sleepTimeMax
The sleep time max.
|
static int |
sleepTimeMax2
The sleep time max2.
|
static int |
sleepTimeMin
The sleep time min.
|
static int |
sleepTimeMin2
The sleep time min2.
|
Constructor and Description |
---|
WebCommonMethods(org.openqa.selenium.WebDriver driver)
Instantiates a new web common methods.
|
Modifier and Type | Method and Description |
---|---|
static void |
alertAccept()
accept Alert window popup.
|
static void |
alertDismiss()
dismiss Alert window popup.
|
static String |
alertGetText()
Get text from the Alert window popup.
|
static void |
checkItemNotPresentInDropdownItems(org.openqa.selenium.WebElement dropdown,
org.openqa.selenium.WebElement dropdownList,
org.openqa.selenium.By commonLocatorWithinLiTagForAllItems,
String itemName)
Check if item is not present in dropdown items.
|
static void |
deselectDropDown(org.openqa.selenium.WebElement element)
Deselect all items(if any) from drop down.
|
static void |
downloadPopupPreferenceForFirefox(String downloadDirectory)
Sets profile preference for Firefox browser to handle download file via OS window popup
|
static List<org.openqa.selenium.WebElement> |
getDropdownItems(org.openqa.selenium.WebElement element)
Gets the dropdown items.
|
static String |
getSelectedDropdownItem(org.openqa.selenium.WebElement element)
Gets the selected dropdown item.
|
static void |
implicitSleep()
Webdriver implicit sleep.
|
static void |
initializeSleepTimings()
Initialize all sleep timings variables.
|
static boolean |
isAttributeValuePresent(org.openqa.selenium.WebElement element,
String attribute)
Checks if attribute value is present and not null.
|
static boolean |
isElementPresent(org.openqa.selenium.WebDriver driver,
org.openqa.selenium.By by)
Checks if element is present on the current screen.
|
static boolean |
isElementPresent(org.openqa.selenium.WebElement element)
Checks if element is present on the current screen.
|
static int |
RetrieveHeadingTdValue(String excelCellTabNameHeadingsTdValue,
String excelCellTabNameUniqueHashValue)
Retrieve heading td value.
|
static int |
RetrieveHeadingTrValue(String headingClassName,
String orgCodeValue)
Retrieve heading tr value.
|
static void |
screenshot(String methodName)
Screenshot for Web Page.
Stored within "failure_Screenshot" folder with File name format: methodName_dd_MM_yyyy_hh_mm_ss.png Ex: loginCheck_28_10_2015_07_10_10.png |
static void |
selectDropdownByText(org.openqa.selenium.WebElement element,
String value)
Select dropdown by Text value.
|
static void |
selectDropdownItemBootStrap(org.openqa.selenium.WebElement dropdown,
String itemName)
Select dropdown item boot strap.
|
static void |
selectDropdownItemBootStrap(org.openqa.selenium.WebElement dropdown,
org.openqa.selenium.WebElement dropdownList,
org.openqa.selenium.By commonLocatorWithinLiTagForAllItems,
String itemName)
Select dropdown item boot strap.
|
static void |
setCheckBox(org.openqa.selenium.WebElement element,
String status)
Sets the check box.
|
static void |
setRadioButton(org.openqa.selenium.WebElement element,
String status)
Sets the radio button.
|
static Boolean |
toggleCheckBox(org.openqa.selenium.WebElement element)
Toggle check box.
|
static void |
waitForElementToBeClickable(org.openqa.selenium.WebElement element)
Waits for desired Seconds for the element to be Clickable.
|
static void |
waitForElementToBeSelected(org.openqa.selenium.WebElement element)
Waits for desired Seconds and then checks for the element to be Selected.
|
static void |
waitForInvisibilityOfWebElement(org.openqa.selenium.By locator)
Wait for invisibility of web element in the page
|
static void |
waitForInvisibilityOfWebElement(org.openqa.selenium.By locator,
String text)
Wait for invisibility of web element.
|
static void |
waitForNumberOfWindowsToBe(int numberOfWindows)
Wait for number of windows to be.
|
static void |
waitForPresenceOfElementToBeLocated(org.openqa.selenium.By locator)
Wait for presence of element to be located.
|
static void |
waitForTextToBePresentInWebElement(org.openqa.selenium.WebElement webElement,
String text)
Wait for text to be present in web element.
|
static void |
waitForVisibilityOfAllWebElements(org.openqa.selenium.By locator)
Wait for visibility of all web elements.
|
static void |
waitForVisibilityOfAllWebElements(List<org.openqa.selenium.WebElement> webElement)
Wait for visibility of all web elements in the page
|
static void |
waitingForTheElementToLoad(org.openqa.selenium.WebElement element)
Waits for desired seconds and then checks if the element is visible or not.
|
static void |
waitSeconds(int seconds)
Wait seconds.
|
public static org.openqa.selenium.WebDriver driver
public static int sleepTimeMin
public static int sleepTimeMin2
public static int sleepTimeAverage
public static int sleepTimeAverage2
public static int sleepTimeMax
public static int sleepTimeMax2
public static Robot robot
public WebCommonMethods(org.openqa.selenium.WebDriver driver)
driver
- the driverpublic static String alertGetText() throws Exception
Exception
public static void alertAccept() throws Exception
Exception
public static void alertDismiss()
public static void waitSeconds(int seconds)
seconds
- the secondspublic static void waitForElementToBeSelected(org.openqa.selenium.WebElement element)
element
- the elementpublic static void waitForElementToBeClickable(org.openqa.selenium.WebElement element)
element
- the elementpublic static void waitingForTheElementToLoad(org.openqa.selenium.WebElement element)
element
- the elementpublic static void waitForInvisibilityOfWebElement(org.openqa.selenium.By locator)
locator
- the locatorpublic static void waitForInvisibilityOfWebElement(org.openqa.selenium.By locator, String text)
locator
- the locatortext
- the textpublic static void waitForVisibilityOfAllWebElements(List<org.openqa.selenium.WebElement> webElement)
webElement
- the web elementpublic static void waitForVisibilityOfAllWebElements(org.openqa.selenium.By locator)
locator
- the locatorpublic static void waitForTextToBePresentInWebElement(org.openqa.selenium.WebElement webElement, String text)
webElement
- the web elementtext
- the textpublic static void waitForNumberOfWindowsToBe(int numberOfWindows)
numberOfWindows
- the number of windowspublic static void waitForPresenceOfElementToBeLocated(org.openqa.selenium.By locator)
locator
- the locatorpublic static void initializeSleepTimings() throws IOException
IOException
- Signals that an I/O exception has occurred.public static void implicitSleep() throws Exception
Exception
- the exceptionpublic static boolean isElementPresent(org.openqa.selenium.WebElement element) throws Exception
element
- the elementException
- the exceptionpublic static boolean isElementPresent(org.openqa.selenium.WebDriver driver, org.openqa.selenium.By by) throws Exception
driver
- the WebDriverby
- Pass the element as By.xpath / By.Id / By.Name or any other locator type supported with ByException
- the exceptionpublic static boolean isAttributeValuePresent(org.openqa.selenium.WebElement element, String attribute) throws Exception
element
- the elementattribute
- the attributeException
- the exceptionpublic static void screenshot(String methodName) throws Exception
methodName
- the method nameException
- the exceptionpublic static int RetrieveHeadingTdValue(String excelCellTabNameHeadingsTdValue, String excelCellTabNameUniqueHashValue) throws jxl.read.biff.BiffException, IOException, Exception
excelCellTabNameHeadingsTdValue
- the excel cell tab name headings td valueexcelCellTabNameUniqueHashValue
- the excel cell tab name unique hash valuejxl.read.biff.BiffException
- the biff exceptionIOException
- Signals that an I/O exception has occurred.Exception
public static int RetrieveHeadingTrValue(String headingClassName, String orgCodeValue) throws jxl.read.biff.BiffException, IOException, Exception
headingClassName
- the heading class nameorgCodeValue
- the org code valuejxl.read.biff.BiffException
- the biff exceptionIOException
- Signals that an I/O exception has occurred.Exception
public static void selectDropdownByText(org.openqa.selenium.WebElement element, String value) throws Exception
element
- the elementvalue
- the valueException
public static List<org.openqa.selenium.WebElement> getDropdownItems(org.openqa.selenium.WebElement element) throws Exception
element
- the elementException
public static String getSelectedDropdownItem(org.openqa.selenium.WebElement element) throws Exception
element
- the elementException
public static void deselectDropDown(org.openqa.selenium.WebElement element) throws Exception
element
- the elementException
public static void selectDropdownItemBootStrap(org.openqa.selenium.WebElement dropdown, org.openqa.selenium.WebElement dropdownList, org.openqa.selenium.By commonLocatorWithinLiTagForAllItems, String itemName) throws Exception
dropdown
- the dropdowndropdownList
- the dropdown listcommonLocatorWithinLiTagForAllItems
- the common locator within li tag for all items. Ex: By.className("active-result")itemName
- the item nameException
- the exceptionpublic static void selectDropdownItemBootStrap(org.openqa.selenium.WebElement dropdown, String itemName) throws IOException, InterruptedException, AWTException, Exception
dropdown
- the dropdownitemName
- the item nameIOException
- Signals that an I/O exception has occurred.InterruptedException
- the interrupted exceptionAWTException
- the AWT exceptionException
- the exceptionpublic static void checkItemNotPresentInDropdownItems(org.openqa.selenium.WebElement dropdown, org.openqa.selenium.WebElement dropdownList, org.openqa.selenium.By commonLocatorWithinLiTagForAllItems, String itemName) throws Exception
dropdown
- the dropdowndropdownList
- the dropdown listcommonLocatorWithinLiTagForAllItems
- the common locator within "li" tag for all items. Ex: By.className("active-result")itemName
- the item nameException
- the exceptionpublic static void setCheckBox(org.openqa.selenium.WebElement element, String status) throws Exception
element
- the webelementstatus
- the status. Ex: "check" or "uncheck"Exception
- the exceptionpublic static void setRadioButton(org.openqa.selenium.WebElement element, String status) throws Exception
element
- the WebElementstatus
- the status. Ex: "Select" or "Deselect"Exception
- the exceptionpublic static Boolean toggleCheckBox(org.openqa.selenium.WebElement element) throws Exception
element
- the elementException
- the exceptionpublic static void downloadPopupPreferenceForFirefox(String downloadDirectory) throws Exception
downloadDirectory
- the download directory. Ex for Windows:"e:\\SampleExcel", for Linux:"/e/SampleExcel/"Exception
- the exception