File tree Expand file tree Collapse file tree 4 files changed +13
-5
lines changed
Expand file tree Collapse file tree 4 files changed +13
-5
lines changed Original file line number Diff line number Diff line change 3636 opts . add_argument ( '--disable-gpu' ) if Gem . win_platform?
3737 # Workaround https://bugs.chromium.org/p/chromedriver/issues/detail?id=2650&q=load&sort=-id&colspec=ID%20Status%20Pri%20Owner%20Summary
3838 opts . add_argument ( '--disable-site-isolation-trials' )
39+
40+ # https://github.com/teamcapybara/capybara/issues/2796#issuecomment-2678172710
41+ opts . add_argument ( 'disable-background-timer-throttling' )
42+ opts . add_argument ( 'disable-backgrounding-occluded-windows' )
43+ opts . add_argument ( 'disable-renderer-backgrounding' )
3944 end
4045
4146 Capybara ::Selenium ::Driver . new ( app , **{ :browser => :chrome , options_key => browser_options } )
Original file line number Diff line number Diff line change @@ -367,6 +367,8 @@ def clear_session_storage
367367 end
368368
369369 def clear_local_storage
370+ # selenium-webdriver 4.30.0 removed HTML5 storage accessors -- not really sure why
371+ # can we replicate this robustly via CDP?
370372 if @browser . respond_to? :local_storage
371373 @browser . local_storage . clear
372374 else
Original file line number Diff line number Diff line change 7575 scrolling_element . scroll_to ( el , align : :center )
7676 el_center = el . evaluate_script ( '(function(rect){return (rect.top + rect.bottom)/2})(this.getBoundingClientRect())' )
7777 scrollable_center = scrolling_element . evaluate_script ( '(this.clientHeight / 2) + this.getBoundingClientRect().top' )
78- expect ( el_center ) . to be_within ( 1 ) . of ( scrollable_center )
78+ # Firefox reports floats and can be slightly outside 1 difference - make 2 instaed
79+ expect ( el_center ) . to be_within ( 2 ) . of ( scrollable_center )
7980 end
8081
8182 it 'can scroll the scrolling element to the top' do
Original file line number Diff line number Diff line change @@ -187,8 +187,8 @@ module TestSessions
187187 session . find ( :css , '#set-storage' ) . click
188188 session . reset!
189189 session . visit ( '/with_js' )
190- expect ( session . driver . browser . local_storage . keys ) . to be_empty
191- expect ( session . driver . browser . session_storage . keys ) . to be_empty
190+ expect ( session . driver . browser . execute_script ( 'return localStorage.length' ) ) . to eq ( 0 )
191+ expect ( session . driver . browser . execute_script ( 'return sessionStorage.length' ) ) . to eq ( 0 )
192192 end
193193
194194 it 'does not clear storage when false' do
@@ -197,8 +197,8 @@ module TestSessions
197197 session . find ( :css , '#set-storage' ) . click
198198 session . reset!
199199 session . visit ( '/with_js' )
200- expect ( session . driver . browser . local_storage . keys ) . not_to be_empty
201- expect ( session . driver . browser . session_storage . keys ) . not_to be_empty
200+ expect ( session . driver . browser . execute_script ( 'return localStorage.length' ) ) . to eq ( 1 )
201+ expect ( session . driver . browser . execute_script ( 'return sessionStorage.length' ) ) . to eq ( 1 )
202202 end
203203 end
204204 end
You can’t perform that action at this time.
0 commit comments