[rb] be more exact about expected sizes of screenshots
@@ -81,13 +81,20 @@ module Selenium
end
it 'takes viewport screenshot by default' do
+ viewport_width = driver.execute_script("return window.innerWidth;") * 2
+ viewport_height = driver.execute_script("return window.innerHeight;") * 2
+
screenshot = driver.save_screenshot path
- expect(File.read(screenshot)[0x10..0x18].unpack('NN').last).to be < 2600
+ expect(File.read(screenshot)[0x10..0x18].unpack('NN')).to eq([viewport_width, viewport_height])
end
it 'takes full page screenshot', exclusive: {browser: :firefox} do
+ viewport_width = driver.execute_script("return window.innerWidth;") * 2
+ viewport_height = driver.execute_script("return window.innerHeight;") * 2
+
screenshot = driver.save_screenshot path, full_page: true
- expect(File.read(screenshot)[0x10..0x18].unpack('NN').last).to be > 2600
+ expect(File.read(screenshot)[0x10..0x18].unpack1('NN')).to eq viewport_width
+ expect(File.read(screenshot)[0x10..0x18].unpack('NN').last).to be > viewport_height
end
it 'does not take full page screenshot', exclude: {browser: :firefox} do
