Update readme.md

This commit is contained in:
jvelilla
2013-05-23 07:52:30 -03:00
parent c741e41597
commit caac696465

View File

@@ -26,69 +26,71 @@ The examples and guide are based on http://docs.seleniumhq.org/docs/03_webdriver
WebDriver is a tool for automating web application testing, and in particular to verify that they work as expected. WebDriver is a tool for automating web application testing, and in particular to verify that they work as expected.
class class
EXAMPLE_SEARCH EXAMPLE_SEARCH
inherit
ANY
redefine
default_create
end
feature
default_create
do
search
end
feature -- Example
search
local
web_driver : WEB_DRIVER
wait : WEB_DRIVER_WAIT
do
--Create a new instance of a Web driver
create web_driver.make
-- Start session with chrome inherit
web_driver.start_session_chrome
-- Go to Google ANY
web_driver.to_url ("http://www.google.com/") redefine
default_create
end
-- Find the text input element by its name feature
if attached web_driver.find_element ((create{SE_BY}).name ("q")) as l_element then
-- Enter something to search for default_create
l_element.send_keys(<<"Eiffel Room">>) do
search
end
-- Now submit the form. WebDriver will find the form for us from the element feature -- Example
l_element.submit
end search
if attached web_driver.get_page_tile as l_title then local
print ("%NPage title is:" + l_title) web_driver: WEB_DRIVER
end wait: WEB_DRIVER_WAIT
do
--Create a new instance of a Web driver
create web_driver.make
-- Google's search is rendered dynamically with JavaScript. -- Start session with chrome
-- Wait for the page to load, timeout after 10 seconds web_driver.start_session_chrome
create wait.make (web_driver,10)
wait.until_when (agent expected_title (web_driver, "Eiffel Room"))
-- Go to Google
web_driver.to_url ("http://www.google.com/")
if attached web_driver.get_page_tile as l_title then -- Find the text input element by its name
print ("%NPage title is:" + l_title) if attached web_driver.find_element ((create {SE_BY}).name ("q")) as l_element then
end
-- close the window -- Enter something to search for
web_driver.window_close l_element.send_keys (<<"Eiffel Room">>)
end
expected_title (driver : WEB_DRIVER; title : STRING_32) : BOOLEAN -- Now submit the form. WebDriver will find the form for us from the element
do l_element.submit
if attached {STRING_32} driver.get_page_tile as l_title and then l_title.has_substring (title) then end
Result := True if attached web_driver.get_page_tile as l_title then
end print ("%NPage title is:" + l_title)
end end
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
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