Skip to content

Commit e6f1131

Browse files
committed
[rb] fix bug preventing processing of Chrome profile
1 parent 957b37e commit e6f1131

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

rb/lib/selenium/webdriver/chrome/profile.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@ module Chrome
2727
class Profile
2828
include ProfileHelper
2929

30-
attr_reader :directory
31-
3230
def initialize(model = nil)
3331
@model = verify_model(model)
3432
@extensions = []
3533
@encoded_extensions = []
34+
@directory = nil
3635
end
3736

3837
def add_extension(path)
@@ -45,6 +44,10 @@ def add_encoded_extension(encoded)
4544
@encoded_extensions << encoded
4645
end
4746

47+
def directory
48+
@directory || layout_on_disk
49+
end
50+
4851
#
4952
# Set a preference in the profile.
5053
#

rb/spec/unit/selenium/webdriver/chrome/options_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,16 @@ module Chrome
217217
expect(options.as_json).to eq("browserName" => "chrome", "goog:chromeOptions" => {"foo" => "bar"})
218218
end
219219

220+
it 'converts profile' do
221+
profile = Profile.new
222+
directory = profile.directory
223+
224+
opts = Options.new(profile: profile)
225+
expect(opts.as_json).to eq('browserName' => 'chrome',
226+
'goog:chromeOptions' =>
227+
{'args' => ["--user-data-dir=#{directory}"]})
228+
end
229+
220230
it 'returns a JSON hash' do
221231
allow(File).to receive(:file?).and_return(true)
222232
allow_any_instance_of(Options).to receive(:encode_extension).with('foo.crx').and_return("encoded_foo")

0 commit comments

Comments
 (0)