diff --git a/library/test/selenium/examples/example_search.e b/library/test/selenium/examples/example_search.e index 8ef8643f..27d089e0 100644 --- a/library/test/selenium/examples/example_search.e +++ b/library/test/selenium/examples/example_search.e @@ -11,6 +11,7 @@ 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 @@ -31,9 +32,15 @@ feature -- Example l_element.submit end + if attached web_driver.get_page_tile as l_title then + print ("%NPage title is:" + l_title) + end + create wait.make (web_driver,0) + wait.wait ("Eiffel Room") - if attached web_driver.get_page_tile as l_title then - print ("Page title is:" + l_title) + + if attached web_driver.get_page_tile as l_title then + print ("%NPage title is:" + l_title) end -- close the window diff --git a/library/test/selenium/src/web_driver.e b/library/test/selenium/src/web_driver.e index 05e97bce..2d840e36 100644 --- a/library/test/selenium/src/web_driver.e +++ b/library/test/selenium/src/web_driver.e @@ -441,6 +441,14 @@ feature -- Common end +feature {WEB_DRIVER, WEB_DRIVER_WAIT} + session_wait (duration : INTEGER_64) + do + if attached session as l_session then + api.set_session_timeouts_async_script (l_session.session_id, duration.as_integer_32) + end + end + feature {NONE} -- Implementation session: detachable SE_SESSION diff --git a/library/test/selenium/src/web_driver_wait.e b/library/test/selenium/src/web_driver_wait.e new file mode 100644 index 00000000..c08f2718 --- /dev/null +++ b/library/test/selenium/src/web_driver_wait.e @@ -0,0 +1,54 @@ +note + description: "Summary description for {WEB_DRIVER_WAIT}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + WEB_DRIVER_WAIT + +create + make +feature {NONE} -- Initialization + make ( driver : like web_driver; a_duration : INTEGER_64) + do + web_driver := driver + duration := a_duration + initialize + ensure + driver_set : driver = web_driver + duration_set : duration = a_duration + end + +feature -- Access + wait (condition : STRING) + + local + found : BOOLEAN + do + condition.to_lower + from + if attached {STRING_32} web_driver.get_page_tile as l_title then + l_title.to_lower + found := l_title.has_substring (condition) + end + until + found + loop + if attached web_driver.get_page_tile as l_title then + l_title.to_lower + found := l_title.has_substring (condition) + + end + end + end + +feature {NONE}-- Implementation + web_driver : WEB_DRIVER + duration : INTEGER_64 + + initialize + do + web_driver.session_wait (duration) + end +end