public class DefaultRefreshable extends java.lang.Object implements IRefreshable
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
cssClass
cssClass is the html css value for this web element, it may be null
|
protected java.lang.String |
id
id is the html id for this web element, it may be null
|
protected java.util.Map<?,?> |
map
The convenient reference to embedded element object.
|
protected java.lang.Object |
object
The wrapped object, represents a control object on the web application
This object is refresh-able, which means it can be reset if the control object of web application has changed its status. For now, 2 kinds of type can be accepted, Map returned from a javascript function; WebElement returned by Selenium WebDriver (with certain search criterion). |
protected java.lang.String[] |
possibleRecognitionStrings
possibleRecognitionStrings is used to refresh the WebElement, it may be null.
|
protected org.openqa.selenium.SearchContext |
searchContext
searchContext is used to refresh the WebElement according to id, tag, cssclass etc, it may be null
|
protected java.lang.String |
tagName
tagName is the html tag name for this web element, should never be null
|
protected org.openqa.selenium.WebElement |
webelement
The convenient reference to embedded element object.
This element may become stale, see stale_element If the element is stale, we need to refresh it by getting it again (by id or css or other ways) |
Modifier | Constructor and Description |
---|---|
protected |
DefaultRefreshable()
Constructor ONLY for subclass, cannot be used to create an instance outside.
|
|
DefaultRefreshable(java.lang.Object object)
Constructor used to create an uniformed DefaultRefreshable object.
User may override this one to parse their own object, if there are some new attributes to analyze, then user should override updateFields() and he MUST TAKE CARE:There are 2 ways to write the overridden constructor: DO NOT forget to call updateFields() after callingsuper(object), below is an example of implementation in subclass. |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getAttribute(java.lang.String attribute)
Get the value of an attribute from the underlying WebElement object.
|
java.lang.String |
getCssClass()
get the WebElement's CSS Class.
|
java.lang.Object |
getEmbeddedObject() |
java.lang.String |
getId()
get the WebElement's ID.
|
java.util.Map<?,?> |
getMap()
The embedded element object (a Map) is returned from a javascript function.
|
java.lang.String[] |
getPossibleRecognitionStrings()
get the possible recognition strings, they will be tried one by one until
a valid WebElement is got. |
org.openqa.selenium.SearchContext |
getSearchContext()
searchContext is used to find the WebElement according to id, tag, cssclass etc, it may be null.
if it is null, SearchObject.getWebDriver() will be used a SearchContext.if it is not null, it may be stale itself! |
java.lang.String |
getTagName()
get the WebElement's Tag Name.
|
org.openqa.selenium.WebElement |
getWebElement()
Try to get the Selenium WebElement object 'webelement', if is null then try to find it by id.
It can be used to verify the status. |
protected void |
initialize(java.lang.Object object)
Set the embedded object and update the component's fields.
|
boolean |
isStale() |
boolean |
refresh(boolean checkStale)
Refresh the webelement by its 'ID' or 'CSS CLASS' or preset 'Recognition Strings'.
And update the value of fields according to the refreshed-WebElement |
void |
setCssClass(java.lang.String cssClass) |
void |
setId(java.lang.String id) |
void |
setPossibleRecognitionStrings(java.lang.String[] possibleRecognitionStrings) |
void |
setSearchContext(org.openqa.selenium.SearchContext searchContext) |
void |
setTagName(java.lang.String tagName) |
void |
setWebElement(org.openqa.selenium.WebElement element)
set the embedded WebElement object.
|
protected void |
updateFields()
set/update the class's local fields through the underlying WebElement.
Especially after calling refresh(boolean) , the underlying WebElement may have beenrefreshed, and the associated attributes may have different value, it is recommended to call this method to update the class's local field. |
protected java.lang.Object object
map
and webelement
.refresh(boolean)
.protected java.util.Map<?,?> map
protected org.openqa.selenium.WebElement webelement
refresh(boolean)
protected java.lang.String tagName
protected java.lang.String id
protected java.lang.String cssClass
protected org.openqa.selenium.SearchContext searchContext
protected java.lang.String[] possibleRecognitionStrings
protected DefaultRefreshable()
public DefaultRefreshable(java.lang.Object object)
updateFields()
and he MUST TAKE CARE:updateFields()
after calling
super(object);
updateFields();
The reason is that all fields will be initialized after calling super() or this() in a constructor.updateFields()
to set value forupdateFields()
,initialize(Object)
.
initialize(Object);
in that constructor, the no-parameter constructor DefaultRefreshable()
will be called implicitly,initialize(Object)
will be called,initialize(Object)
in this constructor, the reason isinitialize(Object)
or updateFields()
object
- Object, the element object. It may be a Map returned from javascript; it may be a WebElement.protected void initialize(java.lang.Object object)
object
- protected void updateFields()
refresh(boolean)
, the underlying WebElement may have beenrefresh(boolean)
public java.lang.String getAttribute(java.lang.String attribute)
attribute
- String, the attribute namepublic org.openqa.selenium.WebElement getWebElement()
getWebElement
in interface IRefreshable
public void setWebElement(org.openqa.selenium.WebElement element)
IRefreshable
setWebElement
in interface IRefreshable
public java.lang.Object getEmbeddedObject()
public java.util.Map<?,?> getMap()
public java.lang.String getTagName()
IRefreshable
getTagName
in interface IRefreshable
public void setTagName(java.lang.String tagName)
public java.lang.String getId()
IRefreshable
getId
in interface IRefreshable
public void setId(java.lang.String id)
public java.lang.String getCssClass()
IRefreshable
getCssClass
in interface IRefreshable
public void setCssClass(java.lang.String cssClass)
public org.openqa.selenium.SearchContext getSearchContext()
SearchObject.getWebDriver()
will be used a SearchContext.getSearchContext
in interface IRefreshable
public void setSearchContext(org.openqa.selenium.SearchContext searchContext)
public java.lang.String[] getPossibleRecognitionStrings()
IRefreshable
getPossibleRecognitionStrings
in interface IRefreshable
public void setPossibleRecognitionStrings(java.lang.String[] possibleRecognitionStrings)
public boolean isStale() throws SeleniumPlusException
SeleniumPlusException
public boolean refresh(boolean checkStale)
refresh
in interface IRefreshable
checkStale
- boolean, whether to check if the webelement is stable before refresh.
true, check stable; false, force refresh directly without check.Copyright © SAS Institute. All Rights Reserved.