Package core.helpers
Class PageHelper
java.lang.Object
core.helpers.PageHelper
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaccepts alert by selecting ok or cancelvoidbrings current browser to front webdriver onlyvoidCloseAndReturn(String defaultWindow) close the window And return to the defaultWindowreturn the current window handlevoiddelete all cookiesvoiddeleteCookieNamed(String name) delete cookie nameddismisses alert by selecting ok or cancelreturns alert message valueretrieves the clip board datareturns the current urlgets page sourcereturns the title of the pageorg.openqa.selenium.WebDriverget current webdriverbooleanisChrome()booleanbooleanbooleanisSafari()returns true if the element is visible in the current page only for web applicationsisVisibleInViewport(EnhancedBy by, int index) returns true if the element is visible in the current page only for web applicationsvoidmaximizes web pagevoidnavigates backvoidnavigate forwardvoidnavigateToUrl(String url) navigate to a different urlvoidprintStackTrace(Throwable throwable) prints stack tracevoidquits all drivers in the current testvoidquits the current web drivervoidquitDriver(org.openqa.selenium.WebDriver driver) quit drivervoidreload pagevoidgets page sourcevoidscroll to bottom of browservoidscroll down the browservoidscrollDownBrowser(int count) scroll down browservoidscrollToWebElement(EnhancedBy element) scroll to web elementvoidscrollToWebElement(EnhancedBy element, int index) scroll to elementvoidscroll 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 specifiedvoidswitches to default framevoidswitchToNewWindow(String defaultWindow) switch to the new opened windowvoidswitch to next tab circles back to initial tab if it reaches the last tabvoidswitch to previous tab circle back to the last tabvoidswitchToTab(int index) switch to tab by indexstatic voidswitchWindowHandle(int index) switch windows handle based on indexvoidnavigate 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()
-