Path: blob/trunk/rb/spec/integration/selenium/webdriver/chrome/profile_spec.rb
1865 views
# frozen_string_literal: true12# Licensed to the Software Freedom Conservancy (SFC) under one3# or more contributor license agreements. See the NOTICE file4# distributed with this work for additional information5# regarding copyright ownership. The SFC licenses this file6# to you under the Apache License, Version 2.0 (the7# "License"); you may not use this file except in compliance8# with the License. You may obtain a copy of the License at9#10# http://www.apache.org/licenses/LICENSE-2.011#12# Unless required by applicable law or agreed to in writing,13# software distributed under the License is distributed on an14# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY15# KIND, either express or implied. See the License for the16# specific language governing permissions and limitations17# under the License.1819require_relative '../spec_helper'2021module Selenium22module WebDriver23module Chrome24describe Profile, exclusive: [{bidi: false, reason: 'Not yet implemented with BiDi'}, {browser: :chrome}] do25let(:profile) { described_class.new }2627it 'adds an extension' do28ext_path = '/some/path.crx'2930allow(File).to receive(:file?).with(ext_path).and_return true3132expect(profile.add_extension(ext_path)).to eq([ext_path])33end3435it 'reads an extension as binary data' do36ext_path = '/some/path.crx'37allow(File).to receive(:file?).with(ext_path).and_return true3839profile.add_extension(ext_path)4041ext_file = instance_double(File)42allow(File).to receive(:open).with(ext_path, 'rb').and_yield ext_file43allow(ext_file).to receive(:read).and_return 'test'4445allow(profile).to receive(:layout_on_disk).and_return 'ignored'4647expect(profile.as_json).to eq('directory' => 'ignored',48'extensions' => [Base64.strict_encode64('test')])49expect(ext_file).to have_received(:read)50end5152it "raises an error if the extension doesn't exist" do53expect {54profile.add_extension('/not/likely/to/exist.crx')55}.to raise_error(Selenium::WebDriver::Error::WebDriverError)56end57end58end # Chrome59end # WebDriver60end # Selenium616263