Updated selenium WEB_DRIVER_WAIT, the feature until_when now use a

predicate. Updated the related example.
This commit is contained in:
jvelilla
2013-05-13 10:47:46 -03:00
parent 30663dc9fb
commit e0c3c783fa
3 changed files with 26 additions and 19 deletions

View File

@@ -39,7 +39,7 @@ feature -- Example
-- Google's search is rendered dynamically with JavaScript. -- Google's search is rendered dynamically with JavaScript.
-- Wait for the page to load, timeout after 10 seconds -- Wait for the page to load, timeout after 10 seconds
create wait.make (web_driver,10) create wait.make (web_driver,10)
wait.until_when ("Eiffel Room") wait.until_when (agent expected_title (web_driver, "Eiffel Room"))
if attached web_driver.get_page_tile as l_title then if attached web_driver.get_page_tile as l_title then
@@ -49,4 +49,12 @@ feature -- Example
-- close the window -- close the window
web_driver.window_close web_driver.window_close
end 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 end

View File

@@ -1,19 +1,21 @@
<?xml version="1.0" encoding="ISO-8859-1"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-10-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-10-0 http://www.eiffel.com/developers/xml/configuration-1-10-0.xsd" name="project" uuid="61EFD50A-C916-494A-91D6-3E12E0738F4D"> <system xmlns="http://www.eiffel.com/developers/xml/configuration-1-10-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-10-0 http://www.eiffel.com/developers/xml/configuration-1-10-0.xsd" name="selenium_example" uuid="61EFD50A-C916-494A-91D6-3E12E0738F4D">
<target name="project"> <target name="selenium_example">
<root class="APPLICATION" feature="make"/> <file_rule>
<exclude>/.git$</exclude>
<exclude>/EIFGENs$</exclude>
<exclude>/CVS$</exclude>
<exclude>/.svn$</exclude>
</file_rule>
<option warning="true" is_attached_by_default="true" void_safety="all" syntax="transitional"> <option warning="true" is_attached_by_default="true" void_safety="all" syntax="transitional">
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/> <assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
</option> </option>
<setting name="console_application" value="true"/> <setting name="console_application" value="true"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/> <library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="selenium" location="..\selenium-safe.ecf"/> <library name="selenium" location="..\selenium-safe.ecf"/>
<cluster name="project" location=".\" recursive="true"> </target>
<file_rule> <target name="search" extends="selenium_example">
<exclude>/EIFGENs$</exclude> <root class="EXAMPLE_SEARCH" feature="default_create"/>
<exclude>/CVS$</exclude> <cluster name="src" location=".\" recursive="true"/>
<exclude>/.svn$</exclude>
</file_rule>
</cluster>
</target> </target>
</system> </system>

View File

@@ -23,7 +23,7 @@ feature {NONE} -- Initialization
feature -- Access feature -- Access
-- create another feature to accept a predicate -- create another feature to accept a predicate
until_when (condition : STRING) until_when (condition : PREDICATE[ANY, TUPLE])
--Evaluate the condition until it's true or timing out . --Evaluate the condition until it's true or timing out .
local local
found : BOOLEAN found : BOOLEAN
@@ -34,20 +34,17 @@ feature -- Access
create l_time1.make_now create l_time1.make_now
create l_duration.make_by_seconds (duration.as_integer_32) create l_duration.make_by_seconds (duration.as_integer_32)
condition.to_lower
from from
create l_time2.make_now create l_time2.make_now
if attached {STRING_32} web_driver.get_page_tile as l_title then if condition.item([]) then
l_title.to_lower found := True
found := l_title.has_substring (condition)
end end
until until
found or found or
l_time2.relative_duration (l_time1).fine_seconds_count > l_duration.fine_seconds_count 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 condition.item([]) then
l_title.to_lower found := True
found := l_title.has_substring (condition)
end end
create l_time2.make_now create l_time2.make_now
end end