Package core.helpers
Class PageHelper
- java.lang.Object
-
- core.helpers.PageHelper
-
public class PageHelper extends Object
-
-
Constructor Summary
Constructors Constructor Description PageHelper()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringacceptAlert()accepts alert by selecting ok or cancelvoidbringPageToFront()brings current browser to front webdriver onlyvoidCloseAndReturn(String defaultWindow)close the window And return to the defaultWindowStringcurrentWindow()return the current window handlevoiddeleteAllCookies()delete all cookiesvoiddeleteCookieNamed(String name)delete cookie namedStringdimissAlert()dismisses alert by selecting ok or cancelStringgetAlertValue()returns alert message valueStringgetClipboardData()retrieves the clip board dataStringgetCurrentUrl()returns the current urlStringgetPageSource()gets page sourceStringgetPageTitle()returns the title of the pageorg.openqa.selenium.WebDrivergetWebdriver()get current webdriverbooleanisChrome()booleanisFirefox()booleanisMicrosoftEdge()booleanisSafari()BooleanisVisibleInViewport(EnhancedBy by)returns true if the element is visible in the current page only for web applicationsBooleanisVisibleInViewport(EnhancedBy by, int index)returns true if the element is visible in the current page only for web applicationsvoidmaximizePage()maximizes web pagevoidnavigateBack()navigates backvoidnavigateForward()navigate forwardvoidnavigateToUrl(String url)navigate to a different urlvoidprintStackTrace(Throwable throwable)prints stack tracevoidquitAllCurrentTestDrivers()quits all drivers in the current testvoidquitCurrentDriver()quits the current web drivervoidquitDriver(org.openqa.selenium.WebDriver driver)quit drivervoidrefreshPage()reload pagevoidrefreshPageSource()gets page sourcevoidscrollBottomPageBrowser()scroll to bottom of browservoidscrollDownBrowser()scroll down the browservoidscrollDownBrowser(int count)scroll down browservoidscrollToWebElement(EnhancedBy element)scroll to web elementvoidscrollToWebElement(EnhancedBy element, int index)scroll to elementvoidscrollUpBrowser()scroll up the browservoidscrollUpBrowser(int count)scroll up browservoidsetPageSize(int x, int y)sets page sizevoidswitchDriver(org.openqa.selenium.WebDriver driver)switch webdriver use for switching between different driversvoidswitchIframe(EnhancedBy frame)switches frame to frame specifiedvoidswitchToDefaultFrame()switches to default framevoidswitchToNewWindow(String defaultWindow)switch to the new opened windowvoidswitchToNextTab()switch to next tab circles back to initial tab if it reaches the last tabvoidswitchToPreviousTab()switch to previous tab circle back to the last tabvoidswitchToTab(int index)switch to tab by indexstatic voidswitchWindowHandle(int index)switch windows handle based on indexvoidswtichUrl(String url)navigate to a different urlvoidverifyNumberOfTabs(int tabs)switch to tab by indexvoidverifyTitle(String appTitle)verify page title
-
-
-
Method Detail
-
maximizePage
public void maximizePage()
maximizes web page
-
setPageSize
public void setPageSize(int x, int y)sets page size- Parameters:
x-y-
-
refreshPage
public void refreshPage()
reload page
-
switchIframe
public void switchIframe(EnhancedBy frame)
switches frame to frame specified- Parameters:
frame-
-
switchToDefaultFrame
public void switchToDefaultFrame()
switches to default frame
-
switchWindowHandle
public static void switchWindowHandle(int index)
switch windows handle based on index- Parameters:
index-
-
dimissAlert
public String dimissAlert()
dismisses alert by selecting ok or cancel- Parameters:
alert-
-
acceptAlert
public String acceptAlert()
accepts alert by selecting ok or cancel- Parameters:
alert-
-
getAlertValue
public String getAlertValue()
returns alert message value- Returns:
-
currentWindow
public String currentWindow()
return the current window handle- Returns:
-
switchToNewWindow
public void switchToNewWindow(String defaultWindow)
switch to the new opened window- Parameters:
defaultWindow-
-
CloseAndReturn
public void CloseAndReturn(String defaultWindow)
close the window And return to the defaultWindow- Parameters:
defaultWindow-
-
refreshPageSource
public void refreshPageSource()
gets page source
-
verifyTitle
public void verifyTitle(String appTitle)
verify page title- Parameters:
appTitle-
-
switchDriver
public void switchDriver(org.openqa.selenium.WebDriver driver)
switch webdriver use for switching between different drivers- Parameters:
driver-
-
switchToNextTab
public void switchToNextTab()
switch to next tab circles back to initial tab if it reaches the last tab
-
switchToPreviousTab
public void switchToPreviousTab()
switch to previous tab circle back to the last tab
-
switchToTab
public void switchToTab(int index)
switch to tab by index
-
verifyNumberOfTabs
public void verifyNumberOfTabs(int tabs)
switch to tab by index
-
getPageTitle
public String getPageTitle()
returns the title of the page- Returns:
-
getCurrentUrl
public String getCurrentUrl()
returns the current url- Returns:
-
getPageSource
public String getPageSource()
gets page source- Returns:
-
navigateBack
public void navigateBack()
navigates back
-
navigateForward
public void navigateForward()
navigate forward
-
deleteAllCookies
public void deleteAllCookies()
delete all cookies
-
deleteCookieNamed
public void deleteCookieNamed(String name)
delete cookie named- Parameters:
name-
-
bringPageToFront
public void bringPageToFront()
brings current browser to front webdriver only
-
swtichUrl
public void swtichUrl(String url)
navigate to a different url- Parameters:
url- destination url
-
navigateToUrl
public void navigateToUrl(String url)
navigate to a different url- Parameters:
url- destination url
-
getClipboardData
public String getClipboardData()
retrieves the clip board data- Returns:
-
quitCurrentDriver
public void quitCurrentDriver()
quits the current web driver
-
quitDriver
public void quitDriver(org.openqa.selenium.WebDriver driver)
quit driver- Parameters:
driver-
-
quitAllCurrentTestDrivers
public void quitAllCurrentTestDrivers()
quits all drivers in the current test
-
isVisibleInViewport
public Boolean isVisibleInViewport(EnhancedBy by)
returns true if the element is visible in the current page only for web applications- Parameters:
by-- Returns:
-
isVisibleInViewport
public Boolean isVisibleInViewport(EnhancedBy by, int index)
returns true if the element is visible in the current page only for web applications- Parameters:
by-- Returns:
-
getWebdriver
public org.openqa.selenium.WebDriver getWebdriver()
get current webdriver- Returns:
-
printStackTrace
public void printStackTrace(Throwable throwable)
prints stack trace- Parameters:
trace-
-
scrollBottomPageBrowser
public void scrollBottomPageBrowser()
scroll to bottom of browser
-
scrollUpBrowser
public void scrollUpBrowser(int count)
scroll up browser
-
scrollUpBrowser
public void scrollUpBrowser()
scroll up the browser
-
scrollDownBrowser
public void scrollDownBrowser(int count)
scroll down browser
-
scrollDownBrowser
public void scrollDownBrowser()
scroll down the browser
-
scrollToWebElement
public void scrollToWebElement(EnhancedBy element)
scroll to web element- Parameters:
element-
-
scrollToWebElement
public void scrollToWebElement(EnhancedBy element, int index)
scroll to element- Parameters:
element-index-
-
isFirefox
public boolean isFirefox()
-
isChrome
public boolean isChrome()
-
isSafari
public boolean isSafari()
-
isMicrosoftEdge
public boolean isMicrosoftEdge()
-
-