Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/rb/spec/integration/selenium/webdriver/edge/profile_spec.rb
1865 views
1
# frozen_string_literal: true
2
3
# Licensed to the Software Freedom Conservancy (SFC) under one
4
# or more contributor license agreements. See the NOTICE file
5
# distributed with this work for additional information
6
# regarding copyright ownership. The SFC licenses this file
7
# to you under the Apache License, Version 2.0 (the
8
# "License"); you may not use this file except in compliance
9
# with the License. You may obtain a copy of the License at
10
#
11
# http://www.apache.org/licenses/LICENSE-2.0
12
#
13
# Unless required by applicable law or agreed to in writing,
14
# software distributed under the License is distributed on an
15
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
# KIND, either express or implied. See the License for the
17
# specific language governing permissions and limitations
18
# under the License.
19
20
require_relative '../spec_helper'
21
22
module Selenium
23
module WebDriver
24
module Edge
25
describe Profile, exclusive: [{bidi: false, reason: 'Not yet implemented with BiDi'}, {browser: :edge}] do
26
let(:profile) { described_class.new }
27
28
it 'adds an extension' do
29
ext_path = '/some/path.crx'
30
31
allow(File).to receive(:file?).with(ext_path).and_return true
32
expect(profile.add_extension(ext_path)).to eq([ext_path])
33
end
34
35
it 'reads an extension as binary data' do
36
ext_path = '/some/path.crx'
37
allow(File).to receive(:file?).with(ext_path).and_return true
38
39
profile.add_extension(ext_path)
40
41
ext_file = instance_double(File)
42
allow(File).to receive(:open).with(ext_path, 'rb').and_yield ext_file
43
allow(ext_file).to receive(:read).and_return 'test'
44
45
allow(profile).to receive(:layout_on_disk).and_return 'ignored'
46
47
expect(profile.as_json).to eq('directory' => 'ignored',
48
'extensions' => [Base64.strict_encode64('test')])
49
expect(ext_file).to have_received(:read)
50
end
51
52
it "raises an error if the extension doesn't exist" do
53
expect {
54
profile.add_extension('/not/likely/to/exist.crx')
55
}.to raise_error(Selenium::WebDriver::Error::WebDriverError)
56
end
57
end
58
end # Edge
59
end # WebDriver
60
end # Selenium
61
62