Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
seleniumhq
GitHub Repository: seleniumhq/selenium
Path: blob/trunk/javascript/webdriver/atoms/inject/frame.js
2868 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
/**
19
* @fileoverview Ready to inject atoms for handling frames.
20
*/
21
22
goog.provide('webdriver.atoms.inject.frame');
23
24
goog.require('bot.frame');
25
goog.require('webdriver.atoms.inject');
26
27
28
/**
29
* Finds a frame by id or name.
30
*
31
* @param {string} idOrName The frame id or name.
32
* @param {{bot.inject.WINDOW_KEY: string}=} opt_root The wrapped window to
33
* perform the search under. Defaults to window.
34
* @return {string} A frame element wrapped in a JSON string as defined by
35
* the wire protocol.
36
*/
37
webdriver.atoms.inject.frame.findFrameByIdOrName =
38
function(idOrName, opt_root) {
39
return webdriver.atoms.inject.executeScript(bot.frame.findFrameByNameOrId,
40
[idOrName, opt_root]);
41
};
42
43
44
/**
45
* @return {string} A string representing the currently active element.
46
*/
47
webdriver.atoms.inject.frame.activeElement = function() {
48
return webdriver.atoms.inject.executeScript(bot.frame.activeElement, []);
49
};
50
51
52
/**
53
* Finds the parent frame of the specified frame.
54
*
55
* @param {!Window=} opt_root The window to perform the search under.
56
* If not specified window is used as the default.
57
* @return {string} A frame element wrapped in a JSON string as defined by
58
* the wire protocol.
59
*/
60
webdriver.atoms.inject.frame.parentFrame = function (opt_root) {
61
return webdriver.atoms.inject.executeScript(bot.frame.parentFrame,
62
[opt_root]);
63
};
64
65
66
/**
67
* Finds a frame by index.
68
*
69
* @param {number} index The index of the frame to search for.
70
* @param {!Window=} opt_root The window to perform the search under.
71
* If not specified window is used as the default.
72
* @return {string} A frame element wrapped in a JSON string as defined by
73
* the wire protocol.
74
*/
75
webdriver.atoms.inject.frame.findFrameByIndex = function(index, opt_root) {
76
return webdriver.atoms.inject.executeScript(bot.frame.findFrameByIndex,
77
[index, opt_root]);
78
};
79
80
81
/**
82
* @return {string} The default content of the current page,
83
* which is the top window.
84
*/
85
webdriver.atoms.inject.frame.defaultContent = function() {
86
return webdriver.atoms.inject.executeScript(bot.frame.defaultContent, []);
87
};
88
89
90
/**
91
* @param {!{bot.inject.ELEMENT_KEY:string}} element The element to query.
92
* @return {string} The window corresponding to the frame element
93
* wrapped in a JSON string as defined by the wire protocol.
94
*/
95
webdriver.atoms.inject.frame.getFrameWindow = function(element) {
96
return webdriver.atoms.inject.executeScript(bot.frame.getFrameWindow,
97
[element]);
98
};
99
100