diff --git a/library/test/selenium/examples/example_search.e b/library/test/selenium/examples/example_search.e index c88fe4d1..6835d9fe 100644 --- a/library/test/selenium/examples/example_search.e +++ b/library/test/selenium/examples/example_search.e @@ -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 diff --git a/library/test/selenium/examples/examples.ecf b/library/test/selenium/examples/examples.ecf index 6f6b52d7..ec7013d0 100644 --- a/library/test/selenium/examples/examples.ecf +++ b/library/test/selenium/examples/examples.ecf @@ -1,19 +1,21 @@ - - - + + + + /.git$ + /EIFGENs$ + /CVS$ + /.svn$ + - - - /EIFGENs$ - /CVS$ - /.svn$ - - + + + + diff --git a/library/test/selenium/src/web_driver_wait.e b/library/test/selenium/src/web_driver_wait.e index c3a450d8..e2bb4771 100644 --- a/library/test/selenium/src/web_driver_wait.e +++ b/library/test/selenium/src/web_driver_wait.e @@ -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