Path: blob/trunk/rb/spec/integration/selenium/webdriver/edge/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 Edge24describe Profile, exclusive: [{bidi: false, reason: 'Not yet implemented with BiDi'}, {browser: :edge}] do25let(:profile) { described_class.new }2627it 'adds an extension' do28ext_path = '/some/path.crx'2930allow(File).to receive(:file?).with(ext_path).and_return true31expect(profile.add_extension(ext_path)).to eq([ext_path])32end3334it 'reads an extension as binary data' do35ext_path = '/some/path.crx'36allow(File).to receive(:file?).with(ext_path).and_return true3738profile.add_extension(ext_path)3940ext_file = instance_double(File)41allow(File).to receive(:open).with(ext_path, 'rb').and_yield ext_file42allow(ext_file).to receive(:read).and_return 'test'4344allow(profile).to receive(:layout_on_disk).and_return 'ignored'4546expect(profile.as_json).to eq('directory' => 'ignored',47'extensions' => [Base64.strict_encode64('test')])48expect(ext_file).to have_received(:read)49end5051it "raises an error if the extension doesn't exist" do52expect {53profile.add_extension('/not/likely/to/exist.crx')54}.to raise_error(Selenium::WebDriver::Error::WebDriverError)55end56end57end # Edge58end # WebDriver59end # Selenium606162