Skip to content

Commit

Permalink
allow passing selenium options (#537)
Browse files Browse the repository at this point in the history
  • Loading branch information
odedniv authored and jejacks0n committed Dec 9, 2018
1 parent 9a2509d commit 0fa9b8f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 6 additions & 2 deletions lib/teaspoon/driver/selenium.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ def initialize(options = nil)
end

def run_specs(runner, url)
driver = ::Selenium::WebDriver.for(driver_options[:client_driver])
driver = ::Selenium::WebDriver.for(
driver_options[:client_driver],
**driver_options[:selenium_options].to_hash.to_options
)
driver.navigate.to(url)

::Selenium::WebDriver::Wait.new(driver_options).until do
Expand All @@ -44,7 +47,8 @@ def driver_options
client_driver: :firefox,
timeout: Teaspoon.configuration.driver_timeout.to_i,
interval: 0.01,
message: "Timed out"
message: 'Timed out',
selenium_options: {}
).merge(@options)
end
end
Expand Down
10 changes: 8 additions & 2 deletions spec/teaspoon/driver/selenium_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

describe "#run_specs" do
it "loads firefox for the webdriver" do
expect(Selenium::WebDriver).to receive(:for).with(:firefox)
expect(Selenium::WebDriver).to receive(:for).with(:firefox, {})
subject.run_specs(runner, "_url_")
end

Expand All @@ -53,7 +53,13 @@
end

it "waits for the specs to complete, setting the interval, timeout and message" do
hash = HashWithIndifferentAccess.new(client_driver: :firefox, timeout: 180, interval: 0.01, message: "Timed out")
hash = HashWithIndifferentAccess.new(
client_driver: :firefox,
timeout: 180,
interval: 0.01,
message: 'Timed out',
selenium_options: {}
)
expect(Selenium::WebDriver::Wait).to receive(:new).with(hash)
subject.run_specs(runner, "_url_")
end
Expand Down

0 comments on commit 0fa9b8f

Please sign in to comment.