Added new classes, implemented more methods from JSONWireProtol API.

Added test cases
This commit is contained in:
jvelilla
2013-04-22 09:15:50 -03:00
parent c344ecceec
commit 3c41ca0864
14 changed files with 1364 additions and 158 deletions

View File

@@ -396,6 +396,342 @@ feature -- Commands
end
change_focus_window (a_session_id: STRING_32; a_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_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
end
close_window (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_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
end
change_size_window (a_session_id: STRING_32; a_window_handle : STRING_32;a_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_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
end
size_window (a_session_id: STRING_32; a_window_handle : 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_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
end
change_window_position (a_session_id: STRING_32; a_window_handle : STRING_32;a_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_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
end
window_position (a_session_id: STRING_32; a_window_handle : 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_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
end
window_maximize (a_session_id: STRING_32; a_window_handle : 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_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
end
retrieve_cookies (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_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
end
set_cookie (a_session_id: STRING_32; a_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_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
end
delete_cookies (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_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
end
delete_cookie_by_name (a_session_id: STRING_32; a_name : STRING_32) : SE_RESPONSE
require
selinum_server_available: is_available
local
resp: HTTP_CLIENT_RESPONSE
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
end
page_source (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_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
end
page_title (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_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
end
search_element (a_session_id: STRING_32; a_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_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
end
search_element_id_element (a_session_id: STRING_32; id : STRING_32; a_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_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
end
search_elements (a_session_id: STRING_32; a_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_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
end
element_active (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_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
end
search_element_id_elements (a_session_id: STRING_32; id : STRING_32; a_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_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
end
feature {NONE} -- Implementation
execute_get (command_name: STRING_32): HTTP_CLIENT_RESPONSE

View File

@@ -0,0 +1,100 @@
note
description: "Summary description for {SE_COOKIE_JSON_CONVERTER}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
SE_COOKIE_JSON_CONVERTER
inherit
SE_JSON_CONVERTER
create
make
feature {NONE} -- Initialization
make
do
create object
end
feature -- Access
object: SE_COOKIE
feature -- Conversion
from_json (j: like to_json): detachable like object
do
create Result
if attached {STRING_32} json_to_object (j.item (name_key), Void) as l_item then
Result.set_name(l_item)
end
if attached {STRING_32} json_to_object (j.item (value_key), Void) as l_item then
Result.set_value(l_item)
end
if attached {STRING_32} json_to_object (j.item (path_key), Void) as l_item then
Result.set_path(l_item)
end
if attached {STRING_32} json_to_object (j.item (domain_key), Void) as l_item then
Result.set_domain(l_item)
end
if attached {BOOLEAN} json_to_object (j.item (secure_key), Void) as l_item then
if l_item then
Result.secure
end
end
if attached {INTEGER_32} json_to_object (j.item (expiry_key), Void) as l_item then
Result.set_expiry (l_item.as_natural_32)
end
end
to_json (o: like object): JSON_OBJECT
do
create Result.make
Result.put (json.value (o.name), name_key)
Result.put (json.value (o.value), value_key)
Result.put (json.value (o.path), path_key)
Result.put (json.value (o.domain), domain_key)
Result.put (json.value (o.is_secure), secure_key)
Result.put (json.value (o.expiry), expiry_key)
end
feature {NONE} -- Implementation
name_key: JSON_STRING
once
create Result.make_json ("name")
end
value_key: JSON_STRING
once
create Result.make_json ("value")
end
path_key: JSON_STRING
once
create Result.make_json ("path")
end
domain_key: JSON_STRING
once
create Result.make_json ("domain")
end
secure_key : JSON_STRING
once
create Result.make_json ("secure")
end
expiry_key : JSON_STRING
once
create Result.make_json ("expiry")
end
end

View File

@@ -71,6 +71,20 @@ feature -- Access
end
end
json_to_se_cookie (post: STRING_32): detachable SE_COOKIE
local
parser: JSON_PARSER
do
initialize_converters (json)
create parser.make_parser (post)
if attached parser.parse_object as st and parser.is_parsed then
if attached {SE_COOKIE} json.object (st, "SE_COOKIE") as l_cookie then
Result := l_cookie
end
end
end
initialize_converters (j: like json)
-- Initialize json converters
do
@@ -82,5 +96,6 @@ feature -- Access
j.add_converter (create {SE_CAPABILITIES_JSON_CONVERTER}.make)
j.add_converter (create {SE_RESPONSE_JSON_CONVERTER}.make)
j.add_converter (create {SE_TIMEOUT_TYPE_JSON_CONVERTER}.make)
j.add_converter (create {SE_COOKIE_JSON_CONVERTER}.make)
end
end

View File

@@ -3,7 +3,7 @@ note
author: ""
date: "$Date$"
revision: "$Revision$"
EIS: "name=SELINIUM", "protocol=http", "src=https://code.google.com/p/selenium/wiki/JsonWireProtocol"
EIS: "name=SELINIUM", "protocol=selenium", "src=https://code.google.com/p/selenium/wiki/JsonWireProtocol"
class
SE_JSON_WIRE_PROTOCOL
@@ -67,7 +67,7 @@ feature -- Commands
if attached response.json_response as l_response then
Result := json_to_se_status (l_response)
end
end
end
end
end
@@ -146,7 +146,7 @@ feature -- Commands
-- Returns:
-- {object} An object describing the session's capabilities.
local
response : SE_RESPONSE
response: SE_RESPONSE
do
if commnad_executor.is_available then
response := commnad_executor.retrieve_session (a_session_id)
@@ -587,7 +587,6 @@ feature -- Commands
-- NoSuchWindow - If the currently selected window has been closed.
-- NoSuchFrame - If the frame specified by id cannot be found.
do
-- TODO
end
change_focus_window (a_session_id: STRING_32; a_name: STRING_32)
@@ -599,8 +598,18 @@ feature -- Commands
-- name - {string} The window to change focus to.
-- Potential Errors:
-- NoSuchWindow - If the window specified by name cannot be found.
local
l_json: STRING_32
resp: SE_RESPONSE
do
-- TODO
l_json := "[
{ "name": "$name" }
]"
l_json.replace_substring_all ("$name", a_name)
if commnad_executor.is_available then
resp := commnad_executor.change_focus_window (a_session_id, l_json)
check_response (resp)
end
end
close_window (a_session_id: STRING_32)
@@ -610,11 +619,16 @@ feature -- Commands
-- :sessionId - ID of the session to route the command to.
-- Potential Errors:
-- NoSuchWindow - If the currently selected window is already closed
local
resp: SE_RESPONSE
do
--TODO
if commnad_executor.is_available then
resp := commnad_executor.close_window (a_session_id)
check_response (resp)
end
end
change_size_window (a_session_id: STRING_32; a_window_handle: STRING_32)
change_size_window (a_session_id: STRING_32; a_window_handle: STRING_32; a_width: NATURAL_32; a_height: NATURAL_32)
-- POST /session/:sessionId/window/:windowHandle/size
-- Change the size of the specified window. If the :windowHandle URL parameter is "current", the currently active window will be resized.
-- URL Parameters:
@@ -622,10 +636,24 @@ feature -- Commands
-- JSON Parameters:
-- width - {number} The new window width.
-- height - {number} The new window height.
local
l_json: STRING_32
resp: SE_RESPONSE
do
l_json := "[
{ "width": $width,
"height": $height
}
]"
l_json.replace_substring_all ("$width", a_width.out)
l_json.replace_substring_all ("$height", a_height.out)
if commnad_executor.is_available then
resp := commnad_executor.change_size_window (a_session_id, a_window_handle, l_json)
check_response (resp)
end
end
size_window (a_session_id: STRING_32; a_window_handle: STRING_32)
size_window (a_session_id: STRING_32; a_window_handle: STRING_32): SE_WINDOW
-- GET /session/:sessionId/window/:windowHandle/size
-- Get the size of the specified window. If the :windowHandle URL parameter is "current", the size of the currently active window will be returned.
-- URL Parameters:
@@ -634,11 +662,27 @@ feature -- Commands
-- {width: number, height: number} The size of the window.
-- Potential Errors:
-- NoSuchWindow - If the specified window cannot be found.
local
resp: SE_RESPONSE
do
--TODO
create Result
if commnad_executor.is_available then
resp := commnad_executor.size_window (a_session_id, a_window_handle)
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_32)
end
if attached l_json_object.item ("height") as l_height then
Result.set_width (l_height.representation.to_natural_32)
end
end
end
end
end
change_window_position (a_session_id: STRING_32; a_window_handle: STRING_32)
change_window_position (a_session_id: STRING_32; a_window_handle: STRING_32; an_x: INTEGER_32; an_y: INTEGER_32)
-- POST /session/:sessionId/window/:windowHandle/position
-- Change the position of the specified window. If the :windowHandle URL parameter is "current", the currently active window will be moved.
-- URL Parameters:
@@ -648,11 +692,24 @@ feature -- Commands
-- y - {number} The Y coordinate to position the window at, relative to the upper left corner of the screen.
-- Potential Errors:
-- NoSuchWindow - If the specified window cannot be found.
local
l_json: STRING_32
resp: SE_RESPONSE
do
-- TODO
l_json := "[
{ "x": $x,
"y": $y
}
]"
l_json.replace_substring_all ("$x", an_x.out)
l_json.replace_substring_all ("$y", an_y.out)
if commnad_executor.is_available then
resp := commnad_executor.change_window_position (a_session_id, a_window_handle, l_json)
check_response (resp)
end
end
window_position (a_sesion_id: STRING_32; a_window_handle: STRING_32)
window_position (a_session_id: STRING_32; a_window_handle: STRING_32): SE_WINDOW
-- GET /session/:sessionId/window/:windowHandle/position
-- Get the position of the specified window. If the :windowHandle URL parameter is "current", the position of the currently active window will be returned.
-- URL Parameters:
@@ -661,21 +718,43 @@ feature -- Commands
-- {x: number, y: number} The X and Y coordinates for the window, relative to the upper left corner of the screen.
-- Potential Errors:
-- NoSuchWindow - If the specified window cannot be found.
local
resp: SE_RESPONSE
do
--TODO
create Result
if commnad_executor.is_available then
resp := commnad_executor.window_position (a_session_id, a_window_handle)
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
window_maximize (a_session_id: STRING_32; a_window_haNdle: STRING_32)
window_maximize (a_session_id: STRING_32; a_window_handle: STRING_32)
-- POST /session/:sessionId/window/:windowHandle/maximize
-- Maximize the specified window if not already maximized. If the :windowHandle URL parameter is "current", the currently active window will be maximized.
-- URL Parameters:
-- :sessionId - ID of the session to route the command to.
-- Potential Errors:
-- NoSuchWindow - If the specified window cannot be found.
local
resp: SE_RESPONSE
do
if commnad_executor.is_available then
resp := commnad_executor.window_maximize (a_session_id, a_window_handle)
check_response (resp)
end
end
retrieve_cookies (a_session_id: STRING_32)
retrieve_cookies (a_session_id: STRING_32): detachable LIST [SE_COOKIE]
-- GET /session/:sessionId/cookie
-- Retrieve all cookies visible to the current page.
-- URL Parameters:
@@ -684,18 +763,55 @@ feature -- Commands
-- {Array.<object>} A list of cookies.
-- Potential Errors:
-- NoSuchWindow - If the currently selected window has been closed.
local
resp: SE_RESPONSE
index: INTEGER
do
-- Check the format of internal json object
if commnad_executor.is_available then
resp := commnad_executor.retrieve_cookies (a_session_id)
check_response (resp)
if not has_error then
if attached resp.value as l_value and then attached {JSON_ARRAY} string_to_json (l_value) as l_json_array then
create {ARRAYED_LIST [SE_COOKIE]} Result.make (10)
from
index := 1
until
index > l_json_array.count
loop
if attached {JSON_VALUE} l_json_array.i_th (index) as json_str then
if attached json_to_se_cookie (json_str.representation) as l_item then
Result.force (l_item)
end
end
index := index + 1
end
end
end
end
end
set_cookie (a_session_id: STRING_32)
set_cookie (a_session_id: STRING_32; a_cookie: SE_COOKIE)
-- POST /session/:sessionId/cookie
-- Set a cookie. If the cookie path is not specified, it should be set to "/". Likewise, if the domain is omitted, it should default to the current page's domain.
-- URL Parameters:
-- :sessionId - ID of the session to route the command to.
-- JSON Parameters:
-- cookie - {object} A JSON object defining the cookie to add.
local
l_data: STRING_32
response: SE_RESPONSE
do
-- TODO
l_data := "[
{ "cookie": $cookie}
]"
if commnad_executor.is_available then
if attached to_json (a_cookie) as l_json then
l_data.replace_substring_all ("$cookie", l_json.representation)
response := commnad_executor.set_cookie (a_session_id, l_data)
check_response (response)
end
end
end
delete_cookies (a_session_id: STRING_32)
@@ -707,8 +823,13 @@ feature -- Commands
-- InvalidCookieDomain - If the cookie's domain is not visible from the current page.
-- NoSuchWindow - If the currently selected window has been closed.
-- UnableToSetCookie - If attempting to set a cookie on a page that does not support cookies (e.g. pages with mime-type text/plain).
local
response: SE_RESPONSE
do
-- TODO
if commnad_executor.is_available then
response := commnad_executor.delete_cookies (a_session_id)
check_response (response)
end
end
delete_cookie_by_name (a_session_id: STRING_32; a_name: STRING_32)
@@ -719,11 +840,16 @@ feature -- Commands
-- :name - The name of the cookie to delete.
-- Potential Errors:
-- NoSuchWindow - If the currently selected window has been closed.
local
response: SE_RESPONSE
do
-- TODO
if commnad_executor.is_available then
response := commnad_executor.delete_cookie_by_name (a_session_id, a_name)
check_response (response)
end
end
page_source (a_session_id: STRING_32)
page_source (a_session_id: STRING_32): detachable STRING_32
-- GET /session/:sessionId/source
-- Get the current page source.
-- URL Parameters:
@@ -732,10 +858,21 @@ feature -- Commands
-- {string} The current page source.
-- 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.page_source (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
page_title (a_session_id: STRING_32)
page_title (a_session_id: STRING_32): detachable STRING_32
-- GET /session/:sessionId/title
-- Get the current page title.
-- URL Parameters:
@@ -744,11 +881,21 @@ feature -- Commands
-- {string} The current page title.
-- Potential Errors:
-- NoSuchWindow - If the currently selected window has been closed.
local
resp: SE_RESPONSE
do
-- TODO
if commnad_executor.is_available then
resp := commnad_executor.page_title (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
search_element (a_session_id: STRING_32)
search_element (a_session_id: STRING_32; strategy: STRING_32): detachable WEB_ELEMENT
-- POST /session/:sessionId/element
-- Search for an element on the page, starting from the document root. The located element will be returned as a
-- WebElement JSON object. The table below lists the locator strategies that each server should support.
@@ -775,11 +922,23 @@ feature -- Commands
-- NoSuchWindow - If the currently selected window has been closed.
-- NoSuchElement - If the element cannot be found.
-- XPathLookupError - If using XPath and the input expression is invalid.
require
has_valid_strategy : (create {SE_BY}).is_valid_strategy (strategy)
local
resp: SE_RESPONSE
do
-- TODO
if commnad_executor.is_available then
resp := commnad_executor.search_element (a_session_id, strategy)
check_response (resp)
if not has_error then
if attached {JSON_OBJECT} resp.value as l_value and then attached l_value.item ("ELEMENT") as l_elem then
create Result.make (l_elem.representation)
end
end
end
end
search_elements (a_session_id: STRING_32)
search_elements (a_session_id: STRING_32; strategy: STRING_32): detachable LIST [WEB_ELEMENT]
-- POST /session/:sessionId/elements
-- Search for multiple elements on the page, starting from the document root. The located elements will be returned as a WebElement JSON objects. The table below lists the locator strategies that each server should support. Elements should be returned in the order located in the DOM.
--
@@ -803,10 +962,34 @@ feature -- Commands
-- Potential Errors:
-- NoSuchWindow - If the currently selected window has been closed.
-- XPathLookupError - If using XPath and the input expression is invalid.
require
has_valid_strategy : (create {SE_BY}).is_valid_strategy (strategy)
local
resp: SE_RESPONSE
index: INTEGER
do
if commnad_executor.is_available then
resp := commnad_executor.search_elements (a_session_id, strategy)
check_response (resp)
if not has_error then
if attached resp.value as l_value and then attached {JSON_ARRAY} string_to_json (l_value) as l_json_array then
create {ARRAYED_LIST [WEB_ELEMENT]} Result.make (10)
from
index := 1
until
index > l_json_array.count
loop
if attached {JSON_OBJECT} l_json_array.i_th (index) as json_str and then attached json_str.item ("ELEMENT") as l_elem then
Result.force (create {WEB_ELEMENT}.make (l_elem.representation))
end
index := index + 1
end
end
end
end
end
element_active (a_session_id: STRING_32)
element_active (a_session_id: STRING_32): detachable WEB_ELEMENT
-- POST /session/:sessionId/element/active
-- Get the element on the page that currently has focus. The element will be returned as a WebElement JSON object.
-- URL Parameters:
@@ -815,24 +998,35 @@ feature -- Commands
-- {ELEMENT:string} A WebElement JSON object for the active element.
-- 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.element_active (a_session_id)
check_response (resp)
if not has_error then
if attached {JSON_OBJECT} resp.value as l_value and then attached l_value.item ("ELEMENT") as l_elem then
create Result.make (l_elem.representation)
end
end
end
end
element_id (a_session_id: STRING_32)
-- GET /session/:sessionId/element/:id
-- Describe the identified element.
-- Note: This command is reserved for future use; its return type is currently undefined.
-- element_id (a_session_id: STRING_32; )
-- -- GET /session/:sessionId/element/:id
-- -- Describe the identified element.
-- -- Note: This command is reserved for future use; its return type is currently undefined.
-- URL Parameters:
-- :sessionId - ID of the session to route the command to.
-- :id - ID of the element to route the command to.
-- 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.
do
end
-- -- URL Parameters:
-- -- :sessionId - ID of the session to route the command to.
-- -- :id - ID of the element to route the command to.
-- -- 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.
-- do
-- end
search_element_id (a_session_id: STRING_32; an_id: STRING_32)
search_element_id_element (a_session_id: STRING_32; an_id: STRING_32; strategy : STRING_32) : detachable WEB_ELEMENT
-- POST /session/:sessionId/element/:id/element
-- Search for an element on the page, starting from the identified element.
-- The located element will be returned as a WebElement JSON object.
@@ -862,10 +1056,24 @@ feature -- Commands
-- StaleElementReference - If the element referenced by :id is no longer attached to the page's DOM.
-- NoSuchElement - If the element cannot be found.
-- XPathLookupError - If using XPath and the input expression is invalid.
require
has_valid_strategy : (create {SE_BY}).is_valid_strategy (strategy)
local
resp: SE_RESPONSE
do
if commnad_executor.is_available then
resp := commnad_executor.search_element_id_element (a_session_id,an_id,strategy)
check_response (resp)
if not has_error then
if attached {JSON_OBJECT} resp.value as l_value and then attached l_value.item ("ELEMENT") as l_elem then
create Result.make (l_elem.representation)
end
end
end
end
search_elements_id (a_session_id: STRING_32; an_id: STRING_32)
search_elements_id (a_session_id: STRING_32; an_id: STRING_32; strategy : STRING_32) : detachable LIST[WEB_ELEMENT]
-- POST /session/:sessionId/element/:id/elements
-- Search for multiple elements on the page, starting from the identified element.
-- The located elements will be returned as a WebElement JSON objects.
@@ -894,7 +1102,21 @@ feature -- Commands
-- 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.
-- XPathLookupError - If using XPath and the input expression is invalid.
require
has_valid_strategy : (create {SE_BY}).is_valid_strategy (strategy)
local
resp : SE_RESPONSE
do
if commnad_executor.is_available then
resp := commnad_executor.search_element_id_elements (a_session_id,an_id,strategy)
check_response (resp)
if not has_error then
-- if attached {JSON_OBJECT} resp.value as l_value and then attached l_value.item ("ELEMENT") as l_elem then
-- create Result.make (l_elem.representation)
-- end
end
end
end
element_click (a_session_id: STRING_32; an_id: STRING_32)
@@ -1604,7 +1826,7 @@ feature {NONE} -- Implementation
new_session (value: STRING_32; to: STRING_32): detachable SE_SESSION
local
l_rep : STRING_32
l_rep: STRING_32
do
if to.is_case_insensitive_equal ("session") then
if attached {JSON_OBJECT} string_to_json (value) as l_value then

View File

@@ -163,26 +163,137 @@ feature
--POST /session/:sessionId/ime/activate Make an engines that is available (appears on the listreturned by getAvailableEngines) active.
--POST /session/:sessionId/frame Change focus to another frame on the page.
--POST /session/:sessionId/window Change focus to another window.
--DELETE /session/:sessionId/window Close the current window.
--POST /session/:sessionId/window/:windowHandle/size Change the size of the specified window.
--GET /session/:sessionId/window/:windowHandle/size Get the size of the specified window.
--POST /session/:sessionId/window/:windowHandle/position Change the position of the specified window.
--GET /session/:sessionId/window/:windowHandle/position Get the position of the specified window.
--POST /session/:sessionId/window/:windowHandle/maximize Maximize the specified window if not already maximized.
--GET /session/:sessionId/cookie Retrieve all cookies visible to the current page.
--POST /session/:sessionId/cookie Set a cookie.
--DELETE /session/:sessionId/cookie Delete all cookies visible to the current page.
--DELETE /session/:sessionId/cookie/:name Delete the cookie with the given name.
--GET /session/:sessionId/source Get the current page source.
--GET /session/:sessionId/title Get the current page title.
--POST /session/:sessionId/element Search for an element on the page, starting from the document root.
--POST /session/:sessionId/elements Search for multiple elements on the page, starting from the document root.
--POST /session/:sessionId/element/active Get the element on the page that currently has focus.
cmd_session_window_tmpl : STRING ="session/$id/window"
cmd_session_window (id: STRING_32): STRING_32
do
create Result.make_from_string (cmd_session_window_tmpl)
Result.replace_substring_all ("$id", id)
end
cmd_session_window_size_tmpl : STRING ="session/$id/window/$windowHandle/size"
cmd_session_window_size (id: STRING_32; window_handle: STRING_32): STRING_32
do
create Result.make_from_string (cmd_session_window_size_tmpl)
Result.replace_substring_all ("$id", id)
Result.replace_substring_all ("$windowHandle", window_handle)
end
cmd_session_window_position_tmpl : STRING ="session/$id/window/$windowHandle/position"
cmd_session_window_position (id: STRING_32; window_handle: STRING_32): STRING_32
do
create Result.make_from_string (cmd_session_window_position_tmpl)
Result.replace_substring_all ("$id", id)
Result.replace_substring_all ("$windowHandle", window_handle)
end
cmd_session_window_maximize_tmpl : STRING ="session/$id/window/$windowHandle/maximize"
cmd_session_window_maximize (id: STRING_32; window_handle: STRING_32): STRING_32
do
create Result.make_from_string (cmd_session_window_maximize_tmpl)
Result.replace_substring_all ("$id", id)
Result.replace_substring_all ("$windowHandle", window_handle)
end
cmd_session_cookie_tmpl : STRING ="session/$id/cookie"
cmd_session_cookie (id: STRING_32): STRING_32
do
create Result.make_from_string (cmd_session_cookie_tmpl)
Result.replace_substring_all ("$id", id)
end
cmd_session_cookie_delte_tmpl : STRING ="session/$id/cookie/$name"
cmd_session_cookie_delete (id: STRING_32;name : STRING_32): STRING_32
do
create Result.make_from_string (cmd_session_cookie_delte_tmpl)
Result.replace_substring_all ("$id", id)
Result.replace_substring_all ("$name", name)
end
cmd_session_source_tmpl : STRING ="session/$id/source"
cmd_session_source (id: STRING_32): STRING_32
do
create Result.make_from_string (cmd_session_source_tmpl)
Result.replace_substring_all ("$id", id)
end
cmd_session_title_tmpl : STRING ="session/$id/title"
cmd_session_title (id: STRING_32): STRING_32
do
create Result.make_from_string (cmd_session_source_tmpl)
Result.replace_substring_all ("$id", id)
end
cmd_session_element_tmpl : STRING ="session/$id/element"
cmd_session_element (id: STRING_32): STRING_32
do
create Result.make_from_string (cmd_session_element_tmpl)
Result.replace_substring_all ("$id", id)
end
cmd_session_elements_tmpl : STRING ="session/$id/elements"
cmd_session_elements (id: STRING_32): STRING_32
do
create Result.make_from_string (cmd_session_elements_tmpl)
Result.replace_substring_all ("$id", id)
end
cmd_session_element_active_tmpl : STRING ="session/$id/element/active"
cmd_session_element_active (id: STRING_32): STRING_32
do
create Result.make_from_string (cmd_session_element_active_tmpl)
Result.replace_substring_all ("$id", id)
end
cmd_session_element_id_tmpl : STRING ="session/$sessionId/element/$id"
cmd_session_element_id (sessionId: STRING_32; id : STRING_32 ): STRING_32
do
create Result.make_from_string (cmd_session_element_id_tmpl)
Result.replace_substring_all ("$sessionId", sessionId)
Result.replace_substring_all ("$id", id)
end
--GET /session/:sessionId/element/:id Describe the identified element.
--POST /session/:sessionId/element/:id/element Search for an element on the page, starting from the identified element.
cmd_session_element_id_element_tmpl : STRING ="session/$sessionId/element/$id/element"
cmd_session_element_id_element (sessionId: STRING_32; id : STRING_32 ): STRING_32
do
create Result.make_from_string (cmd_session_element_id_element_tmpl)
Result.replace_substring_all ("$sessionId", sessionId)
Result.replace_substring_all ("$id", id)
end
cmd_session_element_id_elements_tmpl : STRING ="session/$sessionId/element/$id/elements"
cmd_session_element_id_elements (sessionId: STRING_32; id : STRING_32 ): STRING_32
do
create Result.make_from_string (cmd_session_element_id_elements_tmpl)
Result.replace_substring_all ("$sessionId", sessionId)
Result.replace_substring_all ("$id", id)
end
--POST /session/:sessionId/element/:id/elements Search for multiple elements on the page, starting from the identified element.
--POST /session/:sessionId/element/:id/click Click on an element.
--POST /session/:sessionId/element/:id/submit Submit a FORM element.

View File

@@ -0,0 +1,155 @@
note
description: "Objects used to locate elements within a document"
author: ""
date: "$Date$"
revision: "$Revision$"
class
SE_BY
inherit
JSON_HELPER
SE_LOCATOR_STRATEGY_CONSTANTS
create default_create
feature -- Access
id (an_id : STRING_32; value : STRING_32 ) : STRING_32
-- return a STRING representing a JSON
-- with strategy by `id' and value `value'
-- { "using" : "id", "value":value }
do
create Result.make_from_string (json_template)
Result.replace_substring_all ("$using", se_id)
Result.replace_substring_all ("$value", value)
ensure
has_id_strategy : has_correct_stategy (Result, se_id)
end
name (an_id : STRING_32; value : STRING_32 ) : STRING_32
-- return a STRING representing a JSON
-- with strategy by `name' and value `value'
-- { "using" : "name", "value":value }
do
create Result.make_from_string (json_template)
Result.replace_substring_all ("$using", se_name)
Result.replace_substring_all ("$value", value)
ensure
has_name_strategy : has_correct_stategy (Result, se_name)
end
class_name (an_id : STRING_32; value : STRING_32 ) : STRING_32
-- return a STRING representing a JSON
-- with strategy by `class name' and value `value'
-- { "using" : "class name", "value":value }
do
create Result.make_from_string (json_template)
Result.replace_substring_all ("$using", se_class_name)
Result.replace_substring_all ("$value", value)
ensure
has_class_name_strategy : has_correct_stategy (Result, se_class_name)
end
css_selector (an_id : STRING_32; value : STRING_32 ) : STRING_32
-- return a STRING representing a JSON
-- with strategy by `css selector' and value `value'
-- { "using" : "css selector", "value":value }
do
create Result.make_from_string (json_template)
Result.replace_substring_all ("$using", se_css_selector)
Result.replace_substring_all ("$value", value)
ensure
has_css_selector_strategy : has_correct_stategy (Result, se_css_selector)
end
link_text (an_id : STRING_32; value : STRING_32 ) : STRING_32
-- return a STRING representing a JSON
-- with strategy by `link text' and value `value'
-- { "using" : "link text", "value":value }
do
create Result.make_from_string (json_template)
Result.replace_substring_all ("$using", se_link_text)
Result.replace_substring_all ("$value", value)
ensure
has_link_text_strategy : has_correct_stategy (Result, se_link_text)
end
partial_link_text (an_id : STRING_32; value : STRING_32 ) : STRING_32
-- return a STRING representing a JSON
-- with strategy by `partial link text' and value `value'
-- { "using" : "partial link text", "value":value }
do
create Result.make_from_string (json_template)
Result.replace_substring_all ("$using", se_partial_link_text)
Result.replace_substring_all ("$value", value)
ensure
has_partial_link_text_strategy : has_correct_stategy (Result, se_partial_link_text)
end
tag_name (an_id : STRING_32; value : STRING_32 ) : STRING_32
-- return a STRING representing a JSON
-- with strategy by `tag name' and value `value'
-- { "using" : "tag name", "value":value }
do
create Result.make_from_string (json_template)
Result.replace_substring_all ("$using", se_tag_name)
Result.replace_substring_all ("$value", value)
ensure
has_tag_name_strategy : has_correct_stategy (Result, se_tag_name)
end
xpath (an_id : STRING_32; value : STRING_32 ) : STRING_32
-- return a STRING representing a JSON
-- with strategy by `xpath' and value `value'
-- { "using" : "xpath", "value":value }
do
create Result.make_from_string (json_template)
Result.replace_substring_all ("$using", se_xpath)
Result.replace_substring_all ("$value", value)
ensure
has_xpath_strategy : has_correct_stategy (Result, se_xpath)
end
feature -- Query
has_correct_stategy (data: STRING_32; strategy : STRING_32) : BOOLEAN
do
if attached {JSON_OBJECT} string_to_json(data) as l_json then
if attached l_json.item ("using") as l_using then
Result := (l_using.representation).is_case_insensitive_equal_general ("%""+strategy+"%"")
end
end
end
is_valid_strategy (data : STRING_32) : BOOLEAN
-- if data is using on of the following strategies
-- class name
-- css selector
-- id
-- name
-- link text
-- partial link text
-- tag name
-- xpath
-- return True in othercase False
do
Result := has_correct_stategy (data, se_class_name) or else
has_correct_stategy (data, se_css_selector) or else
has_correct_stategy (data, se_id) or else
has_correct_stategy (data, se_link_text) or else
has_correct_stategy (data, se_name) or else
has_correct_stategy (data, se_partial_link_text) or else
has_correct_stategy (data, se_tag_name) or else
has_correct_stategy (data, se_xpath)
end
feature {NONE} -- Implementation
json_template : String = "[
{"using" :"$using",
"value" : "$value"}
]"
end

View File

@@ -0,0 +1,96 @@
note
description: "bject that describe a cookie. When returning Cookie objects, the server should only omit an optional field if it is incapable of providing the information."
author: ""
date: "$Date$"
revision: "$Revision$"
class
SE_COOKIE
create
default_create, make_with_values
feature -- Initialization
make_with_values (a_name: STRING_32; a_value: STRING_32; a_path: STRING_32; a_domain: STRING_32)
do
set_name (a_name)
set_path (a_path)
set_value (a_value)
set_domain (a_domain)
end
feature -- Access
name: detachable STRING_32
--The name of the cookie.
value: detachable STRING_32
-- The cookie value.
path: detachable STRING_32
--(Optional) The cookie path
domain: detachable STRING_32
--(Optional) The domain the cookie is visible to.
is_secure: BOOLEAN
--(Optional) Whether the cookie is a secure cookie
expiry: NATURAL_32
-- (Optional) When the cookie expires, specified in seconds since midnight, January 1, 1970 UTC.1
feature -- Change Element
set_name (a_name: STRING_32)
do
name := a_name
ensure
assigned_name: name ~ a_name
end
set_value (a_value: STRING_32)
do
value := a_value
ensure
assigned_value: value ~ a_value
end
set_path (a_path: STRING_32)
do
path := a_path
ensure
assigned_path: path ~ a_path
end
set_domain (a_domain: STRING_32)
do
domain := a_domain
ensure
assigned_domain: domain ~ a_domain
end
secure
-- set the cookie as secure
do
is_secure := True
ensure
is_secure: is_secure
end
insecure
-- set the cookie as insecure
do
is_secure := False
ensure
is_not_secure: not is_secure
end
set_expiry (an_expiry: NATURAL)
do
expiry := an_expiry
ensure
assigned_expiry: expiry ~ an_expiry
end
end

View File

@@ -0,0 +1,28 @@
note
description: "Summary description for {SE_LOCATOR_STRATEGY_CONSTANTS}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
SE_LOCATOR_STRATEGY_CONSTANTS
feature -- Constants
se_class_name : STRING_32 = "class name"
se_css_selector : STRING_32 = "css selector"
se_id : STRING_32 = "id"
se_name : STRING_32 = "name"
se_link_text : STRING_32 = "link text"
se_partial_link_text : STRING_32 = "partial link text"
se_tag_name : STRING_32 = "tag name"
se_xpath : STRING_32 = "xpath"
end

View File

@@ -0,0 +1,48 @@
note
description: "Summary description for {SE_WINDOW}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
SE_WINDOW
create
default_create,
make_with_values
feature -- Initialization
make_with_values (a_width : NATURAL_32; a_height : NATURAL_32)
do
set_width (a_width)
set_height (a_height)
end
feature -- Access
--width: number, height: number} The size of the window.
width : NATURAL_32
height : NATURAL_32
x,y : INTEGER_32
feature -- Change Element
set_width (a_width : NATURAL_32)
do
width := a_width
end
set_height (a_height : NATURAL_32)
do
height := a_height
end
set_x (an_x : INTEGER_32)
do
x := an_x
end
set_y (an_y : INTEGER_32)
do
y := an_y
end
end

View File

@@ -1,69 +0,0 @@
note
description: "Object that describe a cookie. When returning Cookie objects, the server should only omit an optional field if it is incapable of providing the information."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WEB_DRIVER_COOKIE
create
make
feature {NONE}-- Initialization
make (a_name : STRING_32; a_value: STRING_32)
do
set_name (a_name)
set_value (a_value)
end
feature -- Access
name : STRING_32
--The name of the cookie.
value : STRING_32
-- The cookie value.
path : detachable STRING_32
--(Optional) The cookie path
domain : detachable STRING_32
--(Optional) The domain the cookie is visible to.
secure : BOOLEAN
--(Optional) Whether the cookie is a secure cookie
expiry : NATURAL_32
-- (Optional) When the cookie expires, specified in seconds since midnight, January 1, 1970 UTC.1
feature -- Change Element
set_name (a_name:STRING_32)
do
name := a_name
end
set_value (a_value:STRING_32)
do
value := a_value
end
set_path (a_path : STRING_32)
do
path := a_path
end
set_domain (a_domain : STRING_32)
do
domain := a_domain
end
set_secure (a_value : BOOLEAN)
do
secure := a_value
end
set_expiry ( a_value : NATURAL_32)
do
expiry := a_value
end
end

View File

@@ -9,17 +9,17 @@ class
create
make
feature
make
make ( an_element : STRING_32)
do
set_element (an_element)
end
feature -- Access
element : detachable STRING_32
element : STRING_32
--The opaque ID assigned to the element by the server.
--This ID should be used in all subsequent commands issued against the element.
feature -- Change Element
set_element (an_element : STRING)
set_element (an_element : STRING_32)
do
element := an_element
end

View File

@@ -18,19 +18,111 @@ create
feature {NONE} -- Initialization
make
do
-- test_back_forward_refesh
-- test_status_sessions_timeout
test_ime_actions
end
test_ime_actions
local
web_driver: SE_JSON_WIRE_PROTOCOL
capabilities: SE_CAPABILITIES
timeout: SE_TIMEOUT_TYPE
do
-- check if the selenium Remote WebDriver is up and running.
create web_driver.make
if attached web_driver.status as l_status then
create capabilities.make
capabilities.set_browser_name ("chrome")
if attached web_driver.create_session_with_desired_capabilities (capabilities) as l_session then
print ("%NSessionId:" + l_session.session_id)
-- available engines
if attached web_driver.ime_available_engines (l_session.session_id) as l_available then
check
has_no_error : not web_driver.has_error
end
else
check has_error : web_driver.has_error end
-- ime_active_engine
check
no_active_engine : web_driver.ime_active_engine (l_session.session_id) = Void
has_error : web_driver.has_error
end
-- ime_activated
check
no_active: not web_driver.ime_activated (l_session.session_id)
has_error : web_driver.has_error
end
-- ime_deactivate
web_driver.ime_deactivate (l_session.session_id)
check
has_error : web_driver.has_error
end
-- ime_activate
web_driver.ime_activate (l_session.session_id,"UNKown")
check
has_error : web_driver.has_error
end
end
end
create capabilities.make
capabilities.set_browser_name ("firefox")
if attached web_driver.create_session_with_desired_capabilities (capabilities) as l_session then
print ("%NSessionId:" + l_session.session_id)
check
no_error_firefox: not web_driver.has_error
end
end
end
end
test_status_sessions_timeout
local
web_driver: SE_JSON_WIRE_PROTOCOL
capabilities: SE_CAPABILITIES
timeout: SE_TIMEOUT_TYPE
do
-- check if the selenium Remote WebDriver is up and running.
-- check if the selenium Remote WebDriver is up and running.
create web_driver.make
if attached web_driver.status as l_status then
print (l_status)
-- create a new session
create capabilities.make
capabilities.set_browser_name ("chrome")
if attached web_driver.create_session_with_desired_capabilities (capabilities) as l_session2 then
print ("%NSessionId:" + l_session2.session_id)
end
-- retrieve sessions
if attached web_driver.sessions as l_session then
across
l_session as l_item
loop
print (l_item)
end
end
if attached web_driver.create_session_with_desired_capabilities (capabilities) as l_session2 then
print ("%NSessionId:" + l_session2.session_id)
create timeout.make ("script", 1)
web_driver.set_session_timeouts (l_session2.session_id, timeout)
end
-- create a new session
else
print ("The selenium server is not accesible")
end
end
test_back_forward_refesh
local
web_driver: SE_JSON_WIRE_PROTOCOL
capabilities: SE_CAPABILITIES
file : RAW_FILE
do
create web_driver.make
-- create a new session
create capabilities.make
capabilities.set_browser_name ("chrome")
if attached web_driver.create_session_with_desired_capabilities (capabilities) as l_session then
@@ -81,36 +173,22 @@ feature {NONE} -- Initialization
check
Has_no_error: not web_driver.has_error
end
if attached web_driver.screenshot (l_session.session_id) as l_screenshot then
check
Has_no_error: not web_driver.has_error
end
create file.make_with_name ("screenshot_"+l_session.session_id+".png")
file.open_write
file.putstring (l_screenshot)
file.close
end
end
-- create a new session
create capabilities.make
capabilities.set_browser_name ("chrome")
if attached web_driver.create_session_with_desired_capabilities (capabilities) as l_session then
print ("%NSessionId:" + l_session.session_id)
create timeout.make ("script", 1)
web_driver.set_session_timeouts (l_session.session_id, timeout)
end
-- -- retrieve sessions
-- if attached web_driver.sessions as l_session then
-- across
-- l_session as l_item
-- loop
-- print (l_item)
-- end
-- end
else
print ("The selenium server is not accesible")
end
end
test_session
local
h: LIBCURL_HTTP_CLIENT
session: HTTP_CLIENT_SESSION
resp: detachable HTTP_CLIENT_RESPONSE
l_location: detachable READABLE_STRING_8
body: STRING
context: HTTP_CLIENT_REQUEST_CONTEXT
s: READABLE_STRING_8
do

View File

@@ -273,6 +273,23 @@ feature -- Test routines
end
end
test_ime_available_engines
local
capabilities : SE_CAPABILITIES
do
if attached wire_protocol.ime_available_engines (session_id) as l_ime_available_engines then
assert ("Has no error", not wire_protocol.has_error)
across l_ime_available_engines as item loop
print (item)
end
else
assert ("Has error :", wire_protocol.has_error)
if attached wire_protocol.last_error as l_error then
assert ("Status 13", l_error.code = 13)
end
end
end
feature {NONE}-- Implementation
wire_protocol: SE_JSON_WIRE_PROTOCOL

View File

@@ -0,0 +1,69 @@
note
description: "[
Eiffel tests that can be executed by testing tool.
]"
author: "EiffelStudio test wizard"
date: "$Date$"
revision: "$Revision$"
testing: "type/manual"
class
TEST_SE_BY
inherit
EQA_TEST_SET
redefine
on_prepare,
on_clean
end
feature {NONE} -- Events
on_prepare
-- <Precursor>
do
-- assert ("not_implemented", False)
end
on_clean
-- <Precursor>
do
-- assert ("not_implemented", False)
end
feature -- Test routines
test_valid_strategy_id
local
l_data : STRING_32
do
l_data := "[
{"using":"id", "value":"test"}
]"
assert ("Expected true", (create {SE_BY}).is_valid_strategy (l_data))
end
test_valid_strategy_name
local
l_data : STRING_32
do
l_data := "[
{"using":"name", "value":"test"}
]"
assert ("Expected true", (create {SE_BY}).is_valid_strategy (l_data))
end
test_wrong_strategy
local
l_data : STRING_32
do
l_data := "[
{"using":"wrong", "value":"test"}
]"
assert ("Expected False", not (create {SE_BY}).is_valid_strategy (l_data))
end
end