01: /***************************************************************
02: * This file is part of the [fleXive](R) project.
03: *
04: * Copyright (c) 1999-2008
05: * UCS - unique computing solutions gmbh (http://www.ucs.at)
06: * All rights reserved
07: *
08: * The [fleXive](R) project is free software; you can redistribute
09: * it and/or modify it under the terms of the GNU General Public
10: * License as published by the Free Software Foundation;
11: * either version 2 of the License, or (at your option) any
12: * later version.
13: *
14: * The GNU General Public License can be found at
15: * http://www.gnu.org/copyleft/gpl.html.
16: * A copy is found in the textfile GPL.txt and important notices to the
17: * license from the author are found in LICENSE.txt distributed with
18: * these libraries.
19: *
20: * This library is distributed in the hope that it will be useful,
21: * but WITHOUT ANY WARRANTY; without even the implied warranty of
22: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23: * GNU General Public License for more details.
24: *
25: * For further information about UCS - unique computing solutions gmbh,
26: * please see the company website: http://www.ucs.at
27: *
28: * For further information about [fleXive](R), please see the
29: * project website: http://www.flexive.org
30: *
31: *
32: * This copyright notice MUST APPEAR in all copies of the file!
33: ***************************************************************/package com.flexive.tests.browser;
34:
35: import com.thoughtworks.selenium.CommandProcessor;
36: import com.thoughtworks.selenium.DefaultSelenium;
37:
38: /**
39: * Flexive-specific extensions to the DefaultSelenium class.
40: *
41: * @author Daniel Lichtenberger (daniel.lichtenberger@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
42: * @version $Rev: 181 $
43: */
44: public class FlexiveSelenium extends DefaultSelenium {
45: /**
46: * A simple context menu wrapper.
47: */
48: public class ContextMenu {
49: private final String id;
50:
51: /**
52: * Define a context menu.
53: *
54: * @param id the context menu widget ID, e.g. "frm:searchResultMenu"
55: */
56: public ContextMenu(String id) {
57: this .id = id;
58: }
59:
60: public ContextMenu clickOption(String optionId) {
61: FlexiveSelenium.this .click('"' + id + ':' + optionId + '"');
62: return this ;
63: }
64:
65: /**
66: * Open the context menu for the given element. The element (or any of its parents) must have
67: * a oncontextmenu handler that opens the context menu.
68: *
69: * @param locator the element locator where the context menu should be opened
70: * @return this
71: */
72: public ContextMenu openAt(String locator) {
73: commandProcessor.doCommand("contextMenu",
74: new String[] { locator });
75: return this ;
76: }
77: }
78:
79: public FlexiveSelenium(String serverHost, int serverPort,
80: String browserStartCommand, String browserURL) {
81: super (serverHost, serverPort, browserStartCommand, browserURL);
82: }
83:
84: public FlexiveSelenium(CommandProcessor processor) {
85: super (processor);
86: }
87:
88: public ContextMenu getContextMenu(String id) {
89: return new ContextMenu(id);
90: }
91: }
|