1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.sf.jameleon.plugin.selenium.tags;
20
21 /***
22 * Validates something is selected in a drop-down("select") field.
23 *
24 * You can specify whether you expect true(something is selected) or
25 * false (nothing is selected). True is the default
26 *
27 * To see if something IS selected in the <b>fruits</b> select field:
28 * <pre><source>
29 * <selenium-assert-something-selected
30 * functionId="Assert if something is selected in 'fruits' field"
31 * expected="true"
32 * msg="no fruits were selected"
33 * locator="fruits" />
34 * </source></pre>
35 *
36 * To see if something is NOT selected in the <b>states</b> select field:
37 * <pre>
38 * <selenium-assert-something-selected
39 * functionId="Assert if something is selected in 'states' field"
40 * expected="false"
41 * msg="no states should be selected"
42 * locator="states" />
43 * </pre>
44 *
45 * @jameleon.function name="selenium-assert-something-selected" type="validation"
46 */
47 public class SeleniumAssertSomethingSelectedTag extends AbstractSeleniumLocatorTag{
48
49 /***
50 * The error message to output if the validation fails.
51 * @jameleon.attribute
52 */
53 protected boolean expected = true;
54
55 /***
56 * The error message to output if the validation fails.
57 * @jameleon.attribute
58 */
59 protected String msg;
60
61 public void testBlock(){
62 if (expected == true)
63 {
64 assertTrue(getStringOrDefault(msg, locator + " had no selected items!"), session.isSomethingSelected(locator));
65 } else {
66 assertFalse(getStringOrDefault(msg, locator + " had selected items!"), session.isSomethingSelected(locator));
67 }
68 }
69 }