### Start FennecInstance in Marionette Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Method to start the FennecInstance, initiating the mobile Gecko browser process. This is a fundamental operation for launching the browser on an emulator. ```python def start(self): pass ``` -------------------------------- ### Install and Uninstall Firefox Addons with Marionette Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index This snippet demonstrates how to install and uninstall Firefox addons using the Addons API provided by the marionette_driver. It covers installing from a file path or base64 encoded data, and uninstalling by addon ID. It also mentions potential exceptions like AddonInstallException and ScriptTimeoutException. ```python from marionette_driver.addons import Addons # Assuming 'marionette' is an initialized Marionette instance addons = Addons(marionette) # Install an addon from a local file try: addon_id = addons.install("/path/to/extension.xpi") print(f"Addon installed with ID: {addon_id}") except AddonInstallException as e: print(f"Failed to install addon: {e}") # Install a temporary addon try: temp_addon_id = addons.install("/path/to/another_extension.xpi", temp=True) print(f"Temporary addon installed with ID: {temp_addon_id}") except AddonInstallException as e: print(f"Failed to install temporary addon: {e}") # Uninstall an addon by its ID try: addons.uninstall(addon_id) print(f"Addon {addon_id} uninstalled successfully.") except Exception as e: # Catching a general exception as specific ones might vary print(f"Failed to uninstall addon {addon_id}: {e}") ``` -------------------------------- ### orientation Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Gets the current browser orientation. ```APIDOC ## GET /session/{sessionId}/orientation ### Description Get the current browser orientation. Will return one of the valid primary orientation values portrait-primary, landscape-primary, portrait-secondary, or landscape-secondary. ### Method GET ### Endpoint /session/{sessionId}/orientation ### Parameters #### Query Parameters - **None** ### Request Example ```json {} ``` ### Response #### Success Response (200) - **value** (string) - The current orientation. Possible values: "portrait-primary", "landscape-primary", "portrait-secondary", "landscape-secondary". #### Response Example ```json { "value": "portrait-primary" } ``` ``` -------------------------------- ### Set Date and Time Input Values with Marionette Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index This example shows how to interact with HTML5 'date' and 'time' input elements using the DateTimeValue class from marionette_driver. It demonstrates finding an element and then setting its date value. The DateTimeValue class abstracts the process of converting Python datetime objects to the string format expected by these input types. ```python from datetime import datetime from marionette_driver.by import By from marionette_driver.date_time_value import DateTimeValue # Assuming 'marionette' is an initialized Marionette instance # Find the date/time input element try: element = marionette.find_element(By.ID, "date-test") dt_value = DateTimeValue(element) # Set the date value dt_value.date = datetime(1998, 6, 2) print("Date set successfully.") # Set the time value (example) # dt_value.time = "14:30:00" # print("Time set successfully.") except Exception as e: print(f"An error occurred: {e}") ``` -------------------------------- ### Addons API Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Provides an API for installing and inspecting addons within the Gecko runtime. It's a partial implementation of Gecko's AddonManager API. ```APIDOC ## marionette_driver.addons.Addons ### Description An API for installing and inspecting addons during Gecko runtime. This is a partially implemented wrapper around Gecko’s AddonManager API. ### Method N/A (Class) ### Endpoint N/A (Class) ### Parameters N/A (Class) ### Request Example ```python from marionette_driver.addons import Addons addons = Addons(marionette) addons.install("/path/to/extension.xpi") ``` ### Response N/A (Class) --- ## POST /addons/install ### Description Install a Firefox addon, which can be used right away. ### Method POST ### Endpoint `/addons/install` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **path** (string) - Optional - A file path to the extension to be installed. - **temp** (boolean) - Optional - Install a temporary addon. Temporary addons will automatically be uninstalled on shutdown and do not need to be signed. - **data** (string) - Optional - A base64-encoded string of a zip-packed addon. ### Request Example ```json { "path": "/path/to/extension.xpi", "temp": false, "data": "UEsDBAoAAAAA..." } ``` ### Response #### Success Response (200) - **addon_id** (string) - The addon ID string of the newly installed addon. #### Response Example ```json { "addon_id": "my-addon@example.com" } ``` --- ## DELETE /addons/uninstall ### Description Uninstall a Firefox addon. If the addon is restartless, it will be uninstalled right away. Otherwise a restart using `restart()` will be needed. If the call to uninstall is resulting in a ScriptTimeoutException, an invalid ID is likely being passed in. ### Method DELETE ### Endpoint `/addons/uninstall` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **addon_id** (string) - Required - The addon ID string to uninstall. ### Request Example ```json { "addon_id": "my-addon@example.com" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the uninstall operation. #### Response Example ```json { "status": "success" } ``` ### Errors - **MarionetteException**: May be raised for various issues during the uninstall process. - **ScriptTimeoutException**: May indicate an invalid addon ID was passed. ``` -------------------------------- ### Get Session Capabilities Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Retrieves a JSON dictionary representing the capabilities of the current session. ```APIDOC ## GET /session/{session_id}/capabilities ### Description Retrieves a JSON dictionary representing the capabilities of the current session. ### Method GET ### Endpoint /session/{session_id}/capabilities ### Response #### Success Response (200) - **value** (object) - A JSON dictionary containing the session capabilities. #### Response Example ```json { "value": { "browserName": "firefox", "version": "100.0", "platform": "linux" } } ``` ``` -------------------------------- ### Get Current URL Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Returns the URL of the current top-level browsing context. Equivalent to document.location.href on desktop browsers. ```python marionette.get_url() ``` -------------------------------- ### Get Cookies Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Retrieves all cookies for the current domain. This is equivalent to calling `document.cookie` and parsing the result. ```APIDOC ## GET /cookie ### Description Retrieves all cookies for the current domain. This is equivalent to calling `document.cookie` and parsing the result. ### Method GET ### Endpoint /session/{sessionId}/cookie ### Parameters None ### Response #### Success Response (200) - **value** (array) - A list of cookie objects for the current domain. #### Response Example ```json { "value": [ { "name": "cookie1", "value": "value1" }, { "name": "cookie2", "value": "value2" } ] } ``` ``` -------------------------------- ### Get Profile Arguments from GeckoInstance in Marionette Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Property to access the arguments related to the browser profile for the GeckoInstance. These arguments are used during browser startup. ```python @property def profile_args(self): pass ``` -------------------------------- ### Get Page Source Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Retrieves a string representation of the DOM for the current page. ```python page_source = marionette._property_page_source ``` -------------------------------- ### switch_to_alert Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Returns an `Alert` object for interacting with a currently displayed alert. Allows accepting, dismissing, or getting text from alerts. ```APIDOC ## SWITCH_TO_ALERT ### Description Returns an `Alert` object for interacting with a currently displayed alert. ### Method POST ### Endpoint /session/{sessionid}/alert ### Parameters #### Path Parameters - **sessionid** (string) - Required - The ID of the current WebDriver session. #### Query Parameters None #### Request Body None ### Request Example ``` # No request body needed ``` ### Response #### Success Response (200) - **value** (object) - An `Alert` object. - **text** (string) - The text content of the alert. #### Response Example ```json { "status": 200, "value": { "text": "This is an alert message." } } ``` ``` -------------------------------- ### Get All Cookies Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Retrieves all cookies associated with the current domain. This function is equivalent to parsing the `document.cookie` string. ```python all_cookies = marionette.get_cookies() ``` -------------------------------- ### Get Preference Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Retrieves the value of a specified preference. Allows specifying the preference branch and expected value type. ```APIDOC ## GET /prefs/{pref} ### Description Retrieves the value of a specified preference. Allows specifying the preference branch and expected value type. ### Method GET ### Endpoint /session/{sessionId}/prefs/{pref} ### Parameters #### Path Parameters - **pref** (string) - Required - The name of the preference to retrieve. #### Query Parameters - **default_branch** (boolean) - Optional - If true, the preference value will be read from the default branch. Otherwise, the user-defined value if set is returned. Defaults to false. - **value_type** (string) - Optional - The expected type of the preference value (e.g., 'string', 'integer', 'boolean'). Defaults to 'unspecified'. ### Response #### Success Response (200) - **value** (any) - The value of the specified preference. #### Response Example ```json { "value": "some_preference_value" } ``` ``` -------------------------------- ### Get Profile from GeckoInstance in Marionette Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Property to retrieve the profile directory used by the GeckoInstance. This allows access to browser profile data and settings. ```python @property def profile(self): pass ``` -------------------------------- ### WebElement Class Methods (Python) Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Represents a DOM Element and provides methods for interacting with it. Includes actions like clearing input, clicking, finding elements, getting attributes and properties, checking display/enabled/selected states, and sending keys. ```python class marionette_driver.marionette.WebElement(_marionette_ , _id_ , _kind ='element-6066-11e4-a52e-4f735466cecf'_) : """Represents a DOM Element.""" def clear(): """Clears the input of the element.""" pass def click(): """Simulates a click on the element.""" pass def find_element(_method_ , _target_): """Returns an `WebElement` instance that matches the specified method and target, relative to the current element.""" pass def find_elements(_method_ , _target_): """Returns a list of all `WebElement` instances that match the specified method and target in the current context.""" pass def get_attribute(_name_): """Returns the requested attribute, or None if no attribute is set.""" pass def get_property(_name_): """Returns the requested property, or None if the property is not set.""" pass def is_displayed(): """Returns True if the element is displayed, False otherwise.""" pass def is_enabled(): """This command will return False if all the following criteria are met otherwise return True: * A form control is disabled. * A `WebElement` has a disabled boolean attribute. """ pass def is_selected(): """Returns True if the element is selected.""" pass def send_keys(_* strings_): """Sends the string via synthesized keypresses to the element.""" pass def value_of_css_property(_property_name_): """Gets the value of the specified CSS property name.""" pass ``` -------------------------------- ### start_session Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Creates a new WebDriver session. This must be called before any other actions. It accepts Marionette-specific capabilities. ```APIDOC ## START_SESSION ### Description Creates a new WebDriver session. This method must be called before performing any other action. ### Method POST ### Endpoint /session ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **capabilities** (object) - Optional - A dictionary of Marionette-specific capabilities. Does not accept WebDriver conforming capabilities. - **process_forked** (boolean) - Optional - If True, indicates the existing process forked itself due to an internal restart. Defaults to False. - **timeout** (integer) - Optional - Timeout in seconds for the server to be ready. ### Request Example ```json { "capabilities": { "marionette_specific_capability": true }, "process_forked": false, "timeout": 60 } ``` ### Response #### Success Response (200) - **value** (object) - A dictionary of the capabilities offered by the Marionette session. #### Response Example ```json { "status": 200, "value": { "browserName": "firefox", "marionette_session_id": "some-session-id" } } ``` ``` -------------------------------- ### Execute JavaScript with Arguments Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Demonstrates how to execute JavaScript code using marionette.execute_script, including passing arguments to the script and accessing them via 'arguments'. It also shows how to retrieve element IDs by passing WebElement objects as arguments. ```python result = marionette.execute_script("return 1;") assert result == 1 result = marionette.execute_script("return arguments[0] + arguments[1];", script_args=(2, 3,)) # Passing arguments assert result == 5 some_element = marionette.find_element(By.ID, "someElement") sid = marionette.execute_script("return arguments[0].id;", script_args=(some_element,)) # Passing WebElement assert some_element.get_attribute("id") == sid ``` -------------------------------- ### switch_to_window Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Switches the active execution context to a specified window. Subsequent commands will be directed at the new window. ```APIDOC ## SWITCH_TO_WINDOW ### Description Switches to the specified window; subsequent commands will be directed at the new window. ### Method POST ### Endpoint /session/{sessionid}/window ### Parameters #### Path Parameters - **sessionid** (string) - Required - The ID of the current WebDriver session. #### Query Parameters None #### Request Body - **handle** (string) - Required - The ID of the window to switch to. - **focus** (boolean) - Optional - Determines whether to focus the window that was just switched to. Defaults to True. ### Request Example ```json { "handle": "window-handle-id", "focus": true } ``` ### Response #### Success Response (200) - **value** (null) - Indicates success. #### Response Example ```json { "status": 200, "value": null } ``` ``` -------------------------------- ### Preferences and Configuration Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index APIs for managing browser preferences and configuration. ```APIDOC ## POST /prefs/clear ### Description Clears a user-defined preference value. ### Method POST ### Endpoint /prefs/clear ### Parameters #### Request Body - **pref** (string) - Required - The name of the preference to clear. ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "success" } ``` ## POST /prefs/enforce ### Description Checks if the running instance has the given preferences. If not, it kills the current instance and spawns a new one with the requested preferences. ### Method POST ### Endpoint /prefs/enforce ### Parameters #### Request Body - **prefs** (object) - Required - A dictionary where keys are preference names. ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### navigate Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Navigates the current browsing context to a specified URL and waits for the document to load. ```APIDOC ## POST /session/{sessionId}/url ### Description Navigate to given url. Navigates the current top-level browsing context’s content frame to the given URL and waits for the document to load or the session’s page timeout duration to elapse before returning. The command will return with a failure if there is an error loading the document or the URL is blocked. This can occur if it fails to reach the host, the URL is malformed, the page is restricted (about:* pages), or if there is a certificate issue to name some examples. The document is considered successfully loaded when the DOMContentLoaded event on the frame element associated with the window triggers and document.readyState is “complete”. In chrome context it will change the current window’s location to the supplied URL and wait until document.readyState equals “complete” or the page timeout duration has elapsed. ### Method POST ### Endpoint /session/{sessionId}/url ### Parameters #### Query Parameters - **None** #### Request Body - **url** (string) - Required - The URL to navigate to. ### Request Example ```json { "url": "https://www.example.com" } ``` ### Response #### Success Response (200) - **value** (null) - Indicates success. #### Response Example ```json { "value": null } ``` ``` -------------------------------- ### Get Active Element Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Retrieves the currently active element in the browser's DOM. ```APIDOC ## GET /element/active ### Description Retrieves the currently active element in the browser's DOM. ### Method GET ### Endpoint /session/{sessionId}/element/active ### Parameters None ### Response #### Success Response (200) - **value** (object) - A WebElement locator object for the active element. #### Response Example ```json { "value": { "ELEMENT": "active-element-id" } } ``` ``` -------------------------------- ### open Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Opens a new browser window or tab with specified options. ```APIDOC ## POST /session/{sessionId}/window ### Description Open a new window, or tab based on the specified context type. If no context type is given the application will choose the best option based on tab and window support. ### Method POST ### Endpoint /session/{sessionId}/window ### Parameters #### Query Parameters - **None** #### Request Body - **type** (string) - Optional - Type of window to be opened. Can be one of “tab” or “window” - **focus** (boolean) - Optional - If true, the opened window will be focused - **private** (boolean) - Optional - If true, open a private window ### Request Example ```json { "type": "tab", "focus": true, "private": false } ``` ### Response #### Success Response (200) - **value** (object) - Dict with new window handle, and type of opened window. Example: `{"handle": "window-1", "type": "tab"}` #### Response Example ```json { "value": { "handle": "window-1", "type": "tab" } } ``` ``` -------------------------------- ### Get Active Element Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Retrieves the currently active element in the DOM. This is the element that currently has focus. ```python active_element = marionette.get_active_element() ``` -------------------------------- ### Create and Perform Action Sequences - Python Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index The ActionSequence class allows for the creation and execution of chained user input actions like key presses and pointer movements. Actions are queued and then performed in order when the perform() method is called. This class is fundamental for simulating user interactions within the browser. ```python ActionSequence(self.marionette, "key", id) \ .key_down("a") \ .key_up("a") \ .perform() ``` -------------------------------- ### Get Browser Orientation Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Retrieves the current orientation of the browser window. Returns one of the primary orientation values. ```python orientation = marionette._property_orientation ``` -------------------------------- ### DesktopInstance Preferences for Marionette Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Defines default preferences for the DesktopInstance of Gecko, used to configure browser behavior. These preferences are applied when initializing a DesktopInstance. ```python desktop_prefs = { 'app.update.auto': False, 'app.update.checkInstallTime': False, 'app.update.disabledForTesting': True, 'browser.EULA.override': True, 'browser.backup.enabled': False, 'browser.contentblocking.introCount': 99, 'browser.dom.window.dump.enabled': True, 'browser.download.panel.shown': True, 'browser.ml.enable': False, 'browser.newtabpage.activity-stream.testing.shouldInitializeFeeds': False, 'browser.pagethumbnails.capturing_disabled': True, 'browser.safebrowsing.update.enabled': False, 'browser.search.update': False, 'browser.sessionstore.resume_from_crash': False, 'browser.shell.checkDefaultBrowser': False, 'browser.startup.couldRestoreSession.count': -1, 'browser.startup.homepage_override.mstone': 'ignore', 'browser.startup.page': 0, 'browser.tabs.remote.unloadDelayMs': 0, 'browser.tabs.unloadOnLowMemory': False, 'browser.tabs.warnOnClose': False, 'browser.tabs.warnOnCloseOtherTabs': False, 'browser.tabs.warnOnOpen': False, 'browser.toolbars.bookmarks.visibility': 'never', 'browser.uitour.enabled': False, 'browser.urlbar.merino.endpointURL': '', 'browser.urlbar.suggest.searches': False, 'browser.warnOnQuit': False, 'devtools.console.stdout.chrome': True, 'dom.ipc.processPriorityManager.enabled': False, 'places.semanticHistory.featureGate': False, 'startup.homepage_welcome_url': 'about:blank', 'startup.homepage_welcome_url.additional': '', 'threads.lower_mainthread_priority_in_background.enabled': False } ``` -------------------------------- ### Navigate to URL Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Navigates the current browsing context to a specified URL and waits for the document to load. Returns failure on errors or blocked URLs. ```python marionette.navigate("https://www.example.com") ``` -------------------------------- ### window_handles Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Retrieves a list of window handles for all open windows in the current context. The order of handles is not guaranteed. ```APIDOC ## GET_WINDOW_HANDLES ### Description Get list of windows in the current context. If called in the content context it will return a list of references to all available browser windows. ### Method GET ### Endpoint /session/{sessionid}/windows ### Parameters #### Path Parameters - **sessionid** (string) - Required - The ID of the current WebDriver session. #### Query Parameters None #### Request Body None ### Request Example ``` # No request body needed ``` ### Response #### Success Response (200) - **value** (array) - An unordered list of unique window handles as strings. #### Response Example ```json { "status": 200, "value": [ "window-handle-1", "window-handle-2" ] } ``` ``` -------------------------------- ### Get Cookie Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Retrieves a single cookie by its name. Returns the cookie object if found, otherwise returns null. ```APIDOC ## GET /cookie/{name} ### Description Retrieves a single cookie by its name. Returns the cookie object if found, otherwise returns null. ### Method GET ### Endpoint /session/{sessionId}/cookie/{name} ### Parameters #### Path Parameters - **name** (string) - Required - The name of the cookie to retrieve. ### Response #### Success Response (200) - **value** (object or null) - The cookie object if found, otherwise null. #### Response Example ```json { "value": { "name": "session_id", "value": "some_value", "path": "/", "domain": "example.com", "secure": false, "httpOnly": false, "expiry": 1678886400 } } ``` ``` -------------------------------- ### WebWindow Class Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Documentation for the WebWindow class, used for handling top-level windows. ```APIDOC ## WebWindow Class ### Description A Class to handle top-level windows. ### Class Definition `marionette_driver.marionette.WebWindow(_marionette_, _id_, _kind='window-fcc6-11e5-b4f8-330a88ab9d7f'_)` ### Properties #### `identifiers` ##### Description Tuple of identifiers for the window. ##### Value `('window-fcc6-11e5-b4f8-330a88ab9d7f',)` ``` -------------------------------- ### Localize Property String with L10n in Marionette Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Demonstrates how to use the L10n class from marionette_driver.localization to retrieve localized strings. It requires a Marionette instance and takes a list of property URLs and a property ID as input. ```python from marionette_driver.localization import L10n l10n = L10n(marionette) l10n.localize_property(["chrome://global/locale/findbar.properties"], "FastFind") ``` -------------------------------- ### Get Browser Preference Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Retrieves the value of a browser preference. Supports complex value types like nsIFile and nsIPrefLocalizedString. ```python marionette.get_pref("browser.tabs.warnOnClose") ``` -------------------------------- ### using_prefs Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Temporarily sets preferences for code executed within a `with` block and restores them upon exiting. Useful for modifying browser behavior during specific operations. ```APIDOC ## USING_PREFS ### Description Set preferences for code executed in a with block, and restores them on exit. ### Method POST ### Endpoint /session/{sessionid}/prefs ### Parameters #### Path Parameters - **sessionid** (string) - Required - The ID of the current WebDriver session. #### Query Parameters None #### Request Body - **prefs** (object) - Required - A dictionary containing one or more preferences and their values to be set. - **default_branch** (boolean) - Optional - If True, the preference value will be written to the default branch and remain until the application restarts. Otherwise, a user-defined value is set. Defaults to False. ### Request Example ```python with marionette.using_prefs({"browser.tabs.warnOnClose": True}): # code that uses the preference pass ``` ```json { "prefs": { "browser.tabs.warnOnClose": true }, "default_branch": false } ``` ### Response #### Success Response (200) - **value** (null) - Indicates success. #### Response Example ```json { "status": 200, "value": null } ``` ``` -------------------------------- ### get_window_type Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Gets the window type attribute of the window Marionette is currently acting on. Useful for distinguishing window types in a chrome context. ```APIDOC ## GET /session/{sessionId}/window/type ### Description Gets the windowtype attribute of the window Marionette is currently acting on. This command only makes sense in a chrome context. You might use this method to distinguish a browser window from an editor window. ### Method GET ### Endpoint /session/{sessionId}/window/type ### Parameters #### Query Parameters - **None** ### Request Example ```json {} ``` ### Response #### Success Response (200) - **value** (string) - The type of the current window (e.g., "content", "chrome"). #### Response Example ```json { "value": "content" } ``` ``` -------------------------------- ### Get Single Cookie by Name Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Retrieves a specific cookie by its name. Returns the cookie object if found, otherwise returns None. ```python cookie = marionette.get_cookie("session_id") ``` -------------------------------- ### switch_to_default_content Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Switches the current execution context back to the main document (the default content). ```APIDOC ## SWITCH_TO_DEFAULT_CONTENT ### Description Switches the current context to the page's default content. ### Method POST ### Endpoint /session/{sessionid}/frame/parent ### Parameters #### Path Parameters - **sessionid** (string) - Required - The ID of the current WebDriver session. #### Query Parameters None #### Request Body None ### Request Example ``` # No request body needed ``` ### Response #### Success Response (200) - **value** (null) - Indicates success. #### Response Example ```json { "status": 200, "value": null } ``` ``` -------------------------------- ### Get Window Type Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Retrieves the window type attribute of the current window. Primarily useful in chrome contexts to differentiate window types. ```python marionette.get_window_type() ``` -------------------------------- ### using_context Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Sets the context for Marionette commands using a `with` statement. The context state is saved upon entering and restored upon exiting. ```APIDOC ## USING_CONTEXT ### Description Sets the context that Marionette commands are running in using a with statement. The state of the context on the server is saved before entering the block, and restored upon exiting it. ### Method POST ### Endpoint /session/{sessionid}/context ### Parameters #### Path Parameters - **sessionid** (string) - Required - The ID of the current WebDriver session. #### Query Parameters None #### Request Body - **context** (string) - Required - The context to switch to. May be one of the class properties `CONTEXT_CHROME` or `CONTEXT_CONTENT`. ### Request Example ```python with marionette.using_context(marionette.CONTEXT_CHROME): # chrome scope commands pass ``` ### Response #### Success Response (200) - **value** (null) - Indicates success. #### Response Example ```json { "status": 200, "value": null } ``` ``` -------------------------------- ### GeckoInstance Management API Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index This section details the core methods for managing the Gecko process within the Marionette Driver. ```APIDOC ## POST /restart ### Description Restarts the managed Gecko process. This method allows for setting specific preferences or resetting the profile before starting. ### Method POST ### Endpoint /restart ### Parameters #### Query Parameters - **prefs** (dict) - Optional - Dictionary of preference names and values to apply before restarting. - **clean** (boolean) - Optional - If True, resets the profile before starting. Defaults to True. ### Request Example ```json { "prefs": { "browser.startup.homepage": "about:blank" }, "clean": false } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "Gecko process restarted successfully." } ``` --- ## POST /start ### Description Starts the managed Gecko process. ### Method POST ### Endpoint /start ### Parameters *No parameters required for this endpoint.* ### Request Example ```json {} ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "Gecko process started successfully." } ``` --- ## POST /switch_profile ### Description Switches the active profile for the Gecko instance. This method allows for specifying a profile name or cloning an existing one. ### Method POST ### Endpoint /switch_profile ### Parameters #### Query Parameters - **profile_name** (string) - Optional - The name of the profile to switch to. This name will be used as part of the profile path. - **clone_from** (string) - Optional - The name or path of an existing profile to clone. If specified, a new profile will be created based on this one. ### Request Example ```json { "profile_name": "my_test_profile", "clone_from": "default" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "Profile switched successfully." } ``` --- ## POST /update_process ### Description Updates the process to track when the application re-launches itself. This is useful for scenarios where the Gecko process might restart independently. ### Method POST ### Endpoint /update_process ### Parameters #### Query Parameters - **pid** (integer) - Required - The process ID (PID) of the Gecko application. - **timeout** (integer) - Optional - The timeout in seconds for tracking the process update. ### Request Example ```json { "pid": 12345, "timeout": 60 } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "Process update tracking initiated." } ``` ``` -------------------------------- ### Get GeckoLog from GeckoInstance in Marionette Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Property to access the Gecko log object associated with the GeckoInstance. This is useful for debugging and monitoring the browser process. ```python @property def gecko_log(self): pass ``` -------------------------------- ### Browser Information and State Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index APIs for checking browser state, retrieving window handles, and managing sessions. ```APIDOC ## GET /check_for_crash ### Description Checks if the browser process has crashed since the last check. ### Method GET ### Endpoint /check_for_crash ### Parameters None ### Response #### Success Response (200) - **crashed** (boolean) - True if a crash occurred, False otherwise. #### Response Example ```json { "crashed": true } ``` ## GET /windows ### Description Retrieves a list of currently open browser windows (handles). ### Method GET ### Endpoint /windows ### Parameters None ### Response #### Success Response (200) - **window_handles** (array of strings) - An unordered list of unique window handles. #### Response Example ```json { "window_handles": ["handle1", "handle2"] } ``` ## GET /window/current ### Description Retrieves the handle of the currently active browser window. ### Method GET ### Endpoint /window/current ### Parameters None ### Response #### Success Response (200) - **current_window_handle** (string) - The unique identifier for the current window. #### Response Example ```json { "current_window_handle": "handle1" } ``` ## POST /session/delete ### Description Closes the current browser session and disconnects from the Marionette server. Optionally sends a request to the server to close the session. ### Method POST ### Endpoint /session/delete ### Parameters #### Query Parameters - **send_request** (boolean) - Optional. If True, sends a request to close the session on the server. Defaults to True. ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### page_source Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Retrieves a string representation of the DOM. ```APIDOC ## GET /session/{sessionId}/source ### Description A string representation of the DOM. ### Method GET ### Endpoint /session/{sessionId}/source ### Parameters #### Query Parameters - **None** ### Request Example ```json {} ``` ### Response #### Success Response (200) - **value** (string) - The DOM source code as a string. #### Response Example ```json { "value": "......" } ``` ``` -------------------------------- ### Get FennecInstance Package Name in Marionette Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Property to retrieve the package name of the application running on the emulator for a FennecInstance. Note that FennecInstance does not use the 'binary' attribute. ```python @property def package_name(self): """ Name of app to run on emulator. Note that FennecInstance does not use self.binary """ pass ``` -------------------------------- ### Keys Module Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Provides constants for special keyboard keys used in simulating user input. ```APIDOC ## marionette_driver.keys module ### Description Provides constants for special keyboard keys used in simulating user input. ### Constants - **ADD**: Represents the '+' key. - **ALT**: Represents the 'Alt' key. - **ARROW_DOWN**: Represents the down arrow key. - **ARROW_LEFT**: Represents the left arrow key. - **ARROW_RIGHT**: Represents the right arrow key. - **ARROW_UP**: Represents the up arrow key. - **BACK_SPACE**: Represents the Backspace key. - **CANCEL**: Represents the Cancel key. - **CLEAR**: Represents the Clear key. - **COMMAND**: Represents the Command key (macOS). - **CONTROL**: Represents the Control key. - **DECIMAL**: Represents the decimal point key on the numeric keypad. - **DELETE**: Represents the Delete key. - **DIVIDE**: Represents the '/' key on the numeric keypad. - **DOWN**: Alias for ARROW_DOWN. - **END**: Represents the End key. - **ENTER**: Represents the Enter key. - **EQUALS**: Represents the '=' key. - **ESCAPE**: Represents the Escape key. - **F1** to **F12**: Represents the function keys F1 through F12. - **HELP**: Represents the Help key. - **HOME**: Represents the Home key. - **INSERT**: Represents the Insert key. - **LEFT**: Alias for ARROW_LEFT. - **LEFT_ALT**: Alias for ALT. - **LEFT_CONTROL**: Alias for CONTROL. - **LEFT_SHIFT**: Alias for SHIFT. - **META**: Represents the Meta key (Windows key on Windows, Command key on macOS). - **MULTIPLY**: Represents the '*' key on the numeric keypad. - **NULL**: Represents the Null key. - **NUMPAD0** to **NUMPAD9**: Represents the numeric keys 0 through 9 on the numeric keypad. - **PAGE_DOWN**: Represents the Page Down key. - **PAGE_UP**: Represents the Page Up key. - **PAUSE**: Represents the Pause/Break key. - **RETURN**: Alias for ENTER. - **RIGHT**: Alias for ARROW_RIGHT. - **SEMICOLON**: Represents the ';' key. - **SEPARATOR**: Represents the separator key on the numeric keypad. - **SHIFT**: Represents the Shift key. - **SPACE**: Represents the Spacebar key. - **SUBTRACT**: Represents the '-' key on the numeric keypad. - **TAB**: Represents the Tab key. - **UP**: Alias for ARROW_UP. ``` -------------------------------- ### Get Preference Value Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Retrieves the value of a specified preference. Optionally, it can read from the default branch of preferences. The 'value_type' parameter can be used to specify the expected type of the preference. ```python pref_value = marionette.get_pref("browser.download.dir") default_pref_value = marionette.get_pref("network.proxy.type", default_branch=True) ``` -------------------------------- ### Fullscreen Window Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Synchronously sets the user agent window to full screen, similar to the user selecting 'View > Enter Full Screen', or restores it if it is already in full screen. ```APIDOC ## POST /window/fullscreen ### Description Synchronously sets the user agent window to full screen, similar to the user selecting 'View > Enter Full Screen', or restores it if it is already in full screen. ### Method POST ### Endpoint /session/{sessionId}/window/fullscreen ### Parameters None ### Response #### Success Response (200) - **value** (object) - The window rectangle after the operation. #### Response Example ```json { "value": { "x": 0, "y": 0, "width": 1920, "height": 1080 } } ``` ``` -------------------------------- ### Enforce Gecko Preferences in Marionette Driver Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index The `enforce_gecko_prefs` method checks if the running Marionette instance has the specified preferences. If not, it terminates the current instance and starts a new one with the provided preferences. ```python enforce_gecko_prefs(_prefs_) ``` -------------------------------- ### Get Current Window Handle in Marionette Driver Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index The `_current_window_handle` property returns the handle of the currently active browser window. This handle is a server-assigned identifier that can be used to switch to this window later. This is an internal property. ```python _property _current_window_handle ``` -------------------------------- ### WebFrame Class Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Documentation for the WebFrame class, used for handling frame windows. ```APIDOC ## WebFrame Class ### Description A Class to handle frame windows. ### Class Definition `marionette_driver.marionette.WebFrame(_marionette_, _id_, _kind='frame-075b-4da1-b6ba-e579c2d3230a'_)` ### Properties #### `identifiers` ##### Description Tuple of identifiers for the frame. ##### Value `('frame-075b-4da1-b6ba-e579c2d3230a',)` ``` -------------------------------- ### Set Multiple Preferences Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Sets the values for a list of browser preferences. ```APIDOC ## POST /session/{session_id}/moz/preferences ### Description Sets the values for a list of browser preferences. ### Method POST ### Endpoint /session/{session_id}/moz/preferences ### Parameters #### Request Body - **prefs** (object) - Required - An object where keys are preference names and values are their desired settings. - **default_branch** (boolean) - Optional - If True, the preference values will be written to the default branch and remain until the application restarts. Defaults to False. ### Response #### Success Response (200) - **value** (string) - A confirmation message indicating the preferences were set. #### Response Example ```json { "value": "Preferences updated successfully" } ``` ``` -------------------------------- ### Get Chrome Window Handles in Marionette Driver Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index The `_chrome_window_handles` property retrieves a list of all currently open Chrome window handles. These handles are server-assigned and the returned list has no guaranteed order. This is an internal property. ```python _property _chrome_window_handles ``` -------------------------------- ### Get Current Chrome Window Handle in Marionette Driver Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index The `_current_chrome_window_handle` property returns the handle of the currently active Chrome window. This handle is a server-assigned identifier that can be used to switch to this window later. This is an internal property. ```python _property _current_chrome_window_handle ``` -------------------------------- ### WebElement Class Methods Source: https://firefox-source-docs.mozilla.org/python/marionette_driver.html/index Documentation for methods available on WebElement objects, used for interacting with DOM elements. ```APIDOC ## WebElement Class Methods ### Description This section details the methods available for interacting with WebElement objects, which represent DOM elements. ### Methods #### `clear()` ##### Description Clears the input of the element. ##### Method `clear()` #### `click()` ##### Description Simulates a click on the element. ##### Method `click()` #### `find_element(_method_, _target_)` ##### Description Returns an `WebElement` instance that matches the specified method and target, relative to the current element. ##### Method `find_element(_method_, _target_)` #### `find_elements(_method_, _target_)` ##### Description Returns a list of all `WebElement` instances that match the specified method and target in the current context. ##### Method `find_elements(_method_, _target_)` #### `get_attribute(_name_)` ##### Description Returns the requested attribute, or None if no attribute is set. ##### Method `get_attribute(_name_) ##### Parameters * **name** (string) - Required - The name of the attribute to retrieve. #### `get_property(_name_)` ##### Description Returns the requested property, or None if the property is not set. ##### Method `get_property(_name_) ##### Parameters * **name** (string) - Required - The name of the property to retrieve. #### `is_displayed()` ##### Description Returns True if the element is displayed, False otherwise. ##### Method `is_displayed()` #### `is_enabled()` ##### Description This command will return False if all the following criteria are met otherwise return True: * A form control is disabled. * A `WebElement` has a disabled boolean attribute. ##### Method `is_enabled()` #### `is_selected()` ##### Description Returns True if the element is selected. ##### Method `is_selected()` #### `send_keys(_* strings_)` ##### Description Sends the string via synthesized keypresses to the element. If an array is passed in like marionette.send_keys(Keys.SHIFT, “a”) it will be joined into a string. If an integer is passed in like marionette.send_keys(1234) it will be coerced into a string. ##### Method `send_keys(_* strings_) ##### Parameters * **strings** (string) - Required - The keys to send to the element. #### `value_of_css_property(_property_name_)` ##### Description Gets the value of the specified CSS property name. ##### Method `value_of_css_property(_property_name_) ##### Parameters * **property_name** (string) - Required - Property name to get the value of. ### Properties #### `computed_label` ##### Description Gets the computed accessibility label of the current element. #### `computed_role` ##### Description Gets the computed accessibility role of the current element. #### `rect` ##### Description Gets the element’s bounding rectangle. This will return a dictionary with the following: > * x and y represent the top left coordinates of the `WebElement` relative to top left corner of the document. > * height and the width will contain the height and the width of the DOMRect of the `WebElement`. > #### `shadow_root` ##### Description Gets the shadow root of the current element. #### `tag_name` ##### Description The tag name of the element. #### `text` ##### Description Returns the visible text of the element, and its child elements. ```