File tree Expand file tree Collapse file tree 1 file changed +23
-4
lines changed
rb/spec/integration/selenium/webdriver Expand file tree Collapse file tree 1 file changed +23
-4
lines changed Original file line number Diff line number Diff line change 3131
3232class SeleniumTestListener
3333 def example_finished ( notification )
34- exception = notification . example . exception
34+ if investigate? ( notification . example ) && WebDriver . logger . debug?
35+ driver = GlobalTestEnv . driver_instance
36+ session_id = driver . instance_variable_get ( :@bridge ) . session_id
37+
38+ FileUtils . mkdir_p ( 'bazel-logs' )
39+ driver . save_screenshot ( "bazel-logs/#{ session_id } .png" )
40+ WebDriver . logger . info ( "Page Source: #{ driver . page_source } " )
41+ end
42+
43+ GlobalTestEnv . reset_driver! if reset_driver? ( notification . example )
44+ end
45+
46+ private
47+
48+ def investigate? ( example )
49+ example . exception && !example . pending
50+ end
51+
52+ def reset_driver? ( example )
53+ exception = example . exception
3554 assertion_failed = exception &&
3655 ( exception . is_a? ( RSpec ::Expectations ::ExpectationNotMetError ) ||
37- exception . is_a? ( RSpec ::Core ::Pending ::PendingExampleFixedError ) )
38- pending_exception = exception . nil? && notification . example . pending && !notification . example . skip
56+ exception . is_a? ( RSpec ::Core ::Pending ::PendingExampleFixedError ) )
57+ pending_exception = exception . nil? && example . pending && !example . skip
3958
40- GlobalTestEnv . reset_driver! if ( exception && !assertion_failed ) || pending_exception
59+ ( exception && !assertion_failed ) || pending_exception
4160 end
4261end
4362
You can’t perform that action at this time.
0 commit comments