Updated WEB_DRIVER_WAIT class, still need to be improved.
Updated Readme and the example
This commit is contained in:
@@ -35,8 +35,11 @@ feature -- Example
|
|||||||
if attached web_driver.get_page_tile as l_title then
|
if attached web_driver.get_page_tile as l_title then
|
||||||
print ("%NPage title is:" + l_title)
|
print ("%NPage title is:" + l_title)
|
||||||
end
|
end
|
||||||
create wait.make (web_driver,0)
|
|
||||||
wait.wait ("Eiffel Room")
|
-- 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 ("Eiffel Room")
|
||||||
|
|
||||||
|
|
||||||
if attached web_driver.get_page_tile as l_title then
|
if attached web_driver.get_page_tile as l_title then
|
||||||
@@ -45,7 +48,5 @@ feature -- Example
|
|||||||
|
|
||||||
-- close the window
|
-- close the window
|
||||||
web_driver.window_close
|
web_driver.window_close
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ Eiffel Selenium binding
|
|||||||
=================================================
|
=================================================
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
Selenium will help you test your web applications effectively and efficiently against a vast number of browsers and platforms.
|
||||||
This client is a binding for the REST API interface defined in the WebDriver protocol http://code.google.com/p/selenium/wiki/JsonWireProtocol.
|
This client is a binding for the REST API interface defined in the WebDriver protocol http://code.google.com/p/selenium/wiki/JsonWireProtocol.
|
||||||
|
|
||||||
WARNING this API is still under development, and maybe it will change
|
WARNING this API is still under development, and maybe it will change
|
||||||
@@ -20,8 +20,67 @@ WARNING this API is still under development, and maybe it will change
|
|||||||
java -jar selenium-server-standalone-2.32.0.jar
|
java -jar selenium-server-standalone-2.32.0.jar
|
||||||
-Dwebdriver.chrome.driver=%PATH_TO%\chromedriver.exe -Dwebdriver.ie.driver=%PATH_TO%\IEDriverServer.exe
|
-Dwebdriver.chrome.driver=%PATH_TO%\chromedriver.exe -Dwebdriver.ie.driver=%PATH_TO%\IEDriverServer.exe
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started Selenium-WebDriver API (Eiffel binding only support (for now) RemoteWebDriver)
|
||||||
|
The examples and guide are based on http://docs.seleniumhq.org/docs/03_webdriver.jsp#introducing-the-selenium-webdriver-api-by-example
|
||||||
|
|
||||||
TODO
|
WebDriver is a tool for automating web application testing, and in particular to verify that they work as expected.
|
||||||
|
|
||||||
|
|
||||||
|
class
|
||||||
|
EXAMPLE_SEARCH
|
||||||
|
|
||||||
|
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
|
||||||
|
web_driver.start_session_chrome
|
||||||
|
|
||||||
|
-- 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
|
||||||
|
|
||||||
|
-- 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
|
||||||
|
|
||||||
|
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 ("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
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
### Selenium-WebDriver API Commands and Operations
|
||||||
|
Fetching a Page
|
||||||
|
The first thing you<6F>re likely to want to do with WebDriver is navigate to a page.
|
||||||
|
|
||||||
|
web_driver.to_url ("http://www.google.com/")
|
||||||
|
|
||||||
|
|
||||||
|
### Locating Elements
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
<library name="encoding" location="$ISE_LIBRARY\library\encoding\encoding-safe.ecf"/>
|
<library name="encoding" location="$ISE_LIBRARY\library\encoding\encoding-safe.ecf"/>
|
||||||
<library name="http_client" location="$EIFFEL_LIBRARY\EWF\library\network\http_client\http_client-safe.ecf"/>
|
<library name="http_client" location="$EIFFEL_LIBRARY\EWF\library\network\http_client\http_client-safe.ecf"/>
|
||||||
<library name="json" location="$EIFFEL_LIBRARY\EWF\contrib\library\text\parser\json\library\json-safe.ecf"/>
|
<library name="json" location="$EIFFEL_LIBRARY\EWF\contrib\library\text\parser\json\library\json-safe.ecf"/>
|
||||||
|
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
|
||||||
<cluster name="src" location=".\src\" recursive="true">
|
<cluster name="src" location=".\src\" recursive="true">
|
||||||
<file_rule>
|
<file_rule>
|
||||||
<exclude>/EIFGENs$</exclude>
|
<exclude>/EIFGENs$</exclude>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ note
|
|||||||
author: ""
|
author: ""
|
||||||
date: "$Date$"
|
date: "$Date$"
|
||||||
revision: "$Revision$"
|
revision: "$Revision$"
|
||||||
EIS: "name=SELINIUM", "protocol=JSONWireProtocol", "src=https://code.google.com/p/selenium/wiki/JsonWireProtocol#Commands"
|
EIS: "name=SELINIUM", "protocol=uri", "src=https://code.google.com/p/selenium/wiki/JsonWireProtocol#Commands"
|
||||||
|
|
||||||
class
|
class
|
||||||
COMMAND_EXECUTOR
|
COMMAND_EXECUTOR
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ note
|
|||||||
|
|
||||||
class
|
class
|
||||||
WEB_DRIVER_WAIT
|
WEB_DRIVER_WAIT
|
||||||
|
inherit
|
||||||
|
SHARED_EXECUTION_ENVIRONMENT
|
||||||
create
|
create
|
||||||
make
|
make
|
||||||
feature {NONE} -- Initialization
|
feature {NONE} -- Initialization
|
||||||
@@ -21,25 +22,34 @@ feature {NONE} -- Initialization
|
|||||||
end
|
end
|
||||||
|
|
||||||
feature -- Access
|
feature -- Access
|
||||||
wait (condition : STRING)
|
-- create another feature to accept a predicate
|
||||||
|
until_when (condition : STRING)
|
||||||
|
--Evaluate the condition until it's true or timing out .
|
||||||
local
|
local
|
||||||
found : BOOLEAN
|
found : BOOLEAN
|
||||||
|
l_time1, l_time2 : TIME
|
||||||
|
l_duration : TIME_DURATION
|
||||||
do
|
do
|
||||||
|
|
||||||
|
create l_time1.make_now
|
||||||
|
create l_duration.make_by_seconds (duration.as_integer_32)
|
||||||
|
|
||||||
condition.to_lower
|
condition.to_lower
|
||||||
from
|
from
|
||||||
|
create l_time2.make_now
|
||||||
if attached {STRING_32} web_driver.get_page_tile as l_title then
|
if attached {STRING_32} web_driver.get_page_tile as l_title then
|
||||||
l_title.to_lower
|
l_title.to_lower
|
||||||
found := l_title.has_substring (condition)
|
found := l_title.has_substring (condition)
|
||||||
end
|
end
|
||||||
until
|
until
|
||||||
found
|
found or
|
||||||
|
l_time2.relative_duration (l_time1).fine_seconds_count > l_duration.fine_seconds_count
|
||||||
loop
|
loop
|
||||||
if attached web_driver.get_page_tile as l_title then
|
if attached web_driver.get_page_tile as l_title then
|
||||||
l_title.to_lower
|
l_title.to_lower
|
||||||
found := l_title.has_substring (condition)
|
found := l_title.has_substring (condition)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
create l_time2.make_now
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user