Package com.hp.lft.sdk.web
Interface Browser
- All Superinterfaces:
LocationInfoProvider
,TestObject
,TestObjectDescriber
,WebTestObjectDescriber
A tab in an open Web browser.
--To open a new browser tab, use
--To access a browser that is already open, use:
--To open a new browser tab, use
BrowserFactory.Launch
.--To access a browser that is already open, use:
BrowserFactory.Attach
.-
Method Summary
Modifier and TypeMethodDescriptionvoid
activate()
Activates the tab of the browser in the window group and clicks on it by default (windows only)void
activate
(boolean setFocus) Activates the tab of the browser in the window group and if the 'setFocus' parameter is true it clicks on it (windows only).void
back()
Navigates to the previous page in the browser history list.void
Clears the browser cache.
Note: This method does not clear the browser's cookies.void
close()
Closes the browser window (or tab) that this test object represents.void
Closes all tabs (if any) and closes the browser window.void
Deletes all cookies from the browser.void
deleteCookies
(String fromSource) Deletes only cookies that originated from the browser source.void
embedScript
(String script) Runs this JavaScript each time a page or frame loads or refreshes in the browser.
- The script remains embedded until you close the browser, or until the run session ends.
- Using this method to perform alert operations may result in unexpected behavior.
- To run this method, the security settings in your Web browser must be set to allow active scripting.void
forward()
Navigates to the next page in the browser history list.void
Toggles the browser between full-screen mode and normal mode.void
fullScreen
(FullScreenMode mode) Controls the browser's full screen mode.Returns the text displayed in a browser message box, such as an alert, confirmation, or prompt.int
Returns the number of currently open tabs in the browser.Returns the browser's initial title when first opened.Returns the URL from which the browser is opened.getPage()
Returns a test object representing the top level document in the tab.Browser[]
Returns a collection of tabs (Browser objects) that are siblings to the current tab (tabs located in the same window).getTitle()
Returns the browser title.getURL()
Returns current browser URL.Returns data regarding the browser version and type.void
Clicks the OK button on the alert, confirmation, or prompt message box.void
handleDialog
(DialogButton button) Clicks a button on the alert, confirmation, or prompt message box.void
handleDialog
(String text) Enters text in the browser's prompt message box and clicks the OK button.boolean
Indicates whether the browser message box is currently open.void
Opens the specified URL in the browser.void
Opens a new tab in the browser window.void
refresh()
Refreshes the current page.void
resizeTo
(int width, int height) Resizes the browser window to specific dimensions.void
Resizes the browser window to a specific size.void
sync()
Waits for the browser to complete the current navigation.Methods inherited from interface com.hp.lft.sdk.LocationInfoProvider
getAbsoluteLocation, getLocation, getSize
Methods inherited from interface com.hp.lft.sdk.TestObject
callFTMethod, callFTMethod, exists, exists, findChildren, getDescription, getDisplayName, getParent, getSnapshot, getTextLocations, getTextLocations, getVisibleText, getVisibleText, highlight, highlightMatches, setDescription, setDisplayName, verifyImageExists, verifyImageExists, verifyImageMatch, verifyImageMatch, verifyImageMatch, verifyImageMatch, verifyImageMatch, verifyImageMatch, waitUntilExists, waitUntilExists
Methods inherited from interface com.hp.lft.sdk.TestObjectDescriber
describe
Methods inherited from interface com.hp.lft.sdk.web.WebTestObjectDescriber
describe, describe
-
Method Details
-
getNumberOfTabs
Returns the number of currently open tabs in the browser.- Returns:
- the number of currently open tabs in the browser.
- Throws:
GeneralLeanFtException
- if error occurs during execution
-
getURL
Returns current browser URL.- Returns:
- current browser URL.
- Throws:
GeneralLeanFtException
- if error occurs during execution
-
getVersion
Returns data regarding the browser version and type.- Returns:
- data regarding the browser version and type.
- Throws:
GeneralLeanFtException
- if error occurs during execution
-
getOpenTitle
Returns the browser's initial title when first opened.- Returns:
- the browser's initial title when first opened.
- Throws:
GeneralLeanFtException
- if error occurs during execution
-
getOpenURL
Returns the URL from which the browser is opened.- Returns:
- the URL from which the browser is opened.
- Throws:
GeneralLeanFtException
- if error occurs during execution
-
getTitle
Returns the browser title.- Returns:
- the browser title.
- Throws:
GeneralLeanFtException
- if error occurs during execution
-
activate
Activates the tab of the browser in the window group and clicks on it by default (windows only)- Throws:
GeneralLeanFtException
- if error occurs during execution
-
activate
Activates the tab of the browser in the window group and if the 'setFocus' parameter is true it clicks on it (windows only). If the 'setFocus' parameter is set on an unsupported OS, an error of type 'unexpectedParameterException' is returned.- Parameters:
setFocus
- decides to click or not the browser after it is activated.- Throws:
GeneralLeanFtException
- if error occurs during execution
-
close
Closes the browser window (or tab) that this test object represents. Use thecloseAllTabs
method to close the currently open tab, all sibling tabs, and the parent browser window.- Throws:
GeneralLeanFtException
- if error occurs during execution
-
sync
Waits for the browser to complete the current navigation. You can use this method to instruct your test to wait until the browser is loaded.- Throws:
GeneralLeanFtException
- if error occurs during execution
-
back
Navigates to the previous page in the browser history list. This method is identical to clicking the browser's Back button.- Throws:
GeneralLeanFtException
- if error occurs during execution
-
forward
Navigates to the next page in the browser history list. This method is identical to clicking the browser's Forward button.- Throws:
GeneralLeanFtException
- if error occurs during execution
-
getPage
Returns a test object representing the top level document in the tab.- Returns:
- a test object representing the top level document in the tab.
- Throws:
GeneralLeanFtException
- if error occurs during execution
-
embedScript
Runs this JavaScript each time a page or frame loads or refreshes in the browser.
- The script remains embedded until you close the browser, or until the run session ends.
- Using this method to perform alert operations may result in unexpected behavior.
- To run this method, the security settings in your Web browser must be set to allow active scripting. Otherwise, steps using this method will fail.- Parameters:
script
- the full content of the JavaScript to embed..- Throws:
GeneralLeanFtException
- if error occurs during execution
-
refresh
Refreshes the current page. This method is identical to clicking the browser's Refresh button.- Throws:
GeneralLeanFtException
- if error occurs during execution
-
clearCache
Clears the browser cache.
Note: This method does not clear the browser's cookies. UsedeleteCookies
to delete the cookies.- Throws:
GeneralLeanFtException
- if error occurs during execution
-
closeAllTabs
Closes all tabs (if any) and closes the browser window.
Use theclose
method to close only the currently open tab.
Limitation: Your Internet Explorer (IE) browser must be configured to "Always close all tabs". To do this, open two or more tabs in IE. Then close IE. In the message box that pops up, select the "Always close all tabs" option.
Note: This method is not supported on Chrome. Use the Close method instead.- Throws:
GeneralLeanFtException
- if error occurs during execution
-
deleteCookies
Deletes all cookies from the browser. This method does not clear the browser's cache. UseclearCache
to clear the cache.- Throws:
GeneralLeanFtException
- if error occurs during execution
-
deleteCookies
Deletes only cookies that originated from the browser source.- Parameters:
fromSource
- the full or partial domain of the source. For example, entering MySite.com or MySite.net clears cookies only from the specified site, whereas entering MySite clears cookies from all related domains.- Throws:
GeneralLeanFtException
- if error occurs during execution
-
fullScreen
Toggles the browser between full-screen mode and normal mode.- Throws:
GeneralLeanFtException
- if error occurs during execution
-
fullScreen
Controls the browser's full screen mode.- Parameters:
mode
- Indicates whether to set the browser to full screen or normal mode. Possible values:FullScreenMode
- Throws:
GeneralLeanFtException
- if error occurs during execution
-
getDialogText
Returns the text displayed in a browser message box, such as an alert, confirmation, or prompt.- Returns:
- the text displayed in a browser message box, such as an alert, confirmation, or prompt.
- Throws:
GeneralLeanFtException
- if error occurs during execution
-
handleDialog
Clicks the OK button on the alert, confirmation, or prompt message box.- Throws:
GeneralLeanFtException
- if error occurs during execution
-
handleDialog
Clicks a button on the alert, confirmation, or prompt message box.- Parameters:
button
- the button to click. Possible values:DialogButton
- Throws:
GeneralLeanFtException
- if error occurs during execution
-
handleDialog
Enters text in the browser's prompt message box and clicks the OK button.- Parameters:
text
- the text to enter in the edit field.- Throws:
GeneralLeanFtException
- if error occurs during execution
-
hasDialog
Indicates whether the browser message box is currently open.- Returns:
- True if a message box is open.
- Throws:
GeneralLeanFtException
- if error occurs during execution
-
openNewTab
Opens a new tab in the browser window.- Throws:
GeneralLeanFtException
- if error occurs during execution
-
resizeTo
Resizes the browser window to specific dimensions.- Parameters:
width
- width of the browser window.height
- height of the browser window.- Throws:
GeneralLeanFtException
- if error occurs during execution
-
resizeTo
Resizes the browser window to a specific size.- Parameters:
newDimensions
- the browser window size in pixels.- Throws:
GeneralLeanFtException
- if error occurs during execution
-
getSiblingTabs
Returns a collection of tabs (Browser objects) that are siblings to the current tab (tabs located in the same window).- Returns:
- The collection of sibling tabs as Browsers
- Throws:
GeneralLeanFtException
- if error occurs during execution
-