11note
2- description : " Summary description for {SE_ACTIONS}. "
2+ description : " Object that allows to build a complex chain of events "
33 author : " "
44 date : " $Date$"
55 revision : " $Revision$"
1313feature {NONE } -- Initialization
1414
1515 make (a_web_driver : WEB_DRIVER )
16- -- Create an object Actions using webdriver input devices (mouse and keyboard)
16+ -- Create an object Actions using webdriver.
1717 do
18- make_with_parameters (a_web_driver .mouse , a_web_driver .keyboard )
18+ make_with_parameters (a_web_driver .mouse , a_web_driver .keyboard )
1919 ensure
2020 keyboard_set : attached keyboard
2121 mouse_set : attached mouse
@@ -37,7 +37,9 @@ feature {NONE} -- Initialization
3737feature -- Access
3838
3939 keyboard : SE_KEYBOARD
40+
4041 mouse : SE_MOUSE
42+
4143 actions : SE_COMPOSITE_ACTION
4244
4345feature -- Change Element
@@ -48,7 +50,6 @@ feature -- Change Element
4850 create actions .make
4951 end
5052
51-
5253 set_keyboard (a_keyboard : SE_KEYBOARD )
5354 -- Set `keyboard' with `a_keyboard'
5455 do
@@ -65,4 +66,71 @@ feature -- Change Element
6566 mouse_set : mouse = a_mouse
6667 end
6768
69+ feature -- Actions
70+
71+ click (a_element : WEB_ELEMENT ): SE_ACTIONS
72+ -- Clicks in the middle of the given element `a_element'
73+ -- Equivalent to call move_to_element (a_element).click()
74+ do
75+ actions .add_action (create {SE_CLICK_ACTION }.make_with_location (mouse , create {SE_COORDINATES }.make (a_element )))
76+ Result := Current
77+ end
78+
79+ click_current : SE_ACTIONS
80+ -- Clicks at the current mouse location
81+ do
82+ actions .add_action (create {SE_CLICK_ACTION }.make (mouse ))
83+ Result := Current
84+ end
85+
86+
87+
88+ key_down (a_key : SE_KEY_STROKE ): SE_ACTIONS
89+ -- Execute a modifier key press. Does not release the modifier key - subsequent interactions may assume it's kept pressed.
90+ -- Note that the modifier key is <b>never</b> released implicitly - either key_UP(a_Key)or send_keys(Keys.NULL)
91+ do
92+ actions .add_action (create {SE_KEY_DOWN_ACTION }.make (keyboard , mouse , a_key ))
93+ Result := Current
94+ end
95+
96+
97+
98+ key_down_element (a_element : WEB_ELEMENT ; a_key : SE_KEY_STROKE ): SE_ACTIONS
99+ -- Execute a modifer key press after focusing on an element
100+ -- Equivalent to: SE_ACTIONS.click(element).send_keys (a_key)
101+ do
102+ actions .add_action (create {SE_KEY_DOWN_ACTION }.make_with_location (keyboard , mouse , a_key ,create {SE_COORDINATES }.make (a_element ) ))
103+ Result := Current
104+ end
105+
106+
107+ key_up (a_key : SE_KEY_STROKE ): SE_ACTIONS
108+ -- Execute a modifier key release. Releasing a non-depressed modifier key will yield undefined
109+ -- behaviour.
110+ do
111+ actions .add_action (create {SE_KEY_UP_ACTION }.make (keyboard , mouse , a_key ))
112+ Result := Current
113+ end
114+
115+
116+
117+ key_up_element (a_element : WEB_ELEMENT ; a_key : SE_KEY_STROKE ): SE_ACTIONS
118+ -- Executes a modifier key release after focusing on an element.
119+ -- Equivalent to: SE_ACTIONS.click(a_element).send_keys (a_key)
120+ do
121+ actions .add_action (create {SE_KEY_UP_ACTION }.make_with_location (keyboard , mouse , a_key ,create {SE_COORDINATES }.make (a_element ) ))
122+ Result := Current
123+ end
124+
125+ feature -- Builder
126+
127+ build : SE_ACTION
128+ -- Build a composite action containinig all actions, ready to be executed (and
129+ -- resets the internal builder state, so subsequent calls to build will contain fresh
130+ -- sequences).
131+ do
132+ Result := actions .twin
133+ reset
134+ end
135+
68136end
0 commit comments