Path: blob/trunk/javascript/webdriver/atoms/inject/frame.js
2868 views
// Licensed to the Software Freedom Conservancy (SFC) under one1// or more contributor license agreements. See the NOTICE file2// distributed with this work for additional information3// regarding copyright ownership. The SFC licenses this file4// to you under the Apache License, Version 2.0 (the5// "License"); you may not use this file except in compliance6// with the License. You may obtain a copy of the License at7//8// http://www.apache.org/licenses/LICENSE-2.09//10// Unless required by applicable law or agreed to in writing,11// software distributed under the License is distributed on an12// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY13// KIND, either express or implied. See the License for the14// specific language governing permissions and limitations15// under the License.1617/**18* @fileoverview Ready to inject atoms for handling frames.19*/2021goog.provide('webdriver.atoms.inject.frame');2223goog.require('bot.frame');24goog.require('webdriver.atoms.inject');252627/**28* Finds a frame by id or name.29*30* @param {string} idOrName The frame id or name.31* @param {{bot.inject.WINDOW_KEY: string}=} opt_root The wrapped window to32* perform the search under. Defaults to window.33* @return {string} A frame element wrapped in a JSON string as defined by34* the wire protocol.35*/36webdriver.atoms.inject.frame.findFrameByIdOrName =37function(idOrName, opt_root) {38return webdriver.atoms.inject.executeScript(bot.frame.findFrameByNameOrId,39[idOrName, opt_root]);40};414243/**44* @return {string} A string representing the currently active element.45*/46webdriver.atoms.inject.frame.activeElement = function() {47return webdriver.atoms.inject.executeScript(bot.frame.activeElement, []);48};495051/**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 by57* the wire protocol.58*/59webdriver.atoms.inject.frame.parentFrame = function (opt_root) {60return webdriver.atoms.inject.executeScript(bot.frame.parentFrame,61[opt_root]);62};636465/**66* Finds a frame by index.67*68* @param {number} index The index of the frame to search for.69* @param {!Window=} opt_root The window to perform the search under.70* If not specified window is used as the default.71* @return {string} A frame element wrapped in a JSON string as defined by72* the wire protocol.73*/74webdriver.atoms.inject.frame.findFrameByIndex = function(index, opt_root) {75return webdriver.atoms.inject.executeScript(bot.frame.findFrameByIndex,76[index, opt_root]);77};787980/**81* @return {string} The default content of the current page,82* which is the top window.83*/84webdriver.atoms.inject.frame.defaultContent = function() {85return webdriver.atoms.inject.executeScript(bot.frame.defaultContent, []);86};878889/**90* @param {!{bot.inject.ELEMENT_KEY:string}} element The element to query.91* @return {string} The window corresponding to the frame element92* wrapped in a JSON string as defined by the wire protocol.93*/94webdriver.atoms.inject.frame.getFrameWindow = function(element) {95return webdriver.atoms.inject.executeScript(bot.frame.getFrameWindow,96[element]);97};9899100