Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/rb/spec/integration/selenium/webdriver/remote/element_spec.rb
1865 views
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: {bidi: false, reason: 'Not yet implemented with BiDi'} do
25
before do
26
driver.file_detector = lambda(&:first)
27
end
28
29
after { driver.file_detector = nil }
30
31
context 'when uploading one file' do
32
it 'uses the provided file detector', exclusive: {driver: :remote},
33
flaky: {browser: :safari,
34
ci: :github,
35
reason: 'unreliable with downloads'} do
36
driver.navigate.to url_for('upload.html')
37
38
driver.find_element(id: 'upload').send_keys(create_tempfile.path)
39
driver.find_element(id: 'go').click
40
wait.until { driver.find_element(id: 'upload_label').displayed? }
41
42
driver.switch_to.frame('upload_target')
43
wait.until { !driver.find_element(xpath: '//body').text.empty? }
44
45
body = driver.find_element(xpath: '//body')
46
expect(body.text.scan('This is a dummy test file').count).to eq(1)
47
end
48
end
49
50
context 'when uploading multiple files' do
51
it 'uses the provided file detector', exclusive: {driver: :remote},
52
flaky: {browser: :safari,
53
ci: :github,
54
reason: 'unreliable with downloads'} do
55
driver.navigate.to url_for('upload_multiple.html')
56
file1 = create_tempfile
57
file2 = create_tempfile
58
59
driver.find_element(id: 'upload').send_keys("#{file1.path}\n#{file2.path}")
60
driver.find_element(id: 'go').click
61
wait.until { driver.find_element(id: 'upload_label').displayed? }
62
63
driver.switch_to.frame('upload_target')
64
wait.until { !driver.find_element(xpath: '//body').text.empty? }
65
66
body = driver.find_element(xpath: '//body')
67
expect(body.text.scan('This is a dummy test file').count).to eq(2)
68
end
69
end
70
end
71
end # WebDriver
72
end # Selenium
73
74