Package com.axway.ats.uiengine.engine
Class AbstractHtmlEngine
- java.lang.Object
-
- com.axway.ats.uiengine.internal.engine.AbstractEngine
-
- com.axway.ats.uiengine.engine.AbstractHtmlEngine
-
- All Implemented Interfaces:
IHtmlEngine
- Direct Known Subclasses:
HiddenHtmlEngine,RealHtmlEngine
public abstract class AbstractHtmlEngine extends AbstractEngine implements IHtmlEngine
Engine operating over HTML application
-
-
Field Summary
-
Fields inherited from class com.axway.ats.uiengine.internal.engine.AbstractEngine
elementsFactory, uiDriver
-
-
Constructor Summary
Constructors Constructor Description AbstractHtmlEngine(UiDriver uiDriver, AbstractElementsFactory elementsFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclickBrowserBackButton()Move back a single "item" in the browser's history.voidclickBrowserForwardButton()Move a single "item" forward in the browser's history.voidclickBrowserRefreshButton()Refresh the current page.voidcloseActiveWindow()Close the active window/tabintcountElements(String xpath)Returns the number of HTML elements that match the specified xpath
eg.intcountElementsByCssSelector(String cssSelector)Returns the number of HTML elements that match the specified css selector
eg.voiddeleteAllCookies()Delete all the cookies for the current domainvoiddeleteCookieNamed(String cookieName)Delete the named cookie from the current domain.
This is equivalent to setting the named cookie's expiration date to some time in the past.StringexecuteJavaScript(String javaScriptCommand)Gets the result of evaluating the specified JavaScript command.voidfireEvent(UiElement element, String eventName)Explicitly simulate an event, to trigger the corresponding "onevent" handler.Cookie[]getCookies()Get all the cookies for the current domain.StringgetCurrentUrl()StringgetPageSource()Get page source as StringString[]getWindowTitles()Returns the titles of all windows that the browser knows aboutvoidgoToAnotherWindow(long timeoutInSeconds)Go to window/tab with same title.voidgoToFirstWindowWithoutTitle()Go to first window/tab without title, skipping the main windowvoidgoToMainWindow()Go to main window/tabvoidgoToPage(String url)Navigate to another URL from within the same already started browservoidgoToWindow(String windowTitle)Going to window/tab with given titlevoidgoToWindow(String windowTitle, long timeoutInSeconds)Going to window/tab with given titlevoidreloadFrames()voidretrieveBrowserFocus()Retrieve the browser's focus.voidsetCookie(String cookieName, String cookieValue)voidsetCookie(String name, String value, String domain, String path, Date expiry, boolean isSecure)-
Methods inherited from class com.axway.ats.uiengine.internal.engine.AbstractEngine
getMapSection, loadMapFile, setMapSection
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.axway.ats.uiengine.internal.engine.IHtmlEngine
expectAlert, expectConfirm, expectPrompt, getButton, getButton, getCheckBox, getCheckBox, getElement, getElement, getFileBrowse, getFileBrowse, getLink, getLink, getMultiSelectList, getMultiSelectList, getRadioList, getRadioList, getSingleSelectList, getSingleSelectList, getTable, getTable, getTextArea, getTextArea, getTextBox, getTextBox, getUtilsElementState
-
-
-
-
Constructor Detail
-
AbstractHtmlEngine
public AbstractHtmlEngine(UiDriver uiDriver, AbstractElementsFactory elementsFactory)
-
-
Method Detail
-
goToPage
public void goToPage(String url)
Navigate to another URL from within the same already started browser- Parameters:
url- of the page to go
-
getCurrentUrl
public String getCurrentUrl()
- Returns:
- the current URL
-
getPageSource
public String getPageSource()
Get page source as String- Returns:
- page source
-
getWindowTitles
public String[] getWindowTitles()
Returns the titles of all windows that the browser knows about- Returns:
- array of all window titles
-
goToWindow
public void goToWindow(String windowTitle)
Going to window/tab with given title- Parameters:
windowTitle- window title or name (the value of "window.name" defined when the window was opened)
-
goToWindow
public void goToWindow(String windowTitle, long timeoutInSeconds)
Going to window/tab with given title- Parameters:
windowTitle- window title or name (the value of "window.name" defined when the window was opened)timeoutInSeconds- timeout (in seconds) for waiting the target window to appear
-
goToAnotherWindow
public void goToAnotherWindow(long timeoutInSeconds)
Go to window/tab with same title. Note that order of same titled windows is not guaranteed.- Parameters:
timeoutInSeconds- timeout (in seconds) for waiting the target window to appear
-
goToMainWindow
public void goToMainWindow()
Go to main window/tab
-
goToFirstWindowWithoutTitle
public void goToFirstWindowWithoutTitle()
Go to first window/tab without title, skipping the main window
-
closeActiveWindow
public void closeActiveWindow()
Close the active window/tab
-
fireEvent
public void fireEvent(UiElement element, String eventName)
Explicitly simulate an event, to trigger the corresponding "onevent" handler.- Parameters:
element- the target elementeventName- the name of the event to fire e.g. click, blur, focus, keydown, keyup, keypress...
-
reloadFrames
public void reloadFrames()
-
retrieveBrowserFocus
public void retrieveBrowserFocus()
Retrieve the browser's focus. This is sometimes needed, for example right before using the RobotEngine
-
executeJavaScript
public String executeJavaScript(String javaScriptCommand)
Gets the result of evaluating the specified JavaScript command. The command/snippet may have multiple lines, but only the result of the last line will be returned.
Note that, by default, the command will run in the context of the "selenium" object itself, so this will refer to the Selenium object.
Use window to refer to the window of your application, e.g. var fooEl = window.document.getElementById('foo'); fooEl.name;- Parameters:
javaScriptCommand- the JavaScript command- Returns:
- the result of the specified command. The command/snippet may have multiple lines, but only the result of the last line will be returned.
-
countElements
public int countElements(String xpath)
Returns the number of HTML elements that match the specified xpath
eg. "//table" would give the number of tables- Parameters:
xpath- the xpath expression to evaluate- Returns:
- matched elements count
-
countElementsByCssSelector
public int countElementsByCssSelector(String cssSelector)
Returns the number of HTML elements that match the specified css selector
eg. "//table" would give the number of tables- Parameters:
cssSelector- the css selector expression to evaluate- Returns:
- matched elements count
-
setCookie
public void setCookie(String cookieName, String cookieValue)
- Parameters:
cookieName- the name of the cookie. May not be null or an empty string.cookieValue- the cookie value. May not be null.
-
setCookie
public void setCookie(String name, String value, String domain, String path, Date expiry, boolean isSecure)
- Parameters:
name- the name of the cookie. May not be null or an empty string.value- the cookie value. May not be null.domain- the domain the cookie is visible to.path- the path the cookie is visible to. If left blank or set to null, will be set to "/".expiry- the cookie's expiration date; may be null.isSecure- whether this cookie requires a secure connection.
-
getCookies
public Cookie[] getCookies()
Get all the cookies for the current domain. This is the equivalent of calling "document.cookie" and parsing the result- Returns:
Cookies array
-
deleteCookieNamed
public void deleteCookieNamed(String cookieName)
Delete the named cookie from the current domain.
This is equivalent to setting the named cookie's expiration date to some time in the past.- Parameters:
cookieName- the name of the cookie. May not be null or an empty string.
-
deleteAllCookies
public void deleteAllCookies()
Delete all the cookies for the current domain
-
clickBrowserBackButton
public void clickBrowserBackButton()
Move back a single "item" in the browser's history.
-
clickBrowserForwardButton
public void clickBrowserForwardButton()
Move a single "item" forward in the browser's history. Does nothing if we are on the latest page viewed.
-
clickBrowserRefreshButton
public void clickBrowserRefreshButton()
Refresh the current page.
-
-