Fixed errors in navigate_to_url command,
Fixed url templates in json_wire_protocol_command. Added test cases to AutoTest
This commit is contained in:
@@ -328,7 +328,7 @@ feature -- Commands
|
||||
resp: SE_RESPONSE
|
||||
do
|
||||
l_json := "[
|
||||
{ "url": $url }
|
||||
{ "url": "$url" }
|
||||
]"
|
||||
l_json.replace_substring_all ("$url", an_url)
|
||||
if commnad_executor.is_available then
|
||||
|
||||
@@ -47,7 +47,7 @@ feature
|
||||
Result.replace_substring_all ("$id", id)
|
||||
end
|
||||
|
||||
cmd_session_timeouts_implicit_wait_tmpl : STRING ="/session/$id/timeouts/implicit_wait"
|
||||
cmd_session_timeouts_implicit_wait_tmpl : STRING ="session/$id/timeouts/implicit_wait"
|
||||
|
||||
cmd_session_timeouts_implicit_wait (id: STRING_32): STRING_32
|
||||
do
|
||||
@@ -56,7 +56,7 @@ feature
|
||||
end
|
||||
|
||||
|
||||
cmd_session_window_handle_tmpl : STRING ="/session/$id/window_handle"
|
||||
cmd_session_window_handle_tmpl : STRING ="session/$id/window_handle"
|
||||
|
||||
cmd_session_window_handle (id: STRING_32): STRING_32
|
||||
do
|
||||
@@ -64,7 +64,7 @@ feature
|
||||
Result.replace_substring_all ("$id", id)
|
||||
end
|
||||
|
||||
cmd_session_window_handles_tmpl : STRING ="/session/$id/window_handles"
|
||||
cmd_session_window_handles_tmpl : STRING ="session/$id/window_handles"
|
||||
|
||||
cmd_session_window_handles (id: STRING_32): STRING_32
|
||||
do
|
||||
@@ -72,7 +72,7 @@ feature
|
||||
Result.replace_substring_all ("$id", id)
|
||||
end
|
||||
|
||||
cmd_session_url_tmpl : STRING ="/session/$id/url"
|
||||
cmd_session_url_tmpl : STRING ="session/$id/url"
|
||||
|
||||
cmd_session_url (id: STRING_32): STRING_32
|
||||
do
|
||||
@@ -82,7 +82,7 @@ feature
|
||||
|
||||
|
||||
|
||||
cmd_session_forward_tmpl : STRING ="/session/$id/forward"
|
||||
cmd_session_forward_tmpl : STRING ="session/$id/forward"
|
||||
|
||||
cmd_session_forward (id: STRING_32): STRING_32
|
||||
do
|
||||
@@ -90,7 +90,7 @@ feature
|
||||
Result.replace_substring_all ("$id", id)
|
||||
end
|
||||
|
||||
cmd_session_back_tmpl : STRING ="/session/$id/back"
|
||||
cmd_session_back_tmpl : STRING ="session/$id/back"
|
||||
|
||||
cmd_session_back (id: STRING_32): STRING_32
|
||||
do
|
||||
@@ -99,7 +99,7 @@ feature
|
||||
end
|
||||
|
||||
|
||||
cmd_session_refresh_tmpl : STRING ="/session/$id/refresh"
|
||||
cmd_session_refresh_tmpl : STRING ="session/$id/refresh"
|
||||
|
||||
cmd_session_refresh (id: STRING_32): STRING_32
|
||||
do
|
||||
@@ -112,7 +112,7 @@ feature
|
||||
--POST /session/:sessionId/execute_async Inject a snippet of JavaScript into the page for execution in the context of the currently selected frame.
|
||||
|
||||
|
||||
cmd_session_screenshot_tmpl : STRING ="/session/$id/screenshot"
|
||||
cmd_session_screenshot_tmpl : STRING ="session/$id/screenshot"
|
||||
|
||||
cmd_session_screenshot (id: STRING_32): STRING_32
|
||||
do
|
||||
@@ -121,7 +121,7 @@ feature
|
||||
end
|
||||
|
||||
|
||||
cmd_session_ime_available_engines_tmpl : STRING ="/session/$id/ime/available_engines"
|
||||
cmd_session_ime_available_engines_tmpl : STRING ="session/$id/ime/available_engines"
|
||||
|
||||
cmd_session_ime_available (id: STRING_32): STRING_32
|
||||
do
|
||||
@@ -129,7 +129,7 @@ feature
|
||||
Result.replace_substring_all ("$id", id)
|
||||
end
|
||||
|
||||
cmd_session_ime_active_engine_tmpl : STRING ="/session/$id/ime/active_engine"
|
||||
cmd_session_ime_active_engine_tmpl : STRING ="session/$id/ime/active_engine"
|
||||
|
||||
cmd_session_ime_active_engine (id: STRING_32): STRING_32
|
||||
do
|
||||
@@ -137,7 +137,7 @@ feature
|
||||
Result.replace_substring_all ("$id", id)
|
||||
end
|
||||
|
||||
cmd_session_ime_activated_tmpl : STRING ="/session/$id/ime/activated"
|
||||
cmd_session_ime_activated_tmpl : STRING ="session/$id/ime/activated"
|
||||
|
||||
cmd_session_ime_activated (id: STRING_32): STRING_32
|
||||
do
|
||||
@@ -145,7 +145,7 @@ feature
|
||||
Result.replace_substring_all ("$id", id)
|
||||
end
|
||||
|
||||
cmd_session_ime_deactivate_tmpl : STRING ="/session/$id/ime/deactivate"
|
||||
cmd_session_ime_deactivate_tmpl : STRING ="session/$id/ime/deactivate"
|
||||
|
||||
cmd_session_ime_deactivate (id: STRING_32): STRING_32
|
||||
do
|
||||
@@ -153,7 +153,7 @@ feature
|
||||
Result.replace_substring_all ("$id", id)
|
||||
end
|
||||
|
||||
cmd_session_ime_activate_tmpl : STRING ="/session/$id/ime/activate"
|
||||
cmd_session_ime_activate_tmpl : STRING ="session/$id/ime/activate"
|
||||
|
||||
cmd_session_ime_activate (id: STRING_32): STRING_32
|
||||
do
|
||||
|
||||
@@ -7,6 +7,7 @@ note
|
||||
class
|
||||
SE_TIMEOUT_TYPE
|
||||
|
||||
-- TODO add contracts to validate the timeout types.
|
||||
create
|
||||
make,
|
||||
make_empty
|
||||
@@ -22,7 +23,7 @@ feature -- Initialization
|
||||
do
|
||||
|
||||
end
|
||||
|
||||
|
||||
feature -- Access
|
||||
type : detachable STRING_32
|
||||
-- The type of operation to set the timeout for.
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
note
|
||||
description : "test application root class"
|
||||
date : "$Date$"
|
||||
revision : "$Revision$"
|
||||
description: "test application root class"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
APPLICATION
|
||||
|
||||
inherit
|
||||
|
||||
ARGUMENTS
|
||||
|
||||
|
||||
-- TODO start and stop selenium server from Eiffel.
|
||||
create
|
||||
make
|
||||
|
||||
@@ -17,72 +20,114 @@ feature {NONE} -- Initialization
|
||||
make
|
||||
local
|
||||
web_driver: SE_JSON_WIRE_PROTOCOL
|
||||
capabilities : SE_CAPABILITIES
|
||||
timeout : SE_TIMEOUT_TYPE
|
||||
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
|
||||
if attached web_driver.status as l_status then
|
||||
print (l_status)
|
||||
|
||||
|
||||
|
||||
-- create a new session
|
||||
-- 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)
|
||||
web_driver.navigate_to_url (l_session.session_id, "http://www.google.com/")
|
||||
check
|
||||
Has_no_error: not web_driver.has_error
|
||||
end
|
||||
web_driver.navigate_to_url (l_session.session_id, "http://www.infoq.com/")
|
||||
check
|
||||
Has_no_error: not web_driver.has_error
|
||||
end
|
||||
web_driver.navigate_to_url (l_session.session_id, "http://www.yahoo.com/")
|
||||
check
|
||||
Has_no_error: not web_driver.has_error
|
||||
end
|
||||
|
||||
--back
|
||||
web_driver.back (l_session.session_id)
|
||||
check
|
||||
Has_no_error: not web_driver.has_error
|
||||
end
|
||||
if attached web_driver.retrieve_url (l_session.session_id) as l_back_url then
|
||||
check
|
||||
Has_no_error: not web_driver.has_error
|
||||
end
|
||||
check
|
||||
expected_infoq: "http://www.infoq.com/" ~ l_back_url.out
|
||||
end
|
||||
end
|
||||
|
||||
-- forward
|
||||
web_driver.forward (l_session.session_id)
|
||||
check
|
||||
Has_no_error: not web_driver.has_error
|
||||
end
|
||||
if attached web_driver.retrieve_url (l_session.session_id) as l_forward_url then
|
||||
check
|
||||
Has_no_error: not web_driver.has_error
|
||||
end
|
||||
check
|
||||
expected_yahoo: "http://www.yahoo.com/" ~ l_forward_url.out
|
||||
end
|
||||
end
|
||||
|
||||
-- refresh
|
||||
web_driver.refresh (l_session.session_id)
|
||||
check
|
||||
Has_no_error: not web_driver.has_error
|
||||
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_empty
|
||||
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
|
||||
|
||||
-- -- 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
|
||||
create h.make
|
||||
s := "[
|
||||
{
|
||||
"desiredCapabilities" : {
|
||||
"browserName":"firefox"
|
||||
}
|
||||
}
|
||||
]"
|
||||
|
||||
|
||||
session := h.new_session ("http://localhost:4444/wd/hub/")
|
||||
create context.make
|
||||
context.headers.put ("application/json;charset=UTF-8", "Content-Type")
|
||||
context.headers.put ("application/json;charset=UTF-8", "Accept")
|
||||
resp := session.post ("session", context,s)
|
||||
print(resp)
|
||||
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
|
||||
create h.make
|
||||
s := "[
|
||||
{
|
||||
"desiredCapabilities" : {
|
||||
"browserName":"firefox"
|
||||
}
|
||||
}
|
||||
]"
|
||||
session := h.new_session ("http://localhost:4444/wd/hub/")
|
||||
create context.make
|
||||
context.headers.put ("application/json;charset=UTF-8", "Content-Type")
|
||||
context.headers.put ("application/json;charset=UTF-8", "Accept")
|
||||
resp := session.post ("session", context, s)
|
||||
print (resp)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -114,6 +114,166 @@ feature -- Test routines
|
||||
-- assert ("After delete Pre sesssion - 1 is equal to post_session", (pre_session - 1) = post_session)
|
||||
end
|
||||
|
||||
test_valid_session_timeouts
|
||||
local
|
||||
l_timeout :SE_TIMEOUT_TYPE
|
||||
capabilities : SE_CAPABILITIES
|
||||
do
|
||||
create l_timeout.make ("script", 1)
|
||||
create capabilities.make
|
||||
capabilities.set_browser_name ("chrome")
|
||||
if attached wire_protocol.create_session_with_desired_capabilities (capabilities) as l_session then
|
||||
assert ("No error", not wire_protocol.has_error)
|
||||
wire_protocol.set_session_timeouts (l_session.session_id, l_timeout)
|
||||
assert ("Has no error", not wire_protocol.has_error)
|
||||
end
|
||||
end
|
||||
|
||||
test_invalid_session_timeouts
|
||||
local
|
||||
l_timeout :SE_TIMEOUT_TYPE
|
||||
capabilities : SE_CAPABILITIES
|
||||
do
|
||||
create l_timeout.make ("tes", 1)
|
||||
create capabilities.make
|
||||
capabilities.set_browser_name ("chrome")
|
||||
if attached wire_protocol.create_session_with_desired_capabilities (capabilities) as l_session then
|
||||
assert ("No error", not wire_protocol.has_error)
|
||||
wire_protocol.set_session_timeouts (l_session.session_id, l_timeout)
|
||||
assert ("Has error", wire_protocol.has_error)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
test_valid_session_async_script_timeouts
|
||||
local
|
||||
capabilities : SE_CAPABILITIES
|
||||
do
|
||||
create capabilities.make
|
||||
capabilities.set_browser_name ("chrome")
|
||||
if attached wire_protocol.create_session_with_desired_capabilities (capabilities) as l_session then
|
||||
assert ("No error", not wire_protocol.has_error)
|
||||
wire_protocol.set_session_timeouts_async_script (l_session.session_id, 1)
|
||||
assert ("Has no error", not wire_protocol.has_error)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
test_valid_session_implicit_wait_timeouts
|
||||
local
|
||||
capabilities : SE_CAPABILITIES
|
||||
do
|
||||
create capabilities.make
|
||||
capabilities.set_browser_name ("chrome")
|
||||
if attached wire_protocol.create_session_with_desired_capabilities (capabilities) as l_session then
|
||||
assert ("No error", not wire_protocol.has_error)
|
||||
wire_protocol.set_session_timeouts_implicit_wait (l_session.session_id, 1)
|
||||
assert ("Has no error", not wire_protocol.has_error)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
test_retrieve_window_handle
|
||||
local
|
||||
capabilities : SE_CAPABILITIES
|
||||
window_handle : detachable STRING_32
|
||||
do
|
||||
create capabilities.make
|
||||
capabilities.set_browser_name ("chrome")
|
||||
if attached wire_protocol.create_session_with_desired_capabilities (capabilities) as l_session then
|
||||
assert ("No error", not wire_protocol.has_error)
|
||||
window_handle := wire_protocol.retrieve_window_handle (l_session.session_id)
|
||||
assert ("Has no error", not wire_protocol.has_error)
|
||||
assert ("Windows handle not void", attached window_handle = True)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
test_retrieve_window_handles
|
||||
local
|
||||
capabilities : SE_CAPABILITIES
|
||||
window_handles : detachable LIST[STRING_32]
|
||||
do
|
||||
create capabilities.make
|
||||
capabilities.set_browser_name ("chrome")
|
||||
if attached wire_protocol.create_session_with_desired_capabilities (capabilities) as l_session then
|
||||
assert ("No error", not wire_protocol.has_error)
|
||||
window_handles := wire_protocol.retrieve_window_handles (l_session.session_id)
|
||||
assert ("Has no error", not wire_protocol.has_error)
|
||||
assert ("Windows handleS not void", attached window_handles = True)
|
||||
end
|
||||
end
|
||||
|
||||
test_retrieve_url
|
||||
local
|
||||
capabilities : SE_CAPABILITIES
|
||||
url : detachable STRING_32
|
||||
do
|
||||
create capabilities.make
|
||||
capabilities.set_browser_name ("chrome")
|
||||
if attached wire_protocol.create_session_with_desired_capabilities (capabilities) as l_session then
|
||||
assert ("No error", not wire_protocol.has_error)
|
||||
url := wire_protocol.retrieve_url (session_id)
|
||||
assert ("Has no error", not wire_protocol.has_error)
|
||||
assert ("url not void", attached url = True)
|
||||
end
|
||||
end
|
||||
|
||||
test_navigate_to_url
|
||||
local
|
||||
capabilities : SE_CAPABILITIES
|
||||
do
|
||||
create capabilities.make
|
||||
capabilities.set_browser_name ("chrome")
|
||||
if attached wire_protocol.create_session_with_desired_capabilities (capabilities) as l_session then
|
||||
assert ("No error", not wire_protocol.has_error)
|
||||
wire_protocol.navigate_to_url (session_id,"http://www.google.com/")
|
||||
assert ("Has no error", not wire_protocol.has_error)
|
||||
if attached wire_protocol.retrieve_url (session_id) as l_url then
|
||||
assert("Expected url", "http://www.google.com/" ~ l_url.out)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
test_back_and_forward
|
||||
local
|
||||
capabilities : SE_CAPABILITIES
|
||||
do
|
||||
create capabilities.make
|
||||
capabilities.set_browser_name ("chrome")
|
||||
capabilities.set_takes_screenshot (True)
|
||||
if attached wire_protocol.create_session_with_desired_capabilities (capabilities) as l_session then
|
||||
assert ("No error", not wire_protocol.has_error)
|
||||
wire_protocol.navigate_to_url (l_session.session_id,"http://www.google.com/")
|
||||
assert ("Has no error", not wire_protocol.has_error)
|
||||
wire_protocol.navigate_to_url (l_session.session_id,"http://www.infoq.com/")
|
||||
assert ("Has no error", not wire_protocol.has_error)
|
||||
wire_protocol.navigate_to_url (l_session.session_id,"http://www.yahoo.com/")
|
||||
assert ("Has no error", not wire_protocol.has_error)
|
||||
|
||||
--back
|
||||
wire_protocol.back (l_session.session_id)
|
||||
assert ("Has no error", not wire_protocol.has_error)
|
||||
|
||||
if attached wire_protocol.retrieve_url (l_session.session_id) as l_back_url then
|
||||
assert ("Has no error", not wire_protocol.has_error)
|
||||
assert ("Expected infoq", "http://www.infoq.com/" ~ l_back_url.out)
|
||||
end
|
||||
|
||||
-- forward
|
||||
wire_protocol.forward (l_session.session_id)
|
||||
assert ("Has no error", not wire_protocol.has_error)
|
||||
|
||||
if attached wire_protocol.retrieve_url (l_session.session_id) as l_forward_url then
|
||||
assert ("Has no error", not wire_protocol.has_error)
|
||||
assert ("Expected yahoo", "http://www.yahoo.com/" ~ l_forward_url.out)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
feature {NONE}-- Implementation
|
||||
wire_protocol: SE_JSON_WIRE_PROTOCOL
|
||||
once
|
||||
|
||||
Reference in New Issue
Block a user