Path: blob/trunk/rb/spec/integration/selenium/webdriver/error_spec.rb
4010 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 WebDriver23describe Error, exclusive: {bidi: false, reason: 'Not yet implemented with BiDi'} do24it 'raises an appropriate error' do25driver.navigate.to url_for('xhtmlTest.html')2627expect {28driver.find_element(id: 'nonexistent')29}.to raise_error(WebDriver::Error::NoSuchElementError, /#nosuchelementexception/)30end3132it 'has backtrace locations' do33driver.find_element(id: 'nonexistent')34rescue WebDriver::Error::NoSuchElementError => e35expect(e.backtrace_locations).not_to be_empty36end3738it 'has cause' do39driver.find_element(id: 'nonexistent')40rescue WebDriver::Error::NoSuchElementError => e41expect(e.cause).to be_a(WebDriver::Error::WebDriverError)42end4344it 'has backtrace' do45driver.find_element(id: 'nonexistent')46rescue WebDriver::Error::NoSuchElementError => e47expect(e.backtrace).not_to be_empty48end4950it 'has backtrace when using a remote server', exclusive: {driver: :remote} do51driver.send(:bridge).instance_variable_set(:@session_id, 'fake_session_id')52driver.window_handle53rescue WebDriver::Error::InvalidSessionIdError => e54expect(e.backtrace).not_to be_empty55end56end57end # WebDriver58end # Selenium596061