diff --git a/lib/wraith/save_images.rb b/lib/wraith/save_images.rb index 151e3c6f..b697be06 100644 --- a/lib/wraith/save_images.rb +++ b/lib/wraith/save_images.rb @@ -136,8 +136,8 @@ def capture_image_selenium(screen_sizes, url, file_name, selector, global_before driver.manage.window.resize_to(width, height || 1500) driver.navigate.to url driver.manage.timeouts.implicit_wait = wraith.settle - driver.execute_script(File.read(global_before_capture)) if global_before_capture - driver.execute_script(File.read(path_before_capture)) if path_before_capture + 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 diff --git a/spec/js/global--chrome.js b/spec/js/global--chrome.js index 63cc23f0..fb1d9f3f 100644 --- a/spec/js/global--chrome.js +++ b/spec/js/global--chrome.js @@ -1,4 +1,6 @@ +var callback = arguments[arguments.length-1]; (function () { document.body.innerHTML = " "; document.body.style['background-color'] = 'red'; + callback(); })(); diff --git a/spec/js/path--chrome.js b/spec/js/path--chrome.js index 2d3ca011..052217bf 100644 --- a/spec/js/path--chrome.js +++ b/spec/js/path--chrome.js @@ -1,4 +1,6 @@ +var callback = arguments[arguments.length-1]; (function () { document.body.innerHTML = " "; document.body.style['background-color'] = 'green'; + callback(); })();