Added command POST /session/:sessionId/modifier

Initial implementation of KeyBoard.
Added Mouse class, but not implemented.
This commit is contained in:
jvelilla
2013-05-29 09:43:14 -03:00
parent 7dbed3ade1
commit 63beaabfa0
9 changed files with 302 additions and 148 deletions

View File

@@ -6,60 +6,63 @@ note
class
EXAMPLE_SEARCH
inherit
ANY
inherit
ANY
redefine
default_create
end
feature
default_create
default_create
do
search
end
feature -- Example
search
local
web_driver : WEB_DRIVER
wait : WEB_DRIVER_WAIT
web_driver: WEB_DRIVER
wait: WEB_DRIVER_WAIT
do
--Create a new instance of a Web driver
create web_driver.make
--Create a new instance of a Web driver
create web_driver.make
-- Start session with chrome
web_driver.start_session_chrome
-- Start session with chrome
web_driver.start_session_chrome
-- Go to Google
web_driver.to_url ("http://www.google.com/")
-- Go to Google
web_driver.to_url ("http://www.google.com/")
-- Find the text input element by its name
if attached web_driver.find_element ((create{SE_BY}).name ("q")) as l_element then
-- Find the text input element by its name
if attached web_driver.find_element ((create {SE_BY}).name ("q")) as l_element then
-- Enter something to search for
l_element.send_keys(<<"Eiffel Room">>)
-- Enter something to search for
l_element.send_keys (<<"Eiffel Room">>)
-- Now submit the form. WebDriver will find the form for us from the element
l_element.submit
-- Now submit the form. WebDriver will find the form for us from the element
l_element.submit
end
if attached web_driver.get_page_tile as l_title then
print ("%NPage title is:" + l_title)
end
end
if attached web_driver.get_page_tile as l_title then
print ("%NPage title is:" + l_title)
end
-- Google's search is rendered dynamically with JavaScript.
-- Wait for the page to load, timeout after 10 seconds
create wait.make (web_driver, 10)
wait.until_when (agent expected_title(web_driver, "Eiffel Room"))
if attached web_driver.get_page_tile as l_title then
print ("%NPage title is:" + l_title)
end
-- Google's search is rendered dynamically with JavaScript.
-- Wait for the page to load, timeout after 10 seconds
create wait.make (web_driver,10)
wait.until_when (agent expected_title (web_driver, "Eiffel Room"))
if attached web_driver.get_page_tile as l_title then
print ("%NPage title is:" + l_title)
end
-- close the window
-- close the window
web_driver.window_close
end
expected_title (driver : WEB_DRIVER; title : STRING_32) : BOOLEAN
expected_title (driver: WEB_DRIVER; title: STRING_32): BOOLEAN
do
if attached {STRING_32} driver.get_page_tile as l_title and then l_title.has_substring (title) then
Result := True

View File

@@ -700,6 +700,17 @@ feature -- Commands
Result := new_response (a_session_id, resp)
end
modifier (a_session_id: STRING_32; data: STRING_32): SE_RESPONSE
require
selinum_server_available: is_available
local
resp: HTTP_CLIENT_RESPONSE
do
resp := execute_post (cmd_session_modifier (a_session_id), data)
Result := new_response (a_session_id, resp)
end
click (a_session_id: STRING_32; data: STRING_32): SE_RESPONSE
require
selinum_server_available: is_available

View File

@@ -1736,6 +1736,21 @@ feature -- Commands
end
end
modifier (a_session_id: STRING_32; data: STRING)
-- POST /session/:sessionId/modifier
-- Not documented
-- For info look
-- http://grepcode.com/file/repo1.maven.org/maven2/org.seleniumhq.selenium/selenium-remote-driver/2.0.0/org/openqa/selenium/remote/HttpCommandExecutor.java?av=h#HttpCommandExecutor
local
resp : SE_RESPONSE
do
if commnad_executor.is_available then
resp := commnad_executor.modifier (a_session_id, data)
check_response (resp)
end
end
click (a_session_id: STRING_32; button : SE_BUTTON )
-- POST /session/:sessionId/click
-- Click any mouse button (at the coordinates set by the last moveto command). Note that calling this command after calling buttondown and before calling button up (or any out-of-order interactions sequence) will yield undefined behaviour).

View File

@@ -485,6 +485,15 @@ feature
Result.replace_substring_all ("$sessionId", sessionId)
end
cmd_session_modifier_tmpl : STRING = "/session/$sessionId/modifier"
cmd_session_modifier (sessionId: STRING_32): STRING_32
do
create Result.make_from_string (cmd_session_modifier_tmpl)
Result.replace_substring_all ("$sessionId", sessionId)
end
cmd_session_click_tmpl: STRING = "session/$sessionId/click"
cmd_session_click (sessionId: STRING_32): STRING_32

View File

@@ -0,0 +1,128 @@
note
description: "Summary description for {SE_KEY_CONSTANTS}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
SE_KEY_CONSTANTS
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

@@ -7,123 +7,38 @@ note
class
SE_KEY_STROKE
inherit
SE_KEY_CONSTANTS
create
make
feature {NONE} -- Initialization
make (a_key: STRING_32)
require
is_valid: keys.has (a_key)
do
set_key (a_key)
ensure
end
feature -- Access
Null_key: STRING_32 = "\uE000"
key: STRING_32
-- current key
Cancel_key: STRING_32 = "\uE001"
feature -- Change Element
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>>
set_key (a_key: STRING_32)
--Set `key' to `a_key'
require
is_valid: keys.has (a_key)
do
key := a_key
ensure
key_set: key = a_key
end
end

View File

@@ -0,0 +1,63 @@
note
description: "Objects representing basic keyboards operations"
author: ""
date: "$Date$"
revision: "$Revision$"
class
SE_KEYBOARD
create
make
feature {NONE} -- Initialization
make ( a_web_driver : like driver)
-- Create an object se_keyboard with his driver
do
driver := a_web_driver
ensure
web_driver_set : driver = a_web_driver
end
feature --Access
send_keys (keys : ARRAY[STRING_32])
do
if attached driver.active_element as l_active_element then
l_active_element.send_keys (keys)
end
end
press_key ( key : SE_KEY_STROKE)
local
l_data : STRING_32
do
create l_data.make_from_string (json_template)
l_data.replace_substring_all ("$value", key.key)
l_data.replace_substring_all ("$boolean", "True")
if attached driver.session as l_session then
driver.api.modifier (l_session.session_id, l_data)
end
end
release_key ( key : SE_KEY_STROKE)
local
l_data : STRING_32
do
create l_data.make_from_string (json_template)
l_data.replace_substring_all ("$value", key.key)
l_data.replace_substring_all ("$boolean", "False")
if attached driver.session as l_session then
driver.api.modifier (l_session.session_id, l_data )
end
end
feature {NONE} -- Implementation
driver : WEB_DRIVER
-- web_driver
json_template : String = "[
{"value" :"$value",
"isdown" : $boolean}
]"
end

View File

@@ -0,0 +1,11 @@
note
description: "Summary description for {SE_MOUSE}."
author: ""
date: "$Date$"
revision: "$Revision$"

View File

@@ -476,12 +476,11 @@ feature {WEB_DRIVER, WEB_DRIVER_WAIT}
end
end
feature {NONE} -- Implementation
feature {SE_KEYBOARD} -- Implementation
session: detachable SE_SESSION
status: BOOLEAN
api: SE_JSON_WIRE_PROTOCOL
end