File tree Expand file tree Collapse file tree 3 files changed +11
-4
lines changed
lib/selenium/webdriver/common
spec/integration/selenium/webdriver Expand file tree Collapse file tree 3 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,8 @@ def initialize(opts = {})
3737 @timeout = opts . fetch ( :timeout , DEFAULT_TIMEOUT )
3838 @interval = opts . fetch ( :interval , DEFAULT_INTERVAL )
3939 @message = opts [ :message ]
40- @ignored = Array ( opts [ :ignore ] || Error ::NoSuchElementError )
40+ @message_provider = opts [ :message_provider ]
41+ @ignored = Array ( opts [ :ignore ] || Error ::NoSuchElementError )
4142 end
4243
4344 #
@@ -64,6 +65,8 @@ def until
6465
6566 msg = if @message
6667 @message . dup
68+ elsif @message_provider
69+ @message_provider . call
6770 else
6871 "timed out after #{ @timeout } seconds"
6972 end
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ module WebDriver
3232 # Safari returns "click intercepted" error instead of "element click intercepted"
3333 it 'raises if different element receives click' , except : { browser : %i[ safari safari_preview ] } do
3434 driver . navigate . to url_for ( 'click_tests/overlapping_elements.html' )
35- element = wait_for_element ( id : 'contents' )
35+ element = wait_for_element ( id : 'contents' , timeout : 10 )
3636 expect { element . click } . to raise_error ( Error ::ElementClickInterceptedError )
3737 end
3838
Original file line number Diff line number Diff line change @@ -84,8 +84,12 @@ def wait_for_no_alert
8484 wait . until { driver . title }
8585 end
8686
87- def wait_for_element ( locator )
88- wait = Wait . new ( timeout : 25 , ignore : Error ::NoSuchElementError )
87+ def wait_for_element ( locator , timeout = 25 )
88+ wait = Wait . new ( timeout : timeout , ignore : Error ::NoSuchElementError , message_provider : lambda {
89+ url = "page url: #{ driver . current_url } ;\n "
90+ source = "page source: #{ driver . find_element ( css : 'body' ) . attribute ( 'innerHTML' ) } \n "
91+ "could not find element #{ locator } in #{ timeout } seconds;\n #{ url } #{ source } "
92+ } )
8993 wait . until { driver . find_element ( locator ) }
9094 end
9195
You can’t perform that action at this time.
0 commit comments