File tree 4 files changed +42
-0
lines changed
4 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,19 @@ bot.frame.activeElement = function() {
42
42
} ;
43
43
44
44
45
+ /**
46
+ * Gets the parent frame of the specified frame.
47
+ *
48
+ * @param {!Window= } opt_root The window get the parent of.
49
+ * Defaults to {@code bot.getWindow()}.
50
+ * @return {Window } The frame if found, null otherwise.
51
+ */
52
+ bot . frame . parentFrame = function ( opt_root ) {
53
+ var domWindow = opt_root || bot . getWindow ( ) ;
54
+ return domWindow . parent ;
55
+ } ;
56
+
57
+
45
58
/**
46
59
* Returns a reference to the window object corresponding to the given element.
47
60
* Note that the element must be a frame or an iframe.
Original file line number Diff line number Diff line change 160
160
var index = bot . frame . getFrameIndex ( el , frameWin ) ;
161
161
assertEquals ( 1 , index ) ;
162
162
}
163
+
164
+ function testFindParentFrame ( ) {
165
+ var frameWin = bot . frame . parentFrame ( window . frames [ 1 ] ) ;
166
+ assertEquals ( frameWin , window ) ;
167
+ }
168
+
169
+ function testParentFrameOnTopLevelIsNoOp ( ) {
170
+ var frameWin = bot . frame . parentFrame ( window ) ;
171
+ assertEquals ( frameWin , window ) ;
172
+ }
163
173
</ script >
164
174
</ head >
165
175
< frameset rows ="*,*,* " >
Original file line number Diff line number Diff line change @@ -83,6 +83,11 @@ js_fragment(name = "default_content",
83
83
function = "webdriver.atoms.inject.frame.defaultContent",
84
84
deps = ["//javascript/webdriver/atoms/inject:deps"])
85
85
86
+ js_fragment(name = "get_parent_frame",
87
+ module = "webdriver.atoms.inject.frame",
88
+ function = "webdriver.atoms.inject.frame.parentFrame",
89
+ deps = ["//javascript/webdriver/atoms/inject:deps"])
90
+
86
91
js_fragment(name = "get_frame_window",
87
92
module = "webdriver.atoms.inject.frame",
88
93
function = "webdriver.atoms.inject.frame.getFrameWindow",
Original file line number Diff line number Diff line change @@ -48,6 +48,20 @@ webdriver.atoms.inject.frame.activeElement = function() {
48
48
} ;
49
49
50
50
51
+ /**
52
+ * Finds the parent frame of the specified frame.
53
+ *
54
+ * @param {!Window= } opt_root The window to perform the search under.
55
+ * If not specified window is used as the default.
56
+ * @return {string } A frame element wrapped in a JSON string as defined by
57
+ * the wire protocol.
58
+ */
59
+ webdriver . atoms . inject . frame . parentFrame = function ( opt_root ) {
60
+ return webdriver . atoms . inject . executeScript ( bot . frame . parentFrame ,
61
+ [ opt_root ] ) ;
62
+ } ;
63
+
64
+
51
65
/**
52
66
* Finds a frame by index.
53
67
*
You can’t perform that action at this time.
0 commit comments