Skip to content

Instantly share code, notes, and snippets.

@gunesmes
Last active August 29, 2015 14:02
Show Gist options
  • Save gunesmes/8fe1f7ba4bd5aba0a6ba to your computer and use it in GitHub Desktop.
Save gunesmes/8fe1f7ba4bd5aba0a6ba to your computer and use it in GitHub Desktop.
set the width and heigth of the browser and then check if the width of navigation bar has full length by executing jQuery.
require 'capybara/dsl'
include Capybara::DSL
Capybara.default_driver = :selenium
visit "http://www.amazon.com/"
# the screen size will be fixed as the following resolution
# then navigation bar is expected to fill full size of header.
# if there is a scroll bar, its width shoul be subtracted as 15px.
screen_sizes = [[640, 480], [1024, 768], [1280, 800], [1368, 768], [1440, 900], [2560, 1440]]
screen_sizes.each do |x, y|
page.driver.browser.manage.window.resize_to(x, y)
top_bar_width = page.evaluate_script("jQuery('#nav-bar-outer').css('width')")
puts "Width of navigation bar: #{top_bar_width}\n"
puts "Width of window: #{x} - #{x-15}\n"
puts "\n-------------------------\n"
[x, x-15].include? top_bar_width
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment