Path: blob/trunk/rb/spec/integration/selenium/webdriver/remote/element_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 WebDriver23describe Element, exclusive: {bidi: false, reason: 'Not yet implemented with BiDi'} do24before do25driver.file_detector = lambda(&:first)26end2728after { driver.file_detector = nil }2930context 'when uploading one file' do31it 'uses the provided file detector', exclusive: {driver: :remote},32flaky: {browser: :safari,33ci: :github,34reason: 'unreliable with downloads'} do35driver.navigate.to url_for('upload.html')3637driver.find_element(id: 'upload').send_keys(create_tempfile.path)38driver.find_element(id: 'go').click39wait.until { driver.find_element(id: 'upload_label').displayed? }4041driver.switch_to.frame('upload_target')42wait.until { !driver.find_element(xpath: '//body').text.empty? }4344body = driver.find_element(xpath: '//body')45expect(body.text.scan('This is a dummy test file').count).to eq(1)46end47end4849context 'when uploading multiple files' do50it 'uses the provided file detector', exclusive: {driver: :remote},51flaky: {browser: :safari,52ci: :github,53reason: 'unreliable with downloads'} do54driver.navigate.to url_for('upload_multiple.html')55file1 = create_tempfile56file2 = create_tempfile5758driver.find_element(id: 'upload').send_keys("#{file1.path}\n#{file2.path}")59driver.find_element(id: 'go').click60wait.until { driver.find_element(id: 'upload_label').displayed? }6162driver.switch_to.frame('upload_target')63wait.until { !driver.find_element(xpath: '//body').text.empty? }6465body = driver.find_element(xpath: '//body')66expect(body.text.scan('This is a dummy test file').count).to eq(2)67end68end69end70end # WebDriver71end # Selenium727374