Skip to content

Commit

Permalink
Change 'timeout_ms' to 'settle' (how long the browser should wait for…
Browse files Browse the repository at this point in the history
… the dust to settle).
  • Loading branch information
bigmartyn committed Aug 20, 2018
1 parent c9730e2 commit bf07cfd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/wraith/save_images.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def capture_image_selenium(screen_sizes, url, file_name, selector, global_before
new_file_name = file_name.sub('MULTI', screen_size)
driver.manage.window.resize_to(width, height || 1500)
driver.navigate.to url
driver.manage.timeouts.implicit_wait = wraith.timeout_ms * 1000
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
resize_to_fit_page(driver) unless height
Expand Down
4 changes: 2 additions & 2 deletions lib/wraith/wraith.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ def comp_domain_label
domains.keys[1]
end

def timeout_ms
@config.fetch('timeout_ms', 1000)
def settle
@config.fetch('settle', 10)
end

def threads
Expand Down
10 changes: 5 additions & 5 deletions spec/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@
it 'returns default values for threads' do
expect(wraith.threads).to eq 8
end
it 'returns default values for timeout_ms' do
expect(wraith.timeout_ms).to eq 1000
it 'returns default values for settle' do
expect(wraith.settle).to eq 10
end

context 'non-standard config values' do
let(:config) { YAML.load "browser: phantomjs\nthreads: 2\ntimeout_ms: 4000"}
let(:config) { YAML.load "browser: phantomjs\nthreads: 2\nsettle: 5"}
let(:non_standard_wraith) { Wraith::Wraith.new( config, { yaml_passed: true }) }

it 'returns overridden value when threads is specified in config' do
expect(non_standard_wraith.threads).to eq 2
end

it 'returns overridden value when timeout_ms is specified in config' do
expect(non_standard_wraith.timeout_ms).to eq 4000
it 'returns overridden value when settle is specified in config' do
expect(non_standard_wraith.settle).to eq 5
end
end

Expand Down

0 comments on commit bf07cfd

Please sign in to comment.