diff --git a/spec/browser/xvfb_spec.rb b/spec/browser/xvfb_spec.rb index 6f5fd016..cbeb7b8a 100644 --- a/spec/browser/xvfb_spec.rb +++ b/spec/browser/xvfb_spec.rb @@ -50,7 +50,8 @@ expect(process.xvfb.screen_size).to eq("1024x768x24") ensure xvfb_browser&.quit - expect(process_alive?(process.xvfb.pid)).to be(false) + pid = process&.xvfb&.pid + expect(process_alive?(pid)).to be(false) if pid end end diff --git a/spec/browser_spec.rb b/spec/browser_spec.rb index 6c167ca5..4a2370ec 100644 --- a/spec/browser_spec.rb +++ b/spec/browser_spec.rb @@ -468,6 +468,7 @@ page.go_to("/ferrum/simple") end + sleep 1 # It may take longer to close the target expect(browser.contexts.size).to eq(1) expect(browser.targets.size).to eq(0) end diff --git a/spec/page/screenshot_spec.rb b/spec/page/screenshot_spec.rb index 8442cbe8..fee140b8 100644 --- a/spec/page/screenshot_spec.rb +++ b/spec/page/screenshot_spec.rb @@ -138,17 +138,20 @@ def create_screenshot(**options) it "supports screenshotting the page with different quality settings" do file2 = "#{PROJECT_ROOT}/spec/tmp/screenshot2.jpeg" file3 = "#{PROJECT_ROOT}/spec/tmp/screenshot3.jpeg" - FileUtils.rm_f([file2, file3]) + file4 = "#{PROJECT_ROOT}/spec/tmp/screenshot4.#{format}" + FileUtils.rm_f([file2, file3, file4]) begin browser.go_to browser.screenshot(path: file, quality: 0) # ignored for png browser.screenshot(path: file2) # defaults to a quality of 75 browser.screenshot(path: file3, quality: 100) - expect(File.size(file)).to be > File.size(file2) # png by default is bigger + browser.screenshot(path: file4, quality: 60) # ignored for png + + expect(File.size(file)).to eq(File.size(file4)) expect(File.size(file2)).to be < File.size(file3) ensure - FileUtils.rm_f([file2, file3]) + FileUtils.rm_f([file2, file3, file4]) end end