Path: blob/trunk/rb/spec/integration/selenium/webdriver/edge/driver_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 Driver, exclusive: [{bidi: false, reason: 'Not yet implemented with BiDi'}, {browser: :edge}] do25it 'gets and sets network conditions' do26driver.network_conditions = {offline: false, latency: 56, throughput: 789}27expect(driver.network_conditions).to eq(28'offline' => false,29'latency' => 56,30'download_throughput' => 789,31'upload_throughput' => 78932)33driver.delete_network_conditions34end3536it 'supports default network conditions' do37driver.network_conditions = {latency: 56}38expect(driver.network_conditions).to eq(39'offline' => false,40'latency' => 56,41'download_throughput' => -1,42'upload_throughput' => -143)44driver.delete_network_conditions4546# Need to reset because https://bugs.chromium.org/p/chromedriver/issues/detail?id=479047reset_driver!48end4950it 'sets download path' do51expect { driver.download_path = File.expand_path(__dir__) }.not_to raise_exception52end5354it 'can execute CDP commands' do55res = driver.execute_cdp('Page.addScriptToEvaluateOnNewDocument', source: 'window.was_here="TW";')56expect(res).to have_key('identifier')5758begin59driver.navigate.to url_for('formPage.html')6061tw = driver.execute_script('return window.was_here')62expect(tw).to eq('TW')63ensure64driver.execute_cdp('Page.removeScriptToEvaluateOnNewDocument', identifier: res['identifier'])65end66end6768describe '#logs' do69before do70reset_driver!(logging_prefs: {browser: 'ALL',71driver: 'ALL',72performance: 'ALL'})73driver.navigate.to url_for('errors.html')74end7576after(:all) { reset_driver! }7778it 'can fetch available log types' do79expect(driver.logs.available_types).to include(:performance, :browser, :driver)80end8182it 'can get the browser log' do83driver.find_element(tag_name: 'input').click8485entries = driver.logs.get(:browser)86expect(entries).not_to be_empty87expect(entries.first).to be_a(LogEntry)88end8990it 'can get the driver log' do91entries = driver.logs.get(:driver)92expect(entries).not_to be_empty93expect(entries.first).to be_a(LogEntry)94end9596it 'can get the performance log' do97entries = driver.logs.get(:performance)98expect(entries).not_to be_empty99expect(entries.first).to be_a(LogEntry)100end101end102103# This requires cast sinks to run104it 'casts' do105# Does not get list correctly the first time for some reason106driver.cast_sinks107sleep 2108sinks = driver.cast_sinks109unless sinks.empty?110device_name = sinks.first['name']111driver.start_cast_tab_mirroring(device_name)112expect { driver.stop_casting(device_name) }.not_to raise_exception113end114end115end116end # Edge117end # WebDriver118end # Selenium119120121