Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

one fallback image per width in multi width #550

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sudo: false
sudo: required
addons:
apt:
packages:
Expand Down
23 changes: 14 additions & 9 deletions lib/wraith/save_images.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,20 @@ def crop_selector driver, selector, image_location
def capture_image_selenium(screen_sizes, url, file_name, selector, global_before_capture, path_before_capture)
driver = get_driver
screen_sizes.to_s.split(",").each do |screen_size|
width, height = screen_size.split("x")
new_file_name = file_name.sub('MULTI', screen_size)
driver.manage.window.resize_to(width, height || 1500)
driver.navigate.to url
driver.execute_async_script(File.read(global_before_capture)) if global_before_capture
driver.execute_async_script(File.read(path_before_capture)) if path_before_capture
resize_to_fit_page(driver) unless height
driver.save_screenshot(new_file_name)
crop_selector(driver, selector, new_file_name) if selector && selector.length > 0
begin
width, height = screen_size.split("x")
new_file_name = file_name.sub('MULTI', screen_size)
driver.manage.window.resize_to(width, height || 1500)
driver.navigate.to url
driver.execute_async_script(File.read(global_before_capture)) if global_before_capture
driver.execute_async_script(File.read(path_before_capture)) if path_before_capture
resize_to_fit_page(driver) unless height
driver.save_screenshot(new_file_name)
crop_selector(driver, selector, new_file_name) if selector && selector.length > 0
rescue => e
logger.error e
create_invalid_image(new_file_name, width)
end
end
driver.quit
end
Expand Down
4 changes: 2 additions & 2 deletions wraith.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency 'log4r'
spec.add_runtime_dependency 'thor'
spec.add_runtime_dependency 'parallel'
spec.add_runtime_dependency 'selenium-webdriver', "~> 3.5"
spec.add_runtime_dependency 'chromedriver-helper', "~> 1.1"
spec.add_runtime_dependency 'selenium-webdriver', "~> 3.9"
spec.add_runtime_dependency 'chromedriver-helper', "~> 1.2"
end