Path: blob/trunk/rb/spec/unit/selenium/webdriver/common/service_spec.rb
4103 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 File.expand_path('../spec_helper', __dir__)2021module Selenium22module WebDriver23describe Service do24let(:service_path) { '/path/to/service' }2526before do27allow(Platform).to receive(:assert_executable)28allow(WebDriver.logger).to receive(:debug?).and_return(false)29stub_const('Selenium::WebDriver::Service::DEFAULT_PORT', 1234)30stub_const('Selenium::WebDriver::Service::EXECUTABLE', 'service')31end3233describe 'browser shortcuts' do34let(:args) { %w[--foo --bar] }3536it 'creates Chrome instance' do37service = described_class.chrome(args: args)38expect(service).to be_a(Chrome::Service)39expect(service.args).to eq args40end4142it 'creates Edge instance' do43service = described_class.edge(args: args)44expect(service).to be_a(Edge::Service)45expect(service.args).to eq args46end4748it 'creates Firefox instance' do49service = described_class.firefox(args: args)50expect(service).to be_a(Firefox::Service)51expect(service.args).to eq(args + %w[--websocket-port 0])52end5354it 'creates IE instance' do55service = described_class.internet_explorer(args: args)56expect(service).to be_a(IE::Service)57expect(service.args).to eq args58end5960it 'creates Safari instance' do61service = described_class.safari(args: args)62expect(service).to be_a(Safari::Service)63expect(service.args).to eq args64end65end66end67end # WebDriver68end # Selenium697071