Skip to content

Commit

Permalink
[rb] fix bug preventing processing of Chrome profile
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Mar 27, 2021
1 parent 957b37e commit e6f1131
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
7 changes: 5 additions & 2 deletions rb/lib/selenium/webdriver/chrome/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ module Chrome
class Profile
include ProfileHelper

attr_reader :directory

def initialize(model = nil)
@model = verify_model(model)
@extensions = []
@encoded_extensions = []
@directory = nil
end

def add_extension(path)
Expand All @@ -45,6 +44,10 @@ def add_encoded_extension(encoded)
@encoded_extensions << encoded
end

def directory
@directory || layout_on_disk
end

#
# Set a preference in the profile.
#
Expand Down
10 changes: 10 additions & 0 deletions rb/spec/unit/selenium/webdriver/chrome/options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,16 @@ module Chrome
expect(options.as_json).to eq("browserName" => "chrome", "goog:chromeOptions" => {"foo" => "bar"})
end

it 'converts profile' do
profile = Profile.new
directory = profile.directory

opts = Options.new(profile: profile)
expect(opts.as_json).to eq('browserName' => 'chrome',
'goog:chromeOptions' =>
{'args' => ["--user-data-dir=#{directory}"]})
end

it 'returns a JSON hash' do
allow(File).to receive(:file?).and_return(true)
allow_any_instance_of(Options).to receive(:encode_extension).with('foo.crx').and_return("encoded_foo")
Expand Down

0 comments on commit e6f1131

Please sign in to comment.