net.sf.jameleon.plugin.watij.tags
Class WatijHtmlElementTag

java.lang.Object
  extended by org.apache.commons.jelly.TagSupport
      extended by net.sf.jameleon.LocationAwareTagSupport
          extended by net.sf.jameleon.JameleonTagSupport
              extended by net.sf.jameleon.function.FunctionTag
                  extended by net.sf.jameleon.plugin.watij.WatijFunctionTag
                      extended by net.sf.jameleon.plugin.watij.tags.AbstractWatijGetTag
                          extended by net.sf.jameleon.plugin.watij.tags.WatijHtmlElementTag
All Implemented Interfaces:
BreakPoint, Attributable, Storable, DynaTag, LocationAware, Tag

public class WatijHtmlElementTag
extends AbstractWatijGetTag

Gets an HtmlElement on the page and stores in the context. An example of its use might be to click on a link via its underlined text:


 <testcase xmlns="jelly:jameleon" xmlns:j="jelly:core">
     <watij-session baseUrl="http://jameleon.sourceforge.net" beginSession="true">
         <watij-html-element
             functionId="Get the 'some link' link"
             how="text"
             what="some link"
             contextVar="watijHtmlElement"/>
         <watij-click
             functionId="Click on the 'some link' link"
             element="${watijHtmlElement}"/>
     </watij-session>
 </testcase>
 
Maybe there are several links with the same text and the one of interest has a and id attribute of '42' and you want to use a more specific context variable name like 'link42':

 <testcase xmlns="jelly:jameleon" xmlns:j="jelly:core">
     <watij-session baseUrl="http://jameleon.sourceforge.net" beginSession="true">
         <watij-html-element
             functionId="Get the link with the id of '42'"
             how="id"
             what="42"
             contextVar="link42"/>
         <watij-click
             functionId="Click on the link"
             element="${link42}"/>
     </watij-session>
 </testcase>
 
To get a form field via XPath (the default symbol):

 <testcase xmlns="jelly:jameleon" xmlns:j="jelly:core">
     <watij-session baseUrl="http://jameleon.sourceforge.net" beginSession="true">
         <watij-html-element
             functionId="Get the j_username form field"
             how="xpath"
             what="//FORM//INPUT[@name='j_username']"
             contextVar="usernameField"/>
         <ju-assert-true
             functionId="Make sure the field exists"
             test="${usernameField.exists()}"/>
     </watij-session>
 </testcase>
 
See the javadocs on watij's SymbolFactory for a complete list of supported symbols.

Tag Name: <watij-html-element> Type: action

Field Summary
 
Fields inherited from class net.sf.jameleon.plugin.watij.tags.AbstractWatijGetTag
contextVar, failOnNotExists, how, what
 
Fields inherited from class net.sf.jameleon.plugin.watij.WatijFunctionTag
sessionTag, STORE_SOURCE_CONFIG_NAME, storeSourceOnStateChange
 
Fields inherited from class net.sf.jameleon.function.FunctionTag
addt, breakPoint, expectException, expectFailure, fResults, functionDelay, functionId, lastFileWritten, log, NO_DELAY, params, postcondition, precondition, st, state, tct, vpt
 
Fields inherited from class net.sf.jameleon.JameleonTagSupport
attributes, broker, contextVars, fp, unsupportedAttributes
 
Fields inherited from class net.sf.jameleon.LocationAwareTagSupport
columnNumber, elementTagName, lineNumber, scriptFileName
 
Fields inherited from class org.apache.commons.jelly.TagSupport
body, context, hasTrimmed, parent, shouldTrim
 
Constructor Summary
WatijHtmlElementTag()
           
 
Method Summary
 HtmlElement getHtmlElement(Symbol how, String what)
          Gets the HtmlElement of interest.
 String getTagName()
          The HTML Element name this tag is used to get.
 
Methods inherited from class net.sf.jameleon.plugin.watij.tags.AbstractWatijGetTag
getHtmlElement, getPrefixMsg, testBlock
 
Methods inherited from class net.sf.jameleon.plugin.watij.WatijFunctionTag
getParentBrowser, getSymbolFromString, ie, setCurrentIE, setupEnvironment, store
 
Methods inherited from class net.sf.jameleon.function.FunctionTag
addParam, addRequiredAttribute, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertFalse, assertFalse, assertMethod, assertMethodWithLevel, assertNotNull, assertNotNull, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNotSame, assertNotSame, assertNull, assertNull, assertNull, assertNull, assertRegexMatches, assertRegexMatches, assertRegexMatches, assertRegexMatches, assertSame, assertSame, assertSame, assertSame, assertTextContains, assertTextContains, assertTextContains, assertTextContains, assertTextEndsWith, assertTextEndsWith, assertTextEndsWith, assertTextEndsWith, assertTextStartsWith, assertTextStartsWith, assertTextStartsWith, assertTextStartsWith, assertTrue, assertTrue, assertTrue, assertTrue, checkParamTypes, cleanUp, cleanUpEnvironment, delay, delay, doTag, fail, fail, fail, fail, getFunctionId, getFunctionResults, getMatchingRegexText, getParam, getParamLength, getParams, getParentTags, getSessionTag, getStoreToFileName, getStringOrDefault, getTestCaseTag, getVariable, getVariableAsBoolean, getVariableAsList, getVariableAsString, isBreakPoint, isContextVariableNull, pluginTearDown, recordFunctionResult, regexMatches, removeFunctionResult, removeVariable, setDefaultVariableValue, setDefaultVariableValue, setExpectException, setExpectFailure, setFunctionDelay, setFunctionId, setup, setUpFunctionResults, setVariable, tearDown, traceMsg, validate
 
Methods inherited from class net.sf.jameleon.JameleonTagSupport
cleanVariablesInContext, createAttributes, describeAttributes, getAttributeBroker, getAttributes, getAttributeType, getClassAttributes, getFunctionalPoint, getUnsupportedAttributes, loadFunctionalPoint, resetFunctionalPoint, setAttribute, setVariableInContext, testForUnsupportedAttributesCaught
 
Methods inherited from class net.sf.jameleon.LocationAwareTagSupport
getColumnNumber, getElementName, getFileName, getLineNumber, setColumnNumber, setElementName, setFileName, setLineNumber
 
Methods inherited from class org.apache.commons.jelly.TagSupport
findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, getBody, getBodyText, getBodyText, getContext, getParent, invokeBody, isEscapeText, isTrim, setBody, setContext, setEscapeText, setParent, setTrim, trimBody
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.jelly.Tag
getBody, getContext, getParent, invokeBody, setBody, setContext, setParent
 

Constructor Detail

WatijHtmlElementTag

public WatijHtmlElementTag()
Method Detail

getHtmlElement

public HtmlElement getHtmlElement(Symbol how,
                                  String what)
                           throws Exception
Description copied from class: AbstractWatijGetTag
Gets the HtmlElement of interest. Each subclass will implement the code required to get the specific element of interest.

Specified by:
getHtmlElement in class AbstractWatijGetTag
Parameters:
how - - How to search for the element
what - - What to search for.
Returns:
HtmlElement
Throws:
Exception

getTagName

public String getTagName()
Description copied from class: AbstractWatijGetTag
The HTML Element name this tag is used to get. For example, if the tag is used to get an image, then this method might return something like img tag

Specified by:
getTagName in class AbstractWatijGetTag
Returns:
String


Copyright © 2006-2008 Christian Hargraves. All Rights Reserved.