Skip to content

Commit

Permalink
Download correct geckdriver file on Apple Silicon
Browse files Browse the repository at this point in the history
Geckodriver splits its Mac OS files into 2 versions (macos.tar.gz and macos-aarch64.tar.gz), and webdriver doesn't work properly if `macos.tar.gz` is used on Apple Sillicon platform.
Geckodriver releases: https://github.com/mozilla/geckodriver/releases
  • Loading branch information
stephannv committed Aug 8, 2022
1 parent 75dae08 commit 4b80eb4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/webdrivers/geckodriver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def platform_ext
when 'linux'
"linux#{System.bitsize}.tar.gz"
when 'mac'
'macos.tar.gz'
System.apple_m1_architecture? ? 'macos-aarch64.tar.gz' : 'macos.tar.gz'
when 'win'
"win#{System.bitsize}.zip"
end
Expand Down
34 changes: 34 additions & 0 deletions spec/webdrivers/geckodriver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,40 @@
msg = /Net::HTTPServerException: 404 "Not Found"/
expect { geckodriver.update }.to raise_error(StandardError, msg)
end

context 'when platform is Apple Sillicon' do
it 'downloads aarch64 binary' do
allow(Webdrivers::System).to receive(:platform).and_return('mac')
allow(Webdrivers::System).to receive(:apple_m1_architecture?).and_return(true)
base = 'https://github.com/mozilla/geckodriver/releases/download'
binary = 'geckodriver-v0.31.0-macos-aarch64.tar.gz'
url = "#{base}/v0.31.0/#{binary}"

allow(Webdrivers::System).to receive(:download).with(url, geckodriver.driver_path)

geckodriver.required_version = '0.31.0'
geckodriver.update

expect(Webdrivers::System).to have_received(:download).with(url, geckodriver.driver_path)
end
end

context 'when platform isn\'t Apple Sillicon' do
it 'downloads default binary' do
allow(Webdrivers::System).to receive(:platform).and_return('mac')
allow(Webdrivers::System).to receive(:apple_m1_architecture?).and_return(false)
base = 'https://github.com/mozilla/geckodriver/releases/download'
binary = 'geckodriver-v0.31.0-macos.tar.gz'
url = "#{base}/v0.31.0/#{binary}"

allow(Webdrivers::System).to receive(:download).with(url, geckodriver.driver_path)

geckodriver.required_version = '0.31.0'
geckodriver.update

expect(Webdrivers::System).to have_received(:download).with(url, geckodriver.driver_path)
end
end
end

describe '#current_version' do
Expand Down

0 comments on commit 4b80eb4

Please sign in to comment.