public abstract class AbstractSelectable extends EmbeddedObject implements ISelectable
Apr 25, 2014 (Lei Wang) Initial release. May 29, 2014 (Lei Wang) Use single-click for selectItem, double-click for activateItem. Oct 15, 2014 (Lei Wang) Modify showOnPage(): move the code 'test visiblility' to super class. Nov 05, 2014 (Lei Wang) Add waitAndVerifyItemSelected(): used to verify item selection.
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<org.openqa.selenium.WebElement,Element[]> |
contentObjects
A cache, which stores a pair(WebElement, Element[])
|
protected int |
DEFAULT_WAIT_TIME |
parent
Constructor and Description |
---|
AbstractSelectable(Component parent) |
Modifier and Type | Method and Description |
---|---|
void |
activateItem(TextMatchingCriterion criterion,
boolean verify,
org.openqa.selenium.Keys key,
java.awt.Point offset)
Try to activate (double-click) the item according to the item's text (fully or partially given),
and then verify if the item has been really selected according to the parameter 'verify'.
|
void |
clearCache()
clear the cache 'contentObjects'.
|
protected void |
clickElement(Element element,
org.openqa.selenium.Keys key,
java.awt.Point offset,
int mouseButtonNumber,
int numberOfClick)
Try to get the Selenium WebElement object from parameter 'element', then click that WebElement object.
After calling this method, the parent of Element may become stale. |
protected Element[] |
getCacheableContent()
Get the real-time content from WebElement.
For some components like Tree, Menu etc. |
Element[] |
getContent()
Try to get the cached content according to the WebElement.
If no cached content can be found, then get the real-time content by calling getCacheableContent() ,and put the content in the cache and return it. If subclass doesn't need this functionality, then just override this method. If subclass needs this functionality, then override method getCacheableContent() |
void |
selectItem(TextMatchingCriterion criterion,
boolean verify,
org.openqa.selenium.Keys key,
java.awt.Point offset,
int mouseButtonNumber)
Try to select (single-click) the item according to the item's text (fully or partially given),
and then verify if the item has been really selected according to the parameter 'verify'.
|
protected void |
showOnPage(Element element)
Make the element is in the container, and visible on the page.
For example, some element may not be visible if there are too many elements in its container; User can scroll to make the element visible on the page. User may need to wait for a while so that the element related object can be updated (like position-onscreen, visibility etc.) This method gives a default implementation: it will scroll and align the top of element to the top of container. Before this method is called, it is suggested to call EmbeddedObject.isShowOnPage(Element) firstly. |
void |
verifyContains(TextMatchingCriterion criterion)
Verify the item (specified by text, partialMatch and matchIndex) is contained.
|
protected void |
verifyItemSelected(Element element)
Note:In subclass, we need to update the 'selected' property of Element.
Please call waitAndVerifyItemSelected(Element) instead to verify selection,as the first method will also try the wait for element to be ready and call EmbeddedObject.refresh(boolean) . |
protected void |
verifyItemSelection(Element element,
boolean expectSelected) |
void |
verifyItemSelection(TextMatchingCriterion criterion,
boolean expectSelected)
Verify the item (specified by text, partialMatch and matchIndex) is selected or un-selected.
|
protected void |
waitAndVerifyItemSelected(Element element)
Wait Item ready, and verify the item has been selected.
Before verification, we need to refresh the parent if the page doesn't change. |
protected void |
waitElementReady(Element element)
Wait for element ready, means that element's attribute has been updated.
This method just wait 200 milliseconds, subclass may give a more detail implementation. |
protected void |
waitElementReady(Element element,
int milliseconds)
Wait for element ready, means that element's attribute has been updated.
This method just wait some time, subclass may give a more detail implementation. When this method will be called? For example, before calling verifyItemSelected(Element) , becauseverifyItemSelected(Element) needs to check element's attributes. |
isShowOnPage, isSupported, refresh, webelement
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
activateItem, getMatchedElement, selectItem, verifyItemSelection
getSupportedClassNames
protected int DEFAULT_WAIT_TIME
protected java.util.Map<org.openqa.selenium.WebElement,Element[]> contentObjects
public AbstractSelectable(Component parent) throws SeleniumPlusException
SeleniumPlusException
public Element[] getContent() throws SeleniumPlusException
getCacheableContent()
,getCacheableContent()
getContent
in interface ISelectable
SeleniumPlusException
getCacheableContent()
protected Element[] getCacheableContent() throws SeleniumPlusException
getContent()
so that the retrived contentgetContent()
will use the content in the cache.SeleniumPlusException
getContent()
public void clearCache()
clearCache
in interface IOperable
public void selectItem(TextMatchingCriterion criterion, boolean verify, org.openqa.selenium.Keys key, java.awt.Point offset, int mouseButtonNumber) throws SeleniumPlusException
ISelectable
selectItem
in interface ISelectable
criterion
- TextMatchingCriterion, containing text, partialMatch, matchedIndex as search-criterion.verify
- boolean, if true then verify the selection;key
- org.openqa.selenium.Keys, it is the key to press during selection.Keys.SHIFT
, or Keys.CONTROL
.offset
- Point, the position relative to the up-left corner to click atmouseButtonNumber
- int, the mouse-button-number representing right, middle, or left button.WDLibrary.MOUSE_BUTTON_LEFT
or WDLibrary.MOUSE_BUTTON_RIGHT
WDLibrary.MOUSE_BUTTON_MIDDLE
.SeleniumPlusException
public void activateItem(TextMatchingCriterion criterion, boolean verify, org.openqa.selenium.Keys key, java.awt.Point offset) throws SeleniumPlusException
ISelectable
activateItem
in interface ISelectable
criterion
- TextMatchingCriterion, containing text, partialMatch, matchedIndex as search-criterion.verify
- boolean, if true then verify the selection;key
- org.openqa.selenium.Keys, it is the key to press during selection.Keys.SHIFT
, or Keys.CONTROL
.offset
- Point, the position relative to the up-left corner to click atSeleniumPlusException
public void verifyContains(TextMatchingCriterion criterion) throws SeleniumPlusException
ISelectable
verifyContains
in interface ISelectable
criterion
- TextMatchingCriterion, containing text, partialMatch, matchedIndex as search-criterion.SeleniumPlusException
- if the verification fails.public void verifyItemSelection(TextMatchingCriterion criterion, boolean expectSelected) throws SeleniumPlusException
ISelectable
verifyItemSelection
in interface ISelectable
criterion
- TextMatchingCriterion, containing text, partialMatch, matchedIndex as search-criterion.expectSelected
- boolean, true if the item is expected 'selected'; false if expected 'unselected'.SeleniumPlusException
- if the verification fails.protected void verifyItemSelection(Element element, boolean expectSelected) throws SeleniumPlusException
element
- Element, the element to check.expectSelected
- boolean, true if the element is expected 'selected'; false if expected 'unselected'.SeleniumPlusException
- if the verification fails.protected void clickElement(Element element, org.openqa.selenium.Keys key, java.awt.Point offset, int mouseButtonNumber, int numberOfClick) throws SeleniumPlusException
EmbeddedObject.refresh(boolean)
.waitAndVerifyItemSelected(Element)
verifyItemSelected(Element)
, as the first method will also try the wait for elementEmbeddedObject.refresh(boolean)
.element
- Element, the element to selectkey
- org.openqa.selenium.Keys, it is the key to press during selection.Keys.SHIFT
, or Keys.CONTROL
.offset
- Point, the position relative to the up-left corner to click atmouseButtonNumber
- int, the mouse-button-number representing right, middle, or left button.
it can be WDLibrary.MOUSE_BUTTON_LEFT
or WDLibrary.MOUSE_BUTTON_RIGHT
WDLibrary.MOUSE_BUTTON_MIDDLE
.numberOfClick
- int, 1 means single-click, 2 means double-clickSeleniumPlusException
#refresh(boolean)}
,
waitAndVerifyItemSelected(Element)
protected void showOnPage(Element element) throws SeleniumPlusException
EmbeddedObject.isShowOnPage(Element)
firstly.element
- Element, the element needs to be visible on pageSeleniumPlusException
#isShowOnPage(Element)}
protected void waitElementReady(Element element, int milliseconds) throws SeleniumPlusException
verifyItemSelected(Element)
, becauseverifyItemSelected(Element)
needs to check element's attributes.element
- Element, the element needs to be readymilliseconds
- int, the time to waitSeleniumPlusException
#verifyItemSelected(Element)}
protected void waitElementReady(Element element) throws SeleniumPlusException
element
- Element, the element needs to be readySeleniumPlusException
protected void waitAndVerifyItemSelected(Element element) throws SeleniumPlusException
element
- Element, the element has been selected or clicked or double-clicked.SeleniumPlusException
#verifyItemSelected(Element)}
protected void verifyItemSelected(Element element) throws SeleniumPlusException
waitAndVerifyItemSelected(Element)
instead to verify selection,EmbeddedObject.refresh(boolean)
.element
- Element, the element to verify that it is selected.SeleniumPlusException
Copyright © SAS Institute. All Rights Reserved.