"Fossies" - the Fresh Open Source Software Archive 
Member "selenium-selenium-4.8.1/rb/spec/integration/selenium/webdriver/remote/element_spec.rb" (17 Feb 2023, 2433 Bytes) of package /linux/www/selenium-selenium-4.8.1.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Ruby source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
1 # frozen_string_literal: true
2
3 # Licensed to the Software Freedom Conservancy (SFC) under one
4 # or more contributor license agreements. See the NOTICE file
5 # distributed with this work for additional information
6 # regarding copyright ownership. The SFC licenses this file
7 # to you under the Apache License, Version 2.0 (the
8 # "License"); you may not use this file except in compliance
9 # with the License. You may obtain a copy of the License at
10 #
11 # http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing,
14 # software distributed under the License is distributed on an
15 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 # KIND, either express or implied. See the License for the
17 # specific language governing permissions and limitations
18 # under the License.
19
20 require_relative '../spec_helper'
21
22 module Selenium
23 module WebDriver
24 describe Element, exclusive: {driver: :remote} do
25 before do
26 driver.file_detector = ->(filename) { File.join(__dir__, filename) }
27 end
28
29 after do
30 driver.file_detector = nil
31 end
32
33 context 'when uploading one file' do
34 it 'uses the provided file detector' do
35 driver.navigate.to url_for('upload.html')
36
37 driver.find_element(id: 'upload').send_keys('element_spec.rb')
38 driver.find_element(id: 'go').submit
39 wait.until { driver.find_element(id: 'upload_label').displayed? }
40
41 driver.switch_to.frame('upload_target')
42 wait.until { driver.find_element(xpath: '//body') }
43
44 body = driver.find_element(xpath: '//body')
45 expect(body.text.scan('Licensed to the Software Freedom Conservancy').count).to eq(3)
46 end
47 end
48
49 context 'when uploading multiple files' do
50 it 'uses the provided file detector' do
51 driver.navigate.to url_for('upload_multiple.html')
52
53 driver.find_element(id: 'upload').send_keys("driver_spec.rb\nelement_spec.rb")
54 driver.find_element(id: 'go').submit
55 wait.until { driver.find_element(id: 'upload_label').displayed? }
56
57 driver.switch_to.frame('upload_target')
58 wait.until { driver.find_element(xpath: '//body') }
59
60 body = driver.find_element(xpath: '//body')
61 expect(body.text.scan('Licensed to the Software Freedom Conservancy').count).to eq(5)
62 end
63 end
64 end
65 end # WebDriver
66 end # Selenium