blob: 0f33d22f750e581e7170c433a07a826528fd9461 [file] [log] [blame]
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_TEST_CHROMEDRIVER_WINDOW_COMMANDS_H_
#define CHROME_TEST_CHROMEDRIVER_WINDOW_COMMANDS_H_
#include <memory>
#include <string>
#include "base/callback_forward.h"
namespace base {
class DictionaryValue;
class Value;
}
struct Session;
class Status;
class Timeout;
class WebView;
typedef base::Callback<Status(Session* session,
WebView* web_view,
const base::DictionaryValue&,
std::unique_ptr<base::Value>*,
Timeout*)> WindowCommand;
// Execute a Window Command on the target window.
Status ExecuteWindowCommand(const WindowCommand& command,
Session* session,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value);
// Loads a URL.
Status ExecuteGet(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
// Evaluates a given synchronous script with arguments.
Status ExecuteExecuteScript(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
// Evaluates a given asynchronous script with arguments.
Status ExecuteExecuteAsyncScript(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
// Changes the targeted frame for the given session.
Status ExecuteSwitchToFrame(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
// Change focus to the parent frame.
Status ExecuteSwitchToParentFrame(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
// Get the current page title.
Status ExecuteGetTitle(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
// Get the current page source.
Status ExecuteGetPageSource(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
// Search for an element on the page, starting from the document root.
Status ExecuteFindElement(int interval_ms,
Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
// Search for multiple elements on the page, starting from the document root.
Status ExecuteFindElements(int interval_ms,
Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
// Get the current page url.
Status ExecuteGetCurrentUrl(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
// Navigate backward in the browser history.
Status ExecuteGoBack(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
// Navigate forward in the browser history.
Status ExecuteGoForward(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
// Refresh the current page.
Status ExecuteRefresh(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
// Move the mouse by an offset of the element if specified .
Status ExecuteMouseMoveTo(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
// Click a mouse button at the coordinates set by the last moveto.
Status ExecuteMouseClick(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
// Click and hold a mouse button at the coordinates set by the last moveto.
Status ExecuteMouseButtonDown(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
// Releases the mouse button previously held (where the mouse is currently at).
Status ExecuteMouseButtonUp(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
// Double-clicks at the current mouse coordinates (set by last moveto).
Status ExecuteMouseDoubleClick(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
// Touch press at a given coordinate.
Status ExecuteTouchDown(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
// Touch release at a given coordinate.
Status ExecuteTouchUp(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
// Touch move at a given coordinate.
Status ExecuteTouchMove(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
// Do a swipe (scroll) gesture beginning at the element.
Status ExecuteTouchScroll(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
Status ExecuteTouchPinch(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
Status ExecuteGetActiveElement(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
// Send a sequence of key strokes to the active element.
Status ExecuteSendKeysToActiveElement(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
// Gets the status of the application cache (window.applicationCache.status).
Status ExecuteGetAppCacheStatus(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
Status ExecuteIsBrowserOnline(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
Status ExecuteGetStorageItem(const char* storage,
Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
Status ExecuteGetStorageKeys(const char* storage,
Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
Status ExecuteSetStorageItem(const char* storage,
Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
Status ExecuteRemoveStorageItem(const char* storage,
Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
Status ExecuteClearStorage(const char* storage,
Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
Status ExecuteGetStorageSize(const char* storage,
Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
Status ExecuteScreenshot(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
// Retrieve all cookies visible to the current page.
Status ExecuteGetCookies(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
// Set a cookie. If the cookie path is not specified, it should be set to "/".
// If the domain is omitted, it should default to the current page's domain.
Status ExecuteAddCookie(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
// Delete the cookie with the given name if it exists in the current page.
Status ExecuteDeleteCookie(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
// Delete all cookies visible to the current page.
Status ExecuteDeleteAllCookies(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
Status ExecuteSetLocation(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
Status ExecuteSetNetworkConditions(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
Status ExecuteDeleteNetworkConditions(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
Status ExecuteTakeHeapSnapshot(Session* session,
WebView* web_view,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value,
Timeout* timeout);
#endif // CHROME_TEST_CHROMEDRIVER_WINDOW_COMMANDS_H_