Implemented more commands from REST API JSONWireProtocol

Refactor COMMAND_EXECUTOR.
This commit is contained in:
jvelilla
2013-04-24 11:33:39 -03:00
parent c7e6fe38fb
commit 4f79bf2add
6 changed files with 468 additions and 380 deletions

View File

@@ -51,9 +51,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_get (cmd_status)
if attached resp.body as l_body then
Result := new_response (l_body)
end
Result := new_response ("", resp)
end
new_session (capabilities: STRING_32): SE_RESPONSE
@@ -64,17 +62,14 @@ feature -- Commands
do
create Result.make_empty
resp := execute_post (cmd_new_session, capabilities)
-- TODO move this scenario to feature new_response
if not (resp.status >= 400) then
if attached resp.header ("Location") as l_location then
resp := http_new_session (l_location).get ("", context_executor)
if attached resp.body as l_body then
Result := new_response (l_body)
end
Result := new_response ("", resp)
end
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
Result := new_response ("", resp)
end
end
@@ -86,9 +81,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_get (cmd_sessions)
if attached resp.body as l_body then
Result := new_response (l_body)
end
Result := new_response ("", resp)
end
retrieve_session (session_id: STRING_32): SE_RESPONSE
@@ -99,9 +92,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_get (cmd_session_by_id (session_id))
if attached resp.body as l_body then
Result := new_response (l_body)
end
Result := new_response (session_id, resp)
end
delete_session (session_id: STRING_32): SE_RESPONSE
@@ -112,14 +103,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_delete (cmd_session_by_id ( session_id ))
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (session_id, resp)
end
set_session_timeouts (a_session_id: STRING_32; a_data_timeout: STRING_32): SE_RESPONSE
@@ -130,14 +114,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_post (cmd_session_timeouts (a_session_id), a_data_timeout)
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
set_session_timeouts_async_script (a_session_id: STRING_32; a_data_timeout: STRING_32): SE_RESPONSE
@@ -148,15 +125,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_post (cmd_session_timeouts_async_script (a_session_id), a_data_timeout)
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
set_session_timeouts_implicit_wait (a_session_id: STRING_32; a_data_timeout: STRING_32): SE_RESPONSE
@@ -167,15 +136,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_post (cmd_session_timeouts_implicit_wait (a_session_id), a_data_timeout)
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
retrieve_window_handle (session_id: STRING_32): SE_RESPONSE
@@ -186,9 +147,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_get (cmd_session_window_handle (session_id))
if attached resp.body as l_body then
Result := new_response (l_body)
end
Result := new_response (session_id, resp)
end
retrieve_window_handles (session_id: STRING_32): SE_RESPONSE
@@ -199,9 +158,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_get (cmd_session_window_handles (session_id))
if attached resp.body as l_body then
Result := new_response (l_body)
end
Result := new_response (session_id, resp)
end
retrieve_url (session_id: STRING_32): SE_RESPONSE
@@ -212,9 +169,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_get (cmd_session_url (session_id))
if attached resp.body as l_body then
Result := new_response (l_body)
end
Result := new_response (session_id, resp)
end
navigate_to_url (a_session_id: STRING_32; a_url: STRING_32): SE_RESPONSE
@@ -225,14 +180,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_post (cmd_session_url (a_session_id), a_url)
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
forward (a_session_id: STRING_32): SE_RESPONSE
@@ -243,14 +191,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_post (cmd_session_forward (a_session_id), Void)
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
back (a_session_id: STRING_32): SE_RESPONSE
@@ -261,14 +202,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_post (cmd_session_back (a_session_id), Void)
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
refresh (a_session_id: STRING_32): SE_RESPONSE
@@ -279,14 +213,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_post (cmd_session_refresh (a_session_id), Void)
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
execute
@@ -315,9 +242,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_get (cmd_session_screenshot (session_id))
if attached resp.body as l_body then
Result := new_response (l_body)
end
Result := new_response (session_id, resp)
end
ime_available_engines (session_id: STRING_32): SE_RESPONSE
@@ -328,9 +253,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_get (cmd_session_ime_available (session_id))
if attached resp.body as l_body then
Result := new_response (l_body)
end
Result := new_response (session_id, resp)
end
ime_active_engine (session_id: STRING_32): SE_RESPONSE
@@ -341,9 +264,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_get (cmd_session_ime_active_engine (session_id))
if attached resp.body as l_body then
Result := new_response (l_body)
end
Result := new_response (session_id, resp)
end
ime_activated (session_id: STRING_32): SE_RESPONSE
@@ -354,9 +275,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_get (cmd_session_ime_activated (session_id))
if attached resp.body as l_body then
Result := new_response (l_body)
end
Result := new_response (session_id, resp)
end
ime_deactivate (a_session_id: STRING_32): SE_RESPONSE
@@ -367,14 +286,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_post (cmd_session_ime_deactivate (a_session_id), Void)
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
ime_activate (a_session_id: STRING_32; an_engine: STRING_32): SE_RESPONSE
@@ -385,15 +297,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_post (cmd_session_ime_activate (a_session_id), an_engine)
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
change_focus_window (a_session_id: STRING_32; a_data: STRING_32): SE_RESPONSE
@@ -404,14 +308,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_post (cmd_session_window (a_session_id), a_data)
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
@@ -423,15 +320,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_delete (cmd_session_window (a_session_id))
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
change_size_window (a_session_id: STRING_32; a_window_handle : STRING_32;a_data: STRING_32): SE_RESPONSE
@@ -442,14 +331,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_post (cmd_session_window_size (a_session_id,a_window_handle), a_data)
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
size_window (a_session_id: STRING_32; a_window_handle : STRING_32) : SE_RESPONSE
@@ -460,14 +342,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_get (cmd_session_window_size (a_session_id,a_window_handle))
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
change_window_position (a_session_id: STRING_32; a_window_handle : STRING_32;a_data: STRING_32): SE_RESPONSE
@@ -478,14 +353,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_post (cmd_session_window_position (a_session_id,a_window_handle), a_data)
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
window_position (a_session_id: STRING_32; a_window_handle : STRING_32) : SE_RESPONSE
@@ -496,14 +364,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_get (cmd_session_window_size (a_session_id,a_window_handle))
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
window_maximize (a_session_id: STRING_32; a_window_handle : STRING_32) : SE_RESPONSE
@@ -514,14 +375,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_post (cmd_session_window_maximize (a_session_id,a_window_handle), Void)
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
@@ -533,14 +387,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_get (cmd_session_cookie (a_session_id))
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
set_cookie (a_session_id: STRING_32; a_data : STRING_32) : SE_RESPONSE
@@ -551,14 +398,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_post (cmd_session_cookie (a_session_id),a_data)
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
delete_cookies (a_session_id: STRING_32) : SE_RESPONSE
@@ -569,14 +409,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_delete (cmd_session_cookie (a_session_id))
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
delete_cookie_by_name (a_session_id: STRING_32; a_name : STRING_32) : SE_RESPONSE
@@ -587,14 +420,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_delete (cmd_session_cookie_delete (a_session_id,a_name))
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
page_source (a_session_id: STRING_32) : SE_RESPONSE
@@ -605,14 +431,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_get (cmd_session_source (a_session_id))
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
@@ -624,14 +443,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_get (cmd_session_title (a_session_id))
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
@@ -643,14 +455,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_post (cmd_session_element (a_session_id),a_data)
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
@@ -662,14 +467,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_post (cmd_session_element_id_element (a_session_id,id),a_data)
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
@@ -681,14 +479,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_post (cmd_session_elements (a_session_id),a_data)
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
@@ -701,14 +492,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_get (cmd_session_element_active (a_session_id))
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
@@ -720,14 +504,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_post (cmd_session_element_id_elements (a_session_id,id),a_data)
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
element_click (a_session_id: STRING_32; id : STRING_32) : SE_RESPONSE
@@ -738,14 +515,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_post (cmd_session_element_click (a_session_id,id),Void)
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
@@ -757,14 +527,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_post (cmd_session_element_submit (a_session_id,id),Void)
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
@@ -776,14 +539,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_get (cmd_session_element_text (a_session_id,id))
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
send_events (a_session_id: STRING_32; id : STRING_32; data : STRING_32) : SE_RESPONSE
@@ -794,14 +550,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_post (cmd_session_element_event (a_session_id,id),data)
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
@@ -813,14 +562,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_post (cmd_session_keys (a_session_id),data)
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
query_by_tag_name (a_session_id: STRING_32; id : STRING_32) : SE_RESPONSE
@@ -831,14 +573,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_get (cmd_session_element_name (a_session_id,id))
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
@@ -850,14 +585,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_post (cmd_session_element_clear (a_session_id,id), Void)
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
is_enabled (a_session_id: STRING_32; id : STRING_32) : SE_RESPONSE
@@ -868,14 +596,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_get (cmd_session_element_enabled (a_session_id,id))
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
is_selected (a_session_id: STRING_32; id : STRING_32) : SE_RESPONSE
@@ -886,14 +607,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_get (cmd_session_element_selected (a_session_id,id))
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
element_value (a_session_id: STRING_32; id : STRING_32; name : STRING_32) : SE_RESPONSE
@@ -904,14 +618,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_get (cmd_session_element_attribute_name (a_session_id,id,name))
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
element_equals (a_session_id: STRING_32; id : STRING_32; other : STRING_32) : SE_RESPONSE
@@ -922,14 +629,7 @@ feature -- Commands
do
create Result.make_empty
resp := execute_get (cmd_session_element_equals (a_session_id,id,other))
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
is_displayed (a_session_id: STRING_32; id : STRING_32) : SE_RESPONSE
@@ -940,16 +640,90 @@ feature -- Commands
do
create Result.make_empty
resp := execute_get (cmd_session_element_displayed (a_session_id,id))
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
Result := new_response (l_body)
end
end
Result := new_response (a_session_id, resp)
end
element_location (a_session_id: STRING_32; id : STRING_32) : SE_RESPONSE
require
selinum_server_available: is_available
local
resp: HTTP_CLIENT_RESPONSE
do
create Result.make_empty
resp := execute_get (cmd_session_element_location (a_session_id,id))
Result := new_response (a_session_id, resp)
end
location_in_view (a_session_id: STRING_32; id : STRING_32) : SE_RESPONSE
require
selinum_server_available: is_available
local
resp: HTTP_CLIENT_RESPONSE
do
create Result.make_empty
resp := execute_get (cmd_session_element_location_in_view (a_session_id,id))
Result := new_response (a_session_id, resp)
end
element_size (a_session_id: STRING_32; id : STRING_32) : SE_RESPONSE
require
selinum_server_available: is_available
local
resp: HTTP_CLIENT_RESPONSE
do
create Result.make_empty
resp := execute_get (cmd_session_element_size (a_session_id,id))
Result := new_response (a_session_id, resp)
end
element_css_value (a_session_id: STRING_32; id : STRING_32; property_name : STRING_32) : SE_RESPONSE
require
selinum_server_available: is_available
local
resp: HTTP_CLIENT_RESPONSE
do
create Result.make_empty
resp := execute_get (cmd_session_element_css_value (a_session_id,id, property_name))
Result := new_response (a_session_id, resp)
end
retrieve_browser_orientation (a_session_id: STRING_32) : SE_RESPONSE
require
selinum_server_available: is_available
local
resp: HTTP_CLIENT_RESPONSE
do
create Result.make_empty
resp := execute_get (cmd_session_browser_orientation (a_session_id))
Result := new_response (a_session_id, resp)
end
set_browser_orientation (a_session_id: STRING_32; data : STRING_32) : SE_RESPONSE
require
selinum_server_available: is_available
local
resp: HTTP_CLIENT_RESPONSE
do
create Result.make_empty
resp := execute_post (cmd_session_browser_orientation (a_session_id), data)
Result := new_response (a_session_id, resp)
end
retrieve_alert_text (a_session_id: STRING_32) : SE_RESPONSE
require
selinum_server_available: is_available
local
resp: HTTP_CLIENT_RESPONSE
do
create Result.make_empty
resp := execute_get (cmd_session_alert_text (a_session_id))
Result := new_response (a_session_id, resp)
end
feature {NONE} -- Implementation
@@ -968,13 +742,22 @@ feature {NONE} -- Implementation
Result := http_session.delete (command_name, context_executor)
end
new_response (a_message: STRING_32): SE_RESPONSE
new_response (a_session_id : STRING_32; resp: HTTP_CLIENT_RESPONSE): SE_RESPONSE
-- Create a new Selenium Response based on `resp' HTTP_RESPONSE
-- todo improve it!!!
do
create Result.make_empty
if attached json_to_se_response(a_message) as l_response then
Result := l_response
if resp.status = 204 then
Result.set_status (0)
Result.set_session_id (a_session_id)
else
if attached resp.body as l_body then
if attached json_to_se_response(l_body) as l_response then
Result := l_response
end
Result.set_json_response (l_body)
end
end
Result.set_json_response (a_message)
end
context_executor: HTTP_CLIENT_REQUEST_CONTEXT

View File

@@ -0,0 +1,19 @@
note
description: "Summary description for {HTTP_METHODS}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
HTTP_METHODS
feature -- Method Names
OPTIONS : STRING_32 = "OPTIONS"
GET : STRING_32 = "GET"
HEAD : STRING_32 = "HEAD"
POST : STRING_32 = "POST"
PUT : STRING_32 = "PUT"
DELETE : STRING_32 = "DELETE"
TRACE : STRING_32 = "TRACE"
CONNECT : STRING_32 = "CONNECT"
end

View File

@@ -1437,7 +1437,7 @@ feature -- Commands
end
end
element_location (a_session_id: STRING_32; an_id: STRING_32)
element_location (a_session_id: STRING_32; an_id: STRING_32): SE_WINDOW
-- GET /session/:sessionId/element/:id/location
-- Determine an element's location on the page. The point (0, 0) refers to the upper-left corner of the page.
-- The element's coordinates are returned as a JSON object with x and y properties.
@@ -1449,10 +1449,27 @@ feature -- Commands
-- Potential Errors:
-- NoSuchWindow - If the currently selected window has been closed.
-- StaleElementReference - If the element referenced by :id is no longer attached to the page's DOM.
local
resp: SE_RESPONSE
do
create Result
if commnad_executor.is_available then
resp := commnad_executor.element_location (a_session_id, an_id)
check_response (resp)
if not has_error then
if attached resp.value as l_value and then attached {JSON_OBJECT} string_to_json (l_value) as l_json_object then
if attached l_json_object.item ("x") as l_x then
Result.set_x (l_x.representation.to_integer_32)
end
if attached l_json_object.item ("y") as l_y then
Result.set_y (l_y.representation.to_integer_32)
end
end
end
end
end
is_location_in_view (a_session_id: STRING_32; an_id: STRING_32)
location_in_view (a_session_id: STRING_32; an_id: STRING_32): SE_WINDOW
-- GET /session/:sessionId/element/:id/location_in_view
-- Determine an element's location on the screen once it has been scrolled into view.
-- Note: This is considered an internal command and should only be used to determine an element's
@@ -1465,10 +1482,27 @@ feature -- Commands
-- Potential Errors:
-- NoSuchWindow - If the currently selected window has been closed.
-- StaleElementReference - If the element referenced by :id is no longer attached to the page's DOM.
local
resp: SE_RESPONSE
do
create Result
if commnad_executor.is_available then
resp := commnad_executor.location_in_view (a_session_id, an_id)
check_response (resp)
if not has_error then
if attached resp.value as l_value and then attached {JSON_OBJECT} string_to_json (l_value) as l_json_object then
if attached l_json_object.item ("x") as l_x then
Result.set_x (l_x.representation.to_integer_32)
end
if attached l_json_object.item ("y") as l_y then
Result.set_y (l_y.representation.to_integer_32)
end
end
end
end
end
element_size (a_session_id: STRING_32; an_id: STRING_32)
element_size (a_session_id: STRING_32; an_id: STRING_32): SE_WINDOW
-- GET /session/:sessionId/element/:id/size
-- Determine an element's size in pixels. The size will be returned as a JSON object with width and height properties.
-- URL Parameters:
@@ -1479,10 +1513,27 @@ feature -- Commands
-- Potential Errors:
-- NoSuchWindow - If the currently selected window has been closed.
-- StaleElementReference - If the element referenced by :id is no longer attached to the page's DOM.
local
resp: SE_RESPONSE
do
create Result
if commnad_executor.is_available then
resp := commnad_executor.element_size (a_session_id, an_id)
check_response (resp)
if not has_error then
if attached resp.value as l_value and then attached {JSON_OBJECT} string_to_json (l_value) as l_json_object then
if attached l_json_object.item ("width") as l_width then
Result.set_width (l_width.representation.to_natural)
end
if attached l_json_object.item ("height") as l_height then
Result.set_height (l_height.representation.to_natural)
end
end
end
end
end
element_css_value (a_session_id: STRING_32; an_id: STRING_32; a_property_name: STRING_32)
element_css_value (a_session_id: STRING_32; an_id: STRING_32; a_property_name: STRING_32): detachable STRING_32
-- GET /session/:sessionId/element/:id/css/:propertyName
-- Query the value of an element's computed CSS property. The CSS property to query should be specified using the CSS property name, not the JavaScript property name (e.g. background-color instead of backgroundColor).
-- URL Parameters:
@@ -1493,10 +1544,21 @@ feature -- Commands
-- Potential Errors:
-- NoSuchWindow - If the currently selected window has been closed.
-- StaleElementReference - If the element referenced by :id is no longer attached to the page's DOM.
local
resp: SE_RESPONSE
do
if commnad_executor.is_available then
resp := commnad_executor.element_css_value (a_session_id, an_id, a_property_name)
check_response (resp)
if not has_error then
if attached resp.value as l_value then
Result := l_value
end
end
end
end
retrieve_browser_orientation (a_session_id: STRING_32)
retrieve_browser_orientation (a_session_id: STRING_32): detachable STRING_32
-- GET /session/:sessionId/orientation
-- Get the current browser orientation. The server should return a valid orientation value as defined in ScreenOrientation: {LANDSCAPE|PORTRAIT}.
-- URL Parameters:
@@ -1505,10 +1567,24 @@ feature -- Commands
-- {string} The current browser orientation corresponding to a value defined in ScreenOrientation: {LANDSCAPE|PORTRAIT}.
-- Potential Errors:
-- NoSuchWindow - If the currently selected window has been closed.
local
resp: SE_RESPONSE
do
if commnad_executor.is_available then
resp := commnad_executor.retrieve_browser_orientation (a_session_id)
check_response (resp)
if not has_error then
if attached resp.value as l_value then
Result := l_value
end
end
end
--ensure
-- if not has_error, has_valid_orientation (LANDSCAPE|PORTRAIT)
-- not_has_error : not has_error implies has_valid_orientation ()
end
set_browser_orientation (a_session_id: STRING_32)
set_browser_orientation (a_session_id: STRING_32; orientation: STRING_32)
-- POST /session/:sessionId/orientation
-- Set the browser orientation. The orientation should be specified as defined in ScreenOrientation: {LANDSCAPE|PORTRAIT}.
-- URL Parameters:
@@ -1517,10 +1593,23 @@ feature -- Commands
-- orientation - {string} The new browser orientation as defined in ScreenOrientation: {LANDSCAPE|PORTRAIT}.
-- Potential Errors:
-- NoSuchWindow - If the currently selected window has been closed.
require
valid_orientation: orientation.is_case_insensitive_equal ("LANDSCAPE") or else orientation.is_case_insensitive_equal ("PORTRAIT")
local
resp: SE_RESPONSE
l_json: STRING_32
do
l_json := "[
{"orientation" : "$orientation"}
]"
if commnad_executor.is_available then
l_json.replace_substring_all ("$orientation", orientation)
resp := commnad_executor.set_browser_orientation (a_session_id, l_json)
check_response (resp)
end
end
retrieve_alert_text (a_session_id: STRING_32)
retrieve_alert_text (a_session_id: STRING_32): detachable STRING_32
-- GET /session/:sessionId/alert_text
-- Gets the text of the currently displayed JavaScript alert(), confirm(), or prompt() dialog.
-- URL Parameters:
@@ -1529,7 +1618,18 @@ feature -- Commands
-- {string} The text of the currently displayed alert.
-- Potential Errors:
-- NoAlertPresent - If there is no alert displayed.
local
resp: SE_RESPONSE
do
if commnad_executor.is_available then
resp := commnad_executor.retrieve_alert_text (a_session_id)
check_response (resp)
if not has_error then
if attached resp.value as l_value then
Result := l_value
end
end
end
end
send_alert_text (a_session_id: STRING_32)

View File

@@ -409,16 +409,61 @@ feature
Result.replace_substring_all ("$id", id)
end
cmd_session_element_location_tmpl : STRING ="session/$sessionId/element/$id/location"
cmd_session_element_location (sessionId: STRING_32; id : STRING_32): STRING_32
do
create Result.make_from_string (cmd_session_element_location_tmpl)
Result.replace_substring_all ("$sessionId", sessionId)
Result.replace_substring_all ("$id", id)
end
cmd_session_element_location_in_view_tmpl : STRING ="session/$sessionId/element/$id/location_in_view"
cmd_session_element_location_in_view (sessionId: STRING_32; id : STRING_32): STRING_32
do
create Result.make_from_string (cmd_session_element_location_in_view_tmpl)
Result.replace_substring_all ("$sessionId", sessionId)
Result.replace_substring_all ("$id", id)
end
cmd_session_element_size_tmpl : STRING ="session/$sessionId/element/$id/size"
cmd_session_element_size (sessionId: STRING_32; id : STRING_32): STRING_32
do
create Result.make_from_string (cmd_session_element_size_tmpl)
Result.replace_substring_all ("$sessionId", sessionId)
Result.replace_substring_all ("$id", id)
end
cmd_session_element_css_value_tmpl : STRING ="session/$sessionId/element/$id/css/$propertyName"
cmd_session_element_css_value (sessionId: STRING_32; id : STRING_32; property_name : STRING_32): STRING_32
do
create Result.make_from_string (cmd_session_element_css_value_tmpl)
Result.replace_substring_all ("$sessionId", sessionId)
Result.replace_substring_all ("$id", id)
Result.replace_substring_all ("$propertyName", property_name)
end
cmd_session_browser_orientation_tmpl : STRING ="session/$sessionId/orientation"
cmd_session_browser_orientation (sessionId: STRING_32): STRING_32
do
create Result.make_from_string (cmd_session_browser_orientation_tmpl)
Result.replace_substring_all ("$sessionId", sessionId)
end
cmd_session_alert_text_tmpl : STRING ="session/$sessionId/alert_text"
cmd_session_alert_text (sessionId: STRING_32): STRING_32
do
create Result.make_from_string (cmd_session_alert_text_tmpl)
Result.replace_substring_all ("$sessionId", sessionId)
end
--GET /session/:sessionId/element/:id/displayed Determine if an element is currently displayed.
--GET /session/:sessionId/element/:id/location Determine an element's location on the page.
--GET /session/:sessionId/element/:id/location_in_view Determine an element's location on the screen once it has been scrolled into view.
--GET /session/:sessionId/element/:id/size Determine an element's size in pixels.
--GET /session/:sessionId/element/:id/css/:propertyName Query the value of an element's computed CSS property.
--GET /session/:sessionId/orientation Get the current browser orientation.
--POST /session/:sessionId/orientation Set the browser orientation.
--GET /session/:sessionId/alert_text Gets the text of the currently displayed JavaScript alert(), confirm(), or prompt() dialog.
--POST /session/:sessionId/alert_text Sends keystrokes to a JavaScript prompt() dialog.
--POST /session/:sessionId/accept_alert Accepts the currently displayed alert dialog.
--POST /session/:sessionId/dismiss_alert Dismisses the currently displayed alert dialog.
--POST /session/:sessionId/moveto Move the mouse by an offset of the specificed element.

View File

@@ -0,0 +1,129 @@
note
description: "Summary description for {SE_KEY_STROKE}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
SE_KEY_STROKE
feature -- Access
Null_key: STRING_32 = "\uE000"
Cancel_key: STRING_32 = "\uE001"
Help_key: STRING_32 = "\uE002"
Backspace_key: STRING_32 = "\uE003"
Tab_key: STRING_32 = "\uE004"
Clear_key: STRING_32 = "\uE005"
Return_key: STRING_32 = "\uE006"
Enter_key: STRING_32 = "\uE007"
Shift_key: STRING_32 = "\uE008"
Control_key: STRING_32 = "\uE009"
Alt_key: STRING_32 = "\uE00A"
Pause_key: STRING_32 = "\uE00B"
Escape_key: STRING_32 = "\uE00C"
Space_key: STRING_32 = "\uE00D"
PageUp_key: STRING_32 = "\uE00E"
PageDown_key: STRING_32 = "\uE00F"
End_key: STRING_32 = "\uE010"
Home_key: STRING_32 = "\uE011"
LeftArrow_key: STRING_32 = "\uE012"
UpArrow_key: STRING_32 = "\uE013"
RightArrow_key: STRING_32 = "\uE014"
DownArrow_key: STRING_32 = "\uE015"
Insert_key: STRING_32 = "\uE016"
Delete_key: STRING_32 = "\uE017"
Semicolon_key: STRING_32 = "\uE018"
Equals_key: STRING_32 = "\uE019"
Numpad0_key: STRING_32 = "\uE01A"
Numpad1_key: STRING_32 = "\uE01B"
Numpad2_key: STRING_32 = "\uE01C"
Numpad3_key: STRING_32 = "\uE01D"
Numpad4_key: STRING_32 = "\uE01E"
Numpad5_key: STRING_32 = "\uE01F"
Numpad6_key: STRING_32 = "\uE020"
Numpad7_key: STRING_32 = "\uE021"
Numpad8_key: STRING_32 = "\uE022"
Numpad9_key: STRING_32 = "\uE023"
Multiply_key: STRING_32 = "\uE024"
Add_key: STRING_32 = "\uE025"
Separator_key: STRING_32 = "\uE026"
Subtract_key: STRING_32 = "\uE027"
Decimal_key: STRING_32 = "\uE028"
Divide_key: STRING_32 = "\uE029"
F1_key: STRING_32 = "\uE031"
F2_key: STRING_32 = "\uE032"
F3_key: STRING_32 = "\uE033"
F4_key: STRING_32 = "\uE034"
F5_key: STRING_32 = "\uE035"
F6_key: STRING_32 = "\uE036"
F7_key: STRING_32 = "\uE037"
F8_key: STRING_32 = "\uE038"
F9_key: STRING_32 = "\uE039"
F10_key: STRING_32 = "\uE03A"
F11_key: STRING_32 = "\uE03B"
F12_key: STRING_32 = "\uE03C"
Command_key: STRING_32 = "\uE03D"
Meta_key: STRING_32 = "\uE03D"
keys: ARRAY [STRING_32]
once
Result := <<Null_key, Cancel_key, Help_key, Backspace_key, Tab_key, Clear_key, Return_key, Enter_key, Shift_key, Control_key, Alt_key, Pause_key, Escape_key, Space_key, PageUp_key, PageDown_key, End_key, Home_key, LeftArrow_key, UpArrow_key, RightArrow_key, DownArrow_key, Insert_key, Delete_key, Semicolon_key, Equals_key, Numpad0_key, Numpad1_key, Numpad2_key, Numpad3_key, Numpad4_key, Numpad5_key, Numpad6_key, Numpad7_key, Numpad8_key, Numpad9_key, Multiply_key, Add_key, Separator_key, Subtract_key, Decimal_key, Divide_key, F1_key, F2_key, F3_key, F4_key, F5_key, F6_key, F7_key, F8_key, F9_key, F10_key, F11_key, F12_key, Command_key, Meta_key>>
end
end

View File

@@ -0,0 +1,12 @@
note
description: "Summary description for {SE_SCREEN_ORIENTATION}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
SE_SCREEN_ORIENTATION
-- {LANDSCAPE|PORTRAIT}
end