Skip to content

Commit

Permalink
[rb] allow service to be started before the driver
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Sep 24, 2023
1 parent e5ce6fd commit f843e8b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
4 changes: 4 additions & 0 deletions rb/lib/selenium/webdriver/common/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ def initialize(path: nil, port: nil, log: nil, args: nil)
end

def launch
@executable_path ||= begin
default_options = WebDriver.const_get("#{self.class.name.split('::')[2]}::Options").new
DriverFinder.path(default_options, self.class)
end
ServiceManager.new(self).tap(&:start)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@ module Chrome
let(:service) { described_class.new }
let(:service_manager) { service.launch }

before { service.executable_path = DriverFinder.path(Options.new, described_class) }
after { service_manager.stop }

it 'auto uses chromedriver' do
service.executable_path = DriverFinder.path(Options.new, described_class)

expect(service_manager.uri).to be_a(URI)
end

it 'can be started outside driver' do
expect(service_manager.uri).to be_a(URI)
end
end
Expand Down
7 changes: 6 additions & 1 deletion rb/spec/integration/selenium/webdriver/edge/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@ module Edge
let(:service) { described_class.new }
let(:service_manager) { service.launch }

before { service.executable_path = DriverFinder.path(Options.new, described_class) }
after { service_manager.stop }

it 'auto uses edgedriver' do
service.executable_path = DriverFinder.path(Options.new, described_class)

expect(service_manager.uri).to be_a(URI)
end

it 'can be started outside driver' do
expect(service_manager.uri).to be_a(URI)
end
end
Expand Down
10 changes: 7 additions & 3 deletions rb/spec/integration/selenium/webdriver/firefox/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,18 @@ module Firefox
let(:service) { described_class.new }
let(:service_manager) { service.launch }

before { service.executable_path = DriverFinder.path(Options.new, described_class) }
after { service_manager.stop }

it 'auto uses geckodriver' do
service_manager = service.launch
service.executable_path = DriverFinder.path(Options.new, described_class)

expect(service_manager.uri).to be_a(URI)
end

it 'can be started outside driver' do
expect(service_manager.uri).to be_a(URI)
end
end
end # Chrome
end # Firefox
end # WebDriver
end # Selenium

0 comments on commit f843e8b

Please sign in to comment.