|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.sahi.client.ElementStub
public class ElementStub
ElementStub is a representation of a particular HTML DOM element on the browser.
It translates to its corresponding Sahi javascript API.
Constructor Summary | |
---|---|
ElementStub(java.lang.String elementType,
Browser browser,
java.lang.Object... args)
|
Method Summary | |
---|---|
ElementStub |
above(ElementStub aboveEl)
Establishes a "near" relation with another element. Eg. |
ElementStub |
aboveOrUnder(ElementStub aboveOrUnderEl)
|
void |
blur()
|
void |
check()
Checks this element (applicable to checkboxes and radio buttons). Internally calls browser.check(this); |
boolean |
checked()
Returns true if the element is checked. |
void |
choose(java.lang.String value)
Sets the value of a select element; Will unselect previously selected option(s). This method will do nothing for elements which are not select fields. Internally calls browser.choose(this, value, false); |
void |
choose(java.lang.String[] values)
Selects multiple options of a select element; Will unselect previously selected option(s). This method will do nothing for elements which are not select fields. Internally calls browser.choose(this, values, false); |
void |
choose(java.lang.String[] values,
boolean append)
Selects multiple options of a select element; Will not unselect previously selected option(s) if append is true. This method will do nothing for elements which are not select fields. Internally calls browser.choose(this, values, append); |
void |
choose(java.lang.String value,
boolean append)
Sets the value of a select element; Will not unselect previously selected option(s) if append is true. This method will do nothing for elements which are not select fields. Internally calls browser.choose(this, values, append); |
void |
click()
Performs a click on this element. Internally calls browser.click(this); |
java.util.List<ElementStub> |
collectSimilar()
Returns a list of element stubs similar to this one Eg. |
boolean |
containsHTML(java.lang.String html)
Returns true if the element's innerHTML contains the input html |
boolean |
containsText(java.lang.String text)
Returns true if the element contains the input text |
int |
countSimilar()
Returns a count of elements similar to this |
void |
doubleClick()
Performs a double click on this element. Internally calls browser.doubleClick(this); |
void |
dragAndDropOn(ElementStub dropElement)
Drags the element and drops it on another element. |
void |
dragAndDropOn(int x,
int y)
Drags the element and drops it at the given x, y coordinate. |
boolean |
exists()
Checks if an element is present on the browser. Internally calls browser.exists(this); Retries a few times if false. |
boolean |
exists(boolean optimistic)
Checks if an element is present on the browser. Internally calls browser.exists(this); |
java.lang.String |
fetch()
|
java.lang.String |
fetch(java.lang.String string)
Fetches the string value of a property of this element. Eg. browser.div("content").fetch("innerHTML") |
void |
focus()
Brings focus on the element. |
java.lang.String |
getAttribute(java.lang.String attribute)
|
java.lang.String |
getSelectedText()
Returns the selected text visible in a select box (<select> tag). Same as selectedText(). Internally calls browser.getSelectedText(this); |
java.lang.String |
getText()
Returns the inner text of an element. same as text(). Internally calls browser.getText(this); |
java.lang.String |
getValue()
Fetches the value of a form field from the browser. Same as value(). Internally calls browser.getValue(this) |
void |
highlight()
Highlights this element. Internally calls browser.highlight(this); |
void |
hover()
Performs a mouseover on this element. Same as mouseOver(). Internally calls browser.mouseOver(this); |
ElementStub |
in(ElementStub inEl)
Establishes an "in" relation with another element. Eg. |
boolean |
isVisible()
Checks for visibility of this element. If an element is hidden via style display attribute set to "none" or if the element is hidden via style visibility attribute set to "hidden", isVisible() returns false. |
boolean |
isVisible(boolean optimistic)
Checks for visibility of this element. If an element is hidden via style display attribute set to "none" or if the element is hidden via style visibility attribute set to "hidden", isVisible() returns false. |
void |
keyDown(int keyCode,
int charCode)
Performs a keyDown on this element. Internally calls browser.keyDown; |
void |
keyPress(java.lang.String keySequence,
java.lang.String combo)
|
void |
keyUp(int keyCode,
int charCode)
Performs a keyUp on this element. Internally calls browser.keyUp; |
ElementStub |
leftOf(ElementStub leftOfEl)
|
ElementStub |
leftOrRightOf(ElementStub leftOrRightOfEl)
|
void |
mouseDown()
Performs a mousedown on this element. Internally calls browser.mouseDown(this); |
void |
mouseOver()
Performs a mouseover on this element. Same as hover(). Internally calls browser.mouseOver(this); |
void |
mouseUp()
Performs a mouseup on this element. Internally calls browser.mouseUp(this); |
ElementStub |
near(ElementStub nearEl)
Establishes a "near" relation with another element. Eg. |
ElementStub |
parentNode()
|
ElementStub |
parentNode(java.lang.String tagName)
Returns the first parentNode of given tagName. Eg. browser.link("click me").parentNode("TABLE") will ignore TDs, TRs etc. |
ElementStub |
parentNode(java.lang.String tagName,
int occurrence)
Returns the nth parentNode of given tagName. |
void |
removeFocus()
Removes focus from the element. |
void |
rightClick()
Performs a right click on this element. Internally calls browser.rightClick(this); |
ElementStub |
rightOf(ElementStub rightOfEl)
|
java.lang.String |
rteHTML()
Fetches the HTML of a Rich Text Editor (RTE). This will be browser dependent |
java.lang.String |
rteText()
Fetches the text of a Rich Text Editor (RTE). |
void |
rteWrite(java.lang.String value)
Writes the text into the Rich Text Editor (RTE). Internally calls browser.rteWrite(this, value); |
java.lang.String |
selectedText()
Returns the selected text visible in a select box (<select> tag). Same as getSelectedText(). Internally calls browser.getSelectedText(this); |
void |
setFile(java.lang.String value)
Sets the value of this file upload element. This method will do nothing for elements which are not file upload fields. Internally calls browser.setFile(this, value); |
void |
setFile2(java.lang.String value)
Sets the value of this file upload element. This method will do nothing for elements which are not file upload fields. Internally calls browser.setFile(this, value); |
void |
setFile2(java.lang.String value,
java.lang.String URL)
|
void |
setValue(java.lang.String value)
Sets the value of this form element. This method will do nothing for elements which do not have a value attribute. Internally calls browser.setValue(this, value); |
java.lang.String |
style(java.lang.String html)
Returns the computed css style eg. |
java.lang.String |
text()
Returns the inner text of an element. same as getText(). Internally calls browser.getText(this); |
java.lang.String |
toString()
|
void |
uncheck()
Unchecks this element (applicable to checkboxes). Internally calls browser.uncheck(this); |
ElementStub |
under(ElementStub underEl)
Establishes an "under" relation with another element. Checks for coordinate based alignment under a particular element within a specific threshold. Eg. |
java.lang.String |
value()
Fetches the value of a form field from the browser. Same as getValue(). Internally calls browser.getValue(this) |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ElementStub(java.lang.String elementType, Browser browser, java.lang.Object... args)
Method Detail |
---|
public java.lang.String toString()
toString
in class java.lang.Object
public void click() throws ExecutionException
ExecutionException
public void doubleClick() throws ExecutionException
ExecutionException
public void rightClick() throws ExecutionException
ExecutionException
public void check() throws ExecutionException
ExecutionException
public void uncheck() throws ExecutionException
ExecutionException
public void focus() throws ExecutionException
element
-
ExecutionException
public void removeFocus() throws ExecutionException
element
-
ExecutionException
public void dragAndDropOn(ElementStub dropElement) throws ExecutionException
dropElement
- Element to be dropped on
ExecutionException
public void dragAndDropOn(int x, int y) throws ExecutionException
dropElement
- Element to be dropped onx
- X coordinatey
- Y coordinate
ExecutionException
public void mouseOver() throws ExecutionException
ExecutionException
public void mouseDown() throws ExecutionException
ExecutionException
public void mouseUp() throws ExecutionException
ExecutionException
public void hover() throws ExecutionException
ExecutionException
public void setValue(java.lang.String value) throws ExecutionException
value
-
ExecutionException
public void setFile(java.lang.String value) throws ExecutionException
value
-
ExecutionException
public void choose(java.lang.String value) throws ExecutionException
value
-
ExecutionException
public void choose(java.lang.String value, boolean append) throws ExecutionException
value
- append:
- if true, options are selected without unselecting previous options in multi-select box
ExecutionException
public void choose(java.lang.String[] values) throws ExecutionException
values
- String array of option identifiers
ExecutionException
public void choose(java.lang.String[] values, boolean append) throws ExecutionException
values
- String array of option identifiersappend:
- if true, options are selected without unselecting previous options in multi-select box
ExecutionException
public java.lang.String text() throws ExecutionException
ExecutionException
public java.lang.String getText() throws ExecutionException
ExecutionException
public void rteWrite(java.lang.String value) throws ExecutionException
value
-
ExecutionException
public java.lang.String rteText()
public java.lang.String rteHTML()
public java.lang.String fetch() throws ExecutionException
ExecutionException
public boolean exists()
public boolean exists(boolean optimistic)
optimistic:
- if true will not retry till exists returns true.
public java.lang.String value() throws ExecutionException
ExecutionException
public java.lang.String getValue() throws ExecutionException
ExecutionException
public java.lang.String selectedText() throws ExecutionException
ExecutionException
public boolean isVisible() throws ExecutionException
ExecutionException
public boolean isVisible(boolean optimistic) throws ExecutionException
optimistic:
- if true, Sahi will return in a single try. If false, Sahi will retry a few times.
ExecutionException
public java.lang.String getSelectedText() throws ExecutionException
ExecutionException
public boolean containsText(java.lang.String text)
text
-
public boolean containsHTML(java.lang.String html)
html
-
public java.lang.String style(java.lang.String html)
el
- attribute
-
public ElementStub in(ElementStub inEl)
browser.link("delete").in(browser.cell("user1").parentNode()).click();
inEl
-
public ElementStub under(ElementStub underEl)
browser.checkbox(0).near(browser.cell("Ram")).under(browser.cell("Delete user"))
underEl
-
public ElementStub near(ElementStub nearEl)
browser.link("delete").near(browser.cell("user1")).click();
nearEl
-
public ElementStub above(ElementStub aboveEl)
browser.link("delete").near(browser.cell("user1")).click();
nearEl
-
public ElementStub aboveOrUnder(ElementStub aboveOrUnderEl)
public ElementStub leftOf(ElementStub leftOfEl)
public ElementStub rightOf(ElementStub rightOfEl)
public ElementStub leftOrRightOf(ElementStub leftOrRightOfEl)
public java.lang.String fetch(java.lang.String string) throws ExecutionException
ExecutionException
public boolean checked() throws ExecutionException
ExecutionException
public ElementStub parentNode()
public ElementStub parentNode(java.lang.String tagName)
tagName
-
public ElementStub parentNode(java.lang.String tagName, int occurrence)
tagName
- occurrence
-
public java.util.List<ElementStub> collectSimilar()
browser.span("/Delete/").collectSimilar() browser.div("css-class-name").in(browser.div("container")).collectSimilar()
public int countSimilar()
public void keyUp(int keyCode, int charCode)
keyCode
- charCode
- public java.lang.String getAttribute(java.lang.String attribute) throws ExecutionException
ExecutionException
public void blur() throws ExecutionException
ExecutionException
public void keyDown(int keyCode, int charCode)
keyCode
- charCode
- public void keyPress(java.lang.String keySequence, java.lang.String combo)
public void highlight() throws ExecutionException
ExecutionException
public void setFile2(java.lang.String value, java.lang.String URL) throws ExecutionException
ExecutionException
public void setFile2(java.lang.String value) throws ExecutionException
value
-
ExecutionException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |