Updated command_executor

Added more examples.
This commit is contained in:
jvelilla
2013-05-22 07:18:17 -03:00
parent a6cad7e811
commit 7dbed3ade1
4 changed files with 224 additions and 156 deletions

View File

@@ -50,6 +50,12 @@
<root class="FIND_ELEMENT_CSS_SELECTOR" feature="default_create"/>
<cluster name="src" location=".\" recursive="true"/>
</target>
<target name="findElementXPath" extends="selenium_example">
<root class="FIND_ELEMENT_XPATH" feature="default_create"/>
<cluster name="src" location=".\" recursive="true"/>
</target>

View File

@@ -46,6 +46,16 @@ feature -- Search by id
if attached web_driver.get_page_tile as l_title then
print ("%NPage title is:" + l_title)
end
-- Find the user name, password element by its id and submit
if attached {WEB_ELEMENT} web_driver.find_element ((create {SE_BY}).id ("edit-name")) as l_user and then attached {WEB_ELEMENT} web_driver.find_element ((create {SE_BY}).id ("edit-pass")) as l_pass and then attached {WEB_ELEMENT} web_driver.find_element ((create {SE_BY}).id ("edit-submit")) as l_form then
if attached l_user.get_css_value ("width") as l_width then
print ("%NCss value:" + l_width)
end
end
io.read_line
-- close the window
web_driver.window_close
end

View File

@@ -0,0 +1,74 @@
note
description: "[
]"
class
FIND_ELEMENT_XPATH
inherit
ANY
redefine
default_create
end
create
default_create
feature
default_create
do
search
end
feature -- Search by id
search
local
web_driver: WEB_DRIVER
xpath_expression : STRING_32
do
--Create a new instance of a Web driver
create web_driver.make
-- Start session with chrome
web_driver.start_session_chrome
-- Go to EiffelRoom home page
web_driver.to_url ("http://www.eiffelroom.com/")
--Xpath expression
xpath_expression := "//*[@id='page']"
if attached {WEB_ELEMENT} web_driver.find_element ((create {SE_BY}).xpath (xpath_expression)) as l_path then
print ("%NElement:" + l_path.element)
end
-- Images with Alt
-- img[@alt]
if attached {LIST[WEB_ELEMENT]}web_driver.find_elements ((create {SE_BY}).xpath ("//img[@alt]")) as l_paths then
from
l_paths.start
until
l_paths.after
loop
print ("%NElement:" + l_paths.item.element)
l_paths.forth
end
end
print ("%Nend process ...")
io.read_line
-- close the window
web_driver.window_close
end
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
end
end
end

View File

@@ -17,6 +17,7 @@ inherit
-- TODO
-- clean and improve the code
-- handle response from the server in a smart way
create
make
@@ -29,7 +30,7 @@ feature -- Initialization
host := a_host
create h.make
http_session := h.new_session (a_host)
http_session.set_timeout (5)
-- http_session.set_timeout (5)
-- http_session.set_is_debug (True)
-- http_session.set_proxy ("127.0.0.1", 8888)
end
@@ -279,7 +280,6 @@ feature -- Commands
Result := new_response (a_session_id, resp)
end
frame (a_session_id: STRING_32; a_data: STRING_32): SE_RESPONSE
require
selinum_server_available: is_available
@@ -300,7 +300,6 @@ feature -- Commands
Result := new_response (a_session_id, resp)
end
close_window (a_session_id: STRING_32): SE_RESPONSE
require
selinum_server_available: is_available
@@ -361,7 +360,6 @@ feature -- Commands
Result := new_response (a_session_id, resp)
end
retrieve_cookies (a_session_id: STRING_32): SE_RESPONSE
require
selinum_server_available: is_available
@@ -412,7 +410,6 @@ feature -- Commands
Result := new_response (a_session_id, resp)
end
page_title (a_session_id: STRING_32): SE_RESPONSE
require
selinum_server_available: is_available
@@ -423,7 +420,6 @@ feature -- Commands
Result := new_response (a_session_id, resp)
end
search_element (a_session_id: STRING_32; a_data: STRING_32): SE_RESPONSE
require
selinum_server_available: is_available
@@ -434,7 +430,6 @@ feature -- Commands
Result := new_response (a_session_id, resp)
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
@@ -445,7 +440,6 @@ feature -- Commands
Result := new_response (a_session_id, resp)
end
search_elements (a_session_id: STRING_32; a_data: STRING_32): SE_RESPONSE
require
selinum_server_available: is_available
@@ -456,8 +450,6 @@ feature -- Commands
Result := new_response (a_session_id, resp)
end
element_active (a_session_id: STRING_32): SE_RESPONSE
require
selinum_server_available: is_available
@@ -468,7 +460,6 @@ feature -- Commands
Result := new_response (a_session_id, resp)
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
@@ -489,7 +480,6 @@ feature -- Commands
Result := new_response (a_session_id, resp)
end
element_submit (a_session_id: STRING_32; id: STRING_32): SE_RESPONSE
require
selinum_server_available: is_available
@@ -500,7 +490,6 @@ feature -- Commands
Result := new_response (a_session_id, resp)
end
element_text (a_session_id: STRING_32; id: STRING_32): SE_RESPONSE
require
selinum_server_available: is_available
@@ -521,7 +510,6 @@ feature -- Commands
Result := new_response (a_session_id, resp)
end
send_key_strokes (a_session_id: STRING_32; data: STRING_32): SE_RESPONSE
require
selinum_server_available: is_available
@@ -542,7 +530,6 @@ feature -- Commands
Result := new_response (a_session_id, resp)
end
clear_element (a_session_id: STRING_32; id: STRING_32): SE_RESPONSE
require
selinum_server_available: is_available
@@ -623,7 +610,6 @@ feature -- Commands
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
@@ -644,7 +630,6 @@ feature -- Commands
Result := new_response (a_session_id, resp)
end
retrieve_browser_orientation (a_session_id: STRING_32): SE_RESPONSE
require
selinum_server_available: is_available
@@ -655,7 +640,6 @@ feature -- Commands
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
@@ -716,7 +700,6 @@ feature -- Commands
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
@@ -757,7 +740,6 @@ feature -- Commands
Result := new_response (a_session_id, resp)
end
touch_click (a_session_id: STRING_32; data: STRING_32): SE_RESPONSE
require
selinum_server_available: is_available
@@ -808,7 +790,6 @@ feature -- Commands
Result := new_response (a_session_id, resp)
end
touch_scroll (a_session_id: STRING_32; data: STRING_32): SE_RESPONSE
require
selinum_server_available: is_available
@@ -826,7 +807,6 @@ feature -- Commands
Result := new_response (a_session_id, resp)
end
touch_long_click (a_session_id: STRING_32; data: STRING_32): SE_RESPONSE
require
selinum_server_available: is_available
@@ -847,7 +827,6 @@ feature -- Commands
Result := new_response (a_session_id, resp)
end
touch_flick (a_session_id: STRING_32; data: STRING_32): SE_RESPONSE
require
selinum_server_available: is_available
@@ -855,7 +834,6 @@ feature -- Commands
Result := start_touch_flick (a_session_id, data)
end
retrieve_geo_location (a_session_id: STRING_32): SE_RESPONSE
require
selinum_server_available: is_available