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 an element is visible.
23 *
24 * You can specify whether you expect true(item is visible) or
25 * false (item is not visible). True is the default
26 *
27 * To see if something IS visible:
28 * <pre><source>
29 * <selenium-assert-visible
30 * functionId="Assert that the div is visible"
31 * expected="true"
32 * msg="We expected the div to be visible"
33 * locator="mydiv" />
34 * </source></pre>
35 *
36 * To see if something is NOT visible:
37 * <pre><source>
38 * <selenium-assert-visible
39 * functionId="Assert that the div is not visible"
40 * expected="false"
41 * msg="We expected the div to be not visible"
42 * locator="div_2" />
43 * </source></pre>
44 *
45 * @jameleon.function name="selenium-assert-visible" type="validation"
46 */
47 public class SeleniumAssertVisibleTag 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 + " is not visible!"), session.isVisible(locator));
65 } else {
66 assertFalse(getStringOrDefault(msg, locator + " was visible!"), session.isVisible(locator));
67 }
68 }
69 }