Updated selenium WEB_DRIVER_WAIT, the feature until_when now use a
predicate. Updated the related example.
This commit is contained in:
@@ -39,7 +39,7 @@ feature -- Example
|
||||
-- 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")
|
||||
wait.until_when (agent expected_title (web_driver, "Eiffel Room"))
|
||||
|
||||
|
||||
if attached web_driver.get_page_tile as l_title then
|
||||
@@ -49,4 +49,12 @@ feature -- Example
|
||||
-- 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
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
<?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">
|
||||
<target name="project">
|
||||
<root class="APPLICATION" feature="make"/>
|
||||
<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="selenium_example">
|
||||
<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">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<setting name="console_application" value="true"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="selenium" location="..\selenium-safe.ecf"/>
|
||||
<cluster name="project" location=".\" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/CVS$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
</cluster>
|
||||
</target>
|
||||
<target name="search" extends="selenium_example">
|
||||
<root class="EXAMPLE_SEARCH" feature="default_create"/>
|
||||
<cluster name="src" location=".\" recursive="true"/>
|
||||
</target>
|
||||
</system>
|
||||
|
||||
@@ -23,7 +23,7 @@ feature {NONE} -- Initialization
|
||||
|
||||
feature -- Access
|
||||
-- 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 .
|
||||
local
|
||||
found : BOOLEAN
|
||||
@@ -34,20 +34,17 @@ feature -- Access
|
||||
create l_time1.make_now
|
||||
create l_duration.make_by_seconds (duration.as_integer_32)
|
||||
|
||||
condition.to_lower
|
||||
from
|
||||
create l_time2.make_now
|
||||
if attached {STRING_32} web_driver.get_page_tile as l_title then
|
||||
l_title.to_lower
|
||||
found := l_title.has_substring (condition)
|
||||
if condition.item([]) then
|
||||
found := True
|
||||
end
|
||||
until
|
||||
found or
|
||||
l_time2.relative_duration (l_time1).fine_seconds_count > l_duration.fine_seconds_count
|
||||
loop
|
||||
if attached web_driver.get_page_tile as l_title then
|
||||
l_title.to_lower
|
||||
found := l_title.has_substring (condition)
|
||||
if condition.item([]) then
|
||||
found := True
|
||||
end
|
||||
create l_time2.make_now
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user