Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/rb/spec/integration/selenium/webdriver/fedcm_spec.rb
4058 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
module FedCM
25
describe FedCM, exclusive: [{bidi: false, reason: 'Not yet implemented with BiDi'}, {browser: %i[chrome edge]}] do
26
let(:dialog) { driver.fedcm_dialog }
27
28
before { driver.get url_for('fedcm/fedcm.html') }
29
after { reset_driver! }
30
31
context 'without dialog present' do
32
it 'throws an error' do
33
expect { dialog.title }.to raise_error(Error::NoSuchAlertError)
34
expect { dialog.subtitle }.to raise_error(Error::NoSuchAlertError)
35
expect { dialog.type }.to raise_error(Error::NoSuchAlertError)
36
expect { dialog.accounts }.to raise_error(Error::NoSuchAlertError)
37
expect { dialog.select_account(1) }.to raise_error(Error::NoSuchAlertError)
38
expect { dialog.cancel }.to raise_error(Error::NoSuchAlertError)
39
end
40
end
41
42
context 'with dialog present' do
43
before do
44
driver.execute_script('triggerFedCm();')
45
driver.wait_for_fedcm_dialog
46
end
47
48
it 'returns the title' do
49
expect(dialog.title).to eq('Sign in to localhost with localhost')
50
end
51
52
it 'returns the subtitle' do
53
expect(dialog.subtitle).to be_nil
54
end
55
56
it 'returns the type' do
57
expect(dialog.type).to eq('AccountChooser')
58
end
59
60
it 'returns the accounts' do
61
first_account = dialog.accounts.first
62
expect(first_account.name).to eq 'John Doe'
63
end
64
65
it 'selects an account' do
66
expect(dialog.select_account(1)).to be_nil
67
end
68
69
it 'clicks the dialog', except: {browser: %i[chrome edge],
70
reason: "error: 'Use another account' not supported for this IDP"} do
71
expect(dialog.click).to be_nil
72
end
73
74
it 'cancels the dialog' do
75
dialog.cancel
76
expect { dialog.title }.to raise_error(Error::NoSuchAlertError)
77
end
78
79
it 'sets the delay' do
80
expect(driver.enable_fedcm_delay = true).to be_truthy
81
end
82
83
it 'resets the cooldown' do
84
expect(driver.reset_fedcm_cooldown).to be_nil
85
end
86
end
87
end
88
end # FedCm
89
end # WebDriver
90
end # Selenium
91
92