Home |
Overview
The web form submission sample is the fileTest1 test case defined in the system test configuration. This is located in the file sampleSystemTests/subtests/SubTest.xml.
SubTest.xml Test Cases
The top level beans to be configured in
the SubTest.xml file are the 2 test case beans. These beans
define the appropriate actions taken for these test cases, and the name
of the particular test case (for junitreport functionality).
|
|
<bean id="subTest.1" class="org.jete.cases.ActionTestCase">
<property name="name">
<value>subtest.success</value>
</property>
<property name="testActions">
<list>
<!-- wait for 5 seconds -->
<bean class="org.jete.util.WaitAction">
<property name="waitMillis" value="50000"/>
</bean>
<bean class="org.jete.web.FormSubmissionValidatedAction">
<property name="formURL">
<value>http://www.google.com/search</value>
</property>
<property name="webRequestData">
<map>
<entry>
<key>
<value>hl</value>
</key>
<value>en</value>
</entry>
<entry>
<key>
<value>q</value>
</key>
<value>subFiletest</value>
</entry>
<entry>
<key>
<value>btnG</value>
</key>
<value>Google+Search</value>
</entry>
</map>
</property>
<property name="validators">
<list>
<ref bean="sample.subtest.validator"/>
</list>
</property>
</bean>
</list>
</property>
</bean>
<bean id="subTest.2" class="org.jete.cases.ActionTestCase">
<property name="name">
<value>subtest.failure</value>
</property>
<property name="testActions">
<list>
<bean class="org.jete.web.FormSubmissionValidatedAction">
<property name="formURL">
<value>http://www.google.com/search</value>
</property>
<property name="webRequestData">
<map>
<entry>
<key>
<value>hl</value>
</key>
<value>en</value>
</entry>
<entry>
<key>
<value>q</value>
</key>
<value>busted</value>
</entry>
<entry>
<key>
<value>btnG</value>
</key>
<value>Google+Search</value>
</entry>
</map>
</property>
<property name="validators">
<list>
<ref bean="sample.subtest.validator"/>
</list>
</property>
</bean>
</list>
</property>
</bean>
|
|
|
|
Actions
The test cases reference one action each. These are simple
FormSubmissionValidatedActions configured to submit a search request to
google.
The actions are as defined:
- waitAction1 puts the system test to sleep for 5 seconds
- action1 performs a google search on the term "subFiletest"
- action2 performs a google search on the term "busted"
Both tests use the same validator (below), to validate the page
response, this results in one test succeeding (using action1) and the
other test failing (using action2).
The properties for FormSubmissionValidatedAction are:
- formURL
- webRequestData
- validators
|
|
<!--
inline subTest.1
sample waiting
-->
<bean class="org.jete.util.WaitAction">
<property name="waitMillis" value="50000"/>
</bean>
<!--
inline subTest.1
sample form submission
-->
<bean class="org.jete.web.FormSubmissionValidatedAction">
<property name="formURL">
<value>http://www.google.com/search</value>
</property>
<property name="webRequestData">
<map>
<entry>
<key>
<value>hl</value>
</key>
<value>en</value>
</entry>
<entry>
<key>
<value>q</value>
</key>
<value>subFiletest</value>
</entry>
<entry>
<key>
<value>btnG</value>
</key>
<value>Google+Search</value>
</entry>
</map>
</property>
<property name="validators">
<list>
<ref bean="validator1"/>
</list>
</property>
</bean>
<!--
inline subTest.2
sample form submission with a validator that would fail
-->
<bean class="org.jete.web.FormSubmissionValidatedAction">
<property name="formURL">
<value>http://www.google.com/search</value>
</property>
<property name="webRequestData">
<map>
<entry>
<key>
<value>hl</value>
</key>
<value>en</value>
</entry>
<entry>
<key>
<value>q</value>
</key>
<value>busted</value>
</entry>
<entry>
<key>
<value>btnG</value>
</key>
<value>Google+Search</value>
</entry>
</map>
</property>
<property name="validators">
<list>
<ref bean="validator1"/>
</list>
</property>
</bean> |
|
|
|
Validator
The validator is a WebPageContentValidator that
provides some basic web page content validation functionality.
This validator, used by both actions (and why one works and the
other fails) just looks for some string content on the page and the
appropriate page title. |
|
<bean id="sample.subtest.validator" class="org.jete.web.WebPageContentValidator">
<property name="expectedContent">
<value>subFiletest - Google Search</value>
</property>
<property name="expectedTitle">
<value>subFiletest - Google Search</value>
</property>
</bean> |
|
|
hosted by |
|