Package core.helpers
Class PageHelper
java.lang.Object
core.helpers.PageHelper
public class PageHelper extends Object
-
Constructor Summary
Constructors Constructor Description PageHelper() -
Method Summary
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
-
Constructor Details
-
PageHelper
public PageHelper()
-
-
Method Details
-
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
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
dismisses alert by selecting ok or cancel- Parameters:
alert-
-
acceptAlert
accepts alert by selecting ok or cancel- Parameters:
alert-
-
getAlertValue
returns alert message value- Returns:
-
currentWindow
return the current window handle- Returns:
-
switchToNewWindow
switch to the new opened window- Parameters:
defaultWindow-
-
CloseAndReturn
close the window And return to the defaultWindow- Parameters:
defaultWindow-
-
refreshPageSource
public void refreshPageSource()gets page source -
verifyTitle
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
returns the title of the page- Returns:
-
getCurrentUrl
returns the current url- Returns:
-
getPageSource
gets page source- Returns:
-
deleteAllCookies
public void deleteAllCookies()delete all cookies -
deleteCookieNamed
delete cookie named- Parameters:
name-
-
bringPageToFront
public void bringPageToFront()brings current browser to front webdriver only -
swtichUrl
navigate to a different url- Parameters:
url- destination url
-
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
returns true if the element is visible in the current page only for web applications- Parameters:
by-- Returns:
-
isVisibleInViewport
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
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
scroll to web element- Parameters:
element-
-
scrollToWebElement
scroll to element- Parameters:
element-index-
-
isFirefox
public boolean isFirefox() -
isChrome
public boolean isChrome() -
isSafari
public boolean isSafari() -
isMicrosoftEdge
public boolean isMicrosoftEdge()
-