Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
seleniumhq
GitHub Repository: seleniumhq/selenium
Path: blob/trunk/javascript/selenium-webdriver/lib/fedcm/dialog.js
2885 views
1
// Licensed to the Software Freedom Conservancy (SFC) under one
2
// or more contributor license agreements. See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership. The SFC licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License. You may obtain a copy of the License at
8
//
9
// http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied. See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
const command = require('../command')
19
const Account = require('./account')
20
21
class Dialog {
22
constructor(driver) {
23
this._driver = driver
24
}
25
26
async title() {
27
const result = await this._driver.execute(new command.Command(command.Name.GET_FEDCM_TITLE))
28
29
return result.title
30
}
31
32
subtitle() {
33
return this._driver.execute(new command.Command(command.Name.GET_FEDCM_TITLE))
34
}
35
36
type() {
37
return this._driver.execute(new command.Command(command.Name.GET_FEDCM_DIALOG_TYPE))
38
}
39
40
async accounts() {
41
const result = await this._driver.execute(new command.Command(command.Name.GET_ACCOUNTS))
42
43
const accountArray = []
44
45
result.forEach((account) => {
46
const acc = new Account(
47
account.accountId,
48
account.email,
49
account.name,
50
account.givenName,
51
account.pictureUrl,
52
account.idpConfigUrl,
53
account.loginState,
54
account.termsOfServiceUrl,
55
account.privacyPolicyUrl,
56
)
57
accountArray.push(acc)
58
})
59
60
return accountArray
61
}
62
63
selectAccount(index) {
64
return this._driver.execute(new command.Command(command.Name.SELECT_ACCOUNT).setParameter('accountIndex', index))
65
}
66
67
accept() {
68
return this._driver.execute(new command.Command(command.Name.CLICK_DIALOG_BUTTON))
69
}
70
71
dismiss() {
72
return this._driver.execute(new command.Command(command.Name.CANCEL_DIALOG))
73
}
74
}
75
76
module.exports = Dialog
77
78