Chromium Module Reference

New in version 0.0.3.

Control Chromium using JXA-like syntax.

Classes:

XAChromiumApplication(properties)

A class for managing and interacting with Chromium.app.

XAChromiumBookmarkFolder(properties)

A class for managing and interacting with bookmark folders in Chromium.app.

XAChromiumBookmarkFolderList(properties[, ...])

A wrapper around a list of bookmark folders.

XAChromiumBookmarkItem(properties)

A class for managing and interacting with bookmarks in Chromium.app.

XAChromiumBookmarkItemList(properties[, filter])

A wrapper around a list of bookmark items.

XAChromiumTab(properties)

A class for managing and interacting with Chromium tabs.

XAChromiumTabList(properties[, filter])

A wrapper around a list of tabs.

XAChromiumWindow(properties)

A class for managing and interacting with Chromium windows.

class PyXA.apps.Chromium.XAChromiumApplication(properties)[source]

Bases: XASBApplication, XACanOpenPath

A class for managing and interacting with Chromium.app.

New in version 0.0.3.

Classes:

ObjectType(value)

The object types that can be created using make().

Methods:

bookmark_folders([filter])

Returns a list of bookmark folders, as PyXA objects, matching the given filter.

make(specifier[, properties, data])

Creates a new element of the given specifier class without adding it to any list.

new_tab([url])

Opens a new tab at the specified URL.

new_window([url])

Opens a new window at the specified URL.

open([url])

Opens a URL in a new tab.

Attributes:

bookmarks_bar

The bookmarks bar bookmark folder.

frontmost

Whether Chromium is the active application.

name

The name of the application.

other_bookmarks

The other bookmarks bookmark folder.

version

The version of Chromium.app.

class ObjectType(value)[source]

Bases: Enum

The object types that can be created using make().

Attributes:

TAB

WINDOW

TAB = 'tab'
WINDOW = 'window'
bookmark_folders(filter: dict | None = None) XAChromiumBookmarkFolderList[source]

Returns a list of bookmark folders, as PyXA objects, matching the given filter.

Parameters:

filter (dict, optional) – Keys and values to filter folders by, defaults to None

Returns:

A PyXA list object wrapping a list of bookmark folders

Return type:

XAChromiumBookmarkFolderList

New in version 0.0.3.

property bookmarks_bar: XAChromiumBookmarkFolder

The bookmarks bar bookmark folder.

property frontmost: bool

Whether Chromium is the active application.

make(specifier: str | ObjectType, properties: dict | None = None, data: Any | None = None)[source]

Creates a new element of the given specifier class without adding it to any list.

Use XABase.XAList.push() to push the element onto a list.

Parameters:
  • specifier (Union[str, XAChromiumApplication.ObjectType]) – The classname of the object to create

  • properties (dict) – The properties to give the object

  • data (Any) – The data to give the object

Returns:

A PyXA wrapped form of the object

Return type:

XABase.XAObject

New in version 0.0.4.

property name: str

The name of the application.

new_tab(url: str | XAURL | None = None) XAChromiumTab[source]

Opens a new tab at the specified URL.

Parameters:

url (Union[str, XABase.XAURL, None], optional) – The URL to open in a new tab, or None to open the tab at the homepage, defaults to None

Returns:

The newly created tab object

Return type:

XAChromiumTab

See also

new_window(), make()

New in version 0.0.5.

new_window(url: str | XAURL | None = None) XAChromiumWindow[source]

Opens a new window at the specified URL.

Parameters:

url (Union[str, XABase.XAURL, None], optional) – The URL to open in a new window, or None to open the window at the homepage, defaults to None

Returns:

The newly created window object

Return type:

XAChromiumWindow

See also

new_tab(), make()

New in version 0.0.5.

open(url: str | XAURL = 'https://google.com') XAChromiumApplication[source]

Opens a URL in a new tab.

Parameters:

url (str, optional) – _description_, defaults to “http://google.com

Returns:

A reference to the Chromium application object.

Return type:

XAChromiumApplication

Example 1:

Open a local or external URL

>>> import PyXA
>>> app = PyXA.Application("Chromium")
>>> app.open("https://www.google.com")
>>> app.open("google.com")
>>> app.open("/Users/exampleuser/Documents/WebPage.html")

New in version 0.0.3.

property other_bookmarks: XAChromiumBookmarkFolder

The other bookmarks bookmark folder.

property version: str

The version of Chromium.app.

class PyXA.apps.Chromium.XAChromiumBookmarkFolder(properties)[source]

Bases: XAObject, XAClipboardCodable

A class for managing and interacting with bookmark folders in Chromium.app.

New in version 0.0.3.

Methods:

bookmark_folders([filter])

Returns a list of bookmark folders, as PyXA objects, matching the given filter.

bookmark_items([filter])

Returns a list of bookmark items, as PyXA objects, matching the given filter.

delete()

Permanently deletes the bookmark folder.

get_clipboard_representation()

Gets a clipboard-codable representation of the bookmark folder.

Attributes:

id

The unique identifier for the bookmark folder.

index

The index of the bookmark folder with respect to its parent folder.

title

The name of the bookmark folder.

bookmark_folders(filter: dict | None = None) XAChromiumBookmarkFolderList[source]

Returns a list of bookmark folders, as PyXA objects, matching the given filter.

Parameters:

filter (dict, optional) – Keys and values to filter folders by, defaults to None

Returns:

A PyXA list object wrapping a list of bookmark folders

Return type:

XAChromiumBookmarkFolderList

New in version 0.0.3.

bookmark_items(filter: dict | None = None) XAChromiumBookmarkItemList[source]

Returns a list of bookmark items, as PyXA objects, matching the given filter.

Parameters:

filter (dict, optional) – Keys and values to filter items by, defaults to None

Returns:

A PyXA list object wrapping a list of bookmark items

Return type:

XAChromiumBookmarkItemList

New in version 0.0.3.

delete()[source]

Permanently deletes the bookmark folder.

New in version 0.0.4.

get_clipboard_representation() str[source]

Gets a clipboard-codable representation of the bookmark folder.

When the clipboard content is set to a bookmark folder, the folders’s title is added to the clipboard.

Returns:

The bookmark folders’s title

Return type:

str

New in version 0.0.8.

property id: int

The unique identifier for the bookmark folder.

property index: int

The index of the bookmark folder with respect to its parent folder.

property title: str

The name of the bookmark folder.

class PyXA.apps.Chromium.XAChromiumBookmarkFolderList(properties: dict, filter: dict | None = None)[source]

Bases: XAList, XAClipboardCodable

A wrapper around a list of bookmark folders.

New in version 0.0.3.

Methods:

by_id(id)

by_index(index)

by_title(title)

get_clipboard_representation()

Gets a clipboard-codable representation of each bookmark folder in the list.

id()

index()

Returns the index of the first occurrence of the element in the list, or -1 if no such element exists in the list.

title()

by_id(id: int) XAChromiumBookmarkFolder | None[source]
by_index(index: int) XAChromiumBookmarkFolder | None[source]
by_title(title: str) XAChromiumBookmarkFolder | None[source]
get_clipboard_representation() list[str][source]

Gets a clipboard-codable representation of each bookmark folder in the list.

When the clipboard content is set to a list of bookmark folders, each folder’s title is added to the clipboard.

Returns:

The list of each bookmark folder’s title

Return type:

list[str]

New in version 0.0.8.

id() list[int][source]
index() list[int][source]

Returns the index of the first occurrence of the element in the list, or -1 if no such element exists in the list.

New in version 0.1.2.

title() list[str][source]
class PyXA.apps.Chromium.XAChromiumBookmarkItem(properties)[source]

Bases: XAObject, XAClipboardCodable

A class for managing and interacting with bookmarks in Chromium.app.

New in version 0.0.3.

Methods:

delete()

Permanently deletes the bookmark.

get_clipboard_representation()

Gets a clipboard-codable representation of the bookmark item.

Attributes:

id

The unique identifier for the bookmark item.

index

The index of the item with respect to its parent folder.

title

The title of the bookmark item.

url

The URL of the bookmark.

delete()[source]

Permanently deletes the bookmark.

New in version 0.0.4.

get_clipboard_representation() list[str | NSURL][source]

Gets a clipboard-codable representation of the bookmark item.

When the clipboard content is set to a bookmark item, the item’s title and URL are added to the clipboard.

Returns:

The bookmark items’s title and URL

Return type:

list[Union[str, AppKit.NSURL]]

New in version 0.0.8.

property id: int

The unique identifier for the bookmark item.

property index: int

The index of the item with respect to its parent folder.

property title: str

The title of the bookmark item.

property url: XAURL

The URL of the bookmark.

class PyXA.apps.Chromium.XAChromiumBookmarkItemList(properties: dict, filter: dict | None = None)[source]

Bases: XAList, XAClipboardCodable

A wrapper around a list of bookmark items.

New in version 0.0.3.

Methods:

by_id(id)

by_index(index)

by_title(title)

by_url(url)

get_clipboard_representation()

Gets a clipboard-codable representation of each bookmark item in the list.

id()

index()

Returns the index of the first occurrence of the element in the list, or -1 if no such element exists in the list.

title()

url()

by_id(id: int) XAChromiumBookmarkItem | None[source]
by_index(index: int) XAChromiumBookmarkItem | None[source]
by_title(title: str) XAChromiumBookmarkItem | None[source]
by_url(url: XAURL) XAChromiumBookmarkItem | None[source]
get_clipboard_representation() list[str | NSURL][source]

Gets a clipboard-codable representation of each bookmark item in the list.

When the clipboard content is set to a list of bookmark items, each item’s title and URL are added to the clipboard.

Returns:

The list of each bookmark items’s title and URL

Return type:

list[Union[str, AppKit.NSURL]]

New in version 0.0.8.

id() list[int][source]
index() list[int][source]

Returns the index of the first occurrence of the element in the list, or -1 if no such element exists in the list.

New in version 0.1.2.

title() list[str][source]
url() list[XAURL][source]
class PyXA.apps.Chromium.XAChromiumTab(properties)[source]

Bases: XAObject, XAClipboardCodable

A class for managing and interacting with Chromium tabs.

New in version 0.0.3.

Methods:

close()

Closes the tab.

copy_selection()

Copies the selected element to the clipboard.

cut_selection()

Attempts to cut the selected content and copy it to the clipboard.

duplicate_to(window)

Duplicates the tab in the specified window.

execute(script)

Executes JavaScript in the tab.

get_clipboard_representation()

Gets a clipboard-codable representation of the tab.

go_back()

Goes to the previous URL in the tab's history.

go_forward()

Goes to the next URL in the tab's history, or does nothing if the current document is the most recent URL.

move_to(window)

Moves the tab to the specified window.

paste_selection()

Attempts to paste the clipboard into the selected element.

print()

Opens the print dialog for the tab.

redo()

Redoes the last action done on the tab.

reload()

Reloads the tab.

save(file_path[, save_assets])

select_all()

Selects all text content within the tab.

stop()

Forces the tab to stop loading.

undo()

Undoes the last action done on the tab.

view_source()

Opens the source HTML of the tab's document in a separate tab.

Attributes:

id

The unique identifier for the tab.

loading

Is the tab currently loading?

title

The title of the tab.

url

The URL visible to the user.

close() XAChromiumTab[source]

Closes the tab.

New in version 0.0.4.

copy_selection() XAChromiumTab[source]

Copies the selected element to the clipboard.

New in version 0.0.4.

cut_selection() XAChromiumTab[source]

Attempts to cut the selected content and copy it to the clipboard. If the content cannot be deleted, then it is only copied to the clipboard.

New in version 0.0.4.

duplicate_to(window: XAChromiumWindow) XAChromiumWindow[source]

Duplicates the tab in the specified window. The tab will then exist in two locations.

Parameters:

window (XASafariWindow) – The window to duplicate the tab in.

Returns:

A reference to the tab object.

Return type:

XASafariTab

Example 1:

Duplicate the current tab in the second window

>>> import PyXA
>>> app = PyXA.Application("Chromium")
>>> tab = app.front_window.active_tab
>>> window2 = app.windows()[1]
>>> tab.duplicate_to(window2)

See also

move_to()

New in version 0.0.1.

execute(script: str) Any[source]

Executes JavaScript in the tab.

New in version 0.0.4.

get_clipboard_representation() list[str | NSURL][source]

Gets a clipboard-codable representation of the tab.

When the clipboard content is set to a Chromium tab, the tab’s title and URL are added to the clipboard.

Returns:

The tab’s title and URL

Return type:

list[Union[str, AppKit.NSURL]]

New in version 0.0.8.

go_back() XAChromiumTab[source]

Goes to the previous URL in the tab’s history.

New in version 0.0.4.

go_forward() XAChromiumTab[source]

Goes to the next URL in the tab’s history, or does nothing if the current document is the most recent URL.

New in version 0.0.4.

property id: int

The unique identifier for the tab.

property loading: bool

Is the tab currently loading?

move_to(window: XAChromiumWindow) XAChromiumWindow[source]

Moves the tab to the specified window. After, the tab will exist in only one location.

Parameters:

window (XASafariWindow) – The window to move the tab to.

Returns:

A reference to the tab object.

Return type:

XASafariGeneric

Example 1:

Move the current tab to the second window

>>> import PyXA
>>> app = PyXA.Application("Chromium")
>>> tab = app.front_window.active_tab
>>> window2 = app.windows()[1]
>>> tab.move_to(window2)

See also

duplicate_to()

New in version 0.0.1.

paste_selection() XAChromiumTab[source]

Attempts to paste the clipboard into the selected element.

New in version 0.0.4.

print() XAChromiumTab[source]

Opens the print dialog for the tab.

New in version 0.0.4.

redo() XAChromiumTab[source]

Redoes the last action done on the tab.

New in version 0.0.4.

reload() XAChromiumTab[source]

Reloads the tab.

New in version 0.0.4.

save(file_path: str | NSURL, save_assets: bool = True) XAChromiumTab[source]
select_all() XAChromiumTab[source]

Selects all text content within the tab.

New in version 0.0.4.

stop() XAChromiumTab[source]

Forces the tab to stop loading.

New in version 0.0.4.

property title: str

The title of the tab.

undo() XAChromiumTab[source]

Undoes the last action done on the tab.

New in version 0.0.4.

property url: XAURL

The URL visible to the user.

view_source() XAChromiumTab[source]

Opens the source HTML of the tab’s document in a separate tab.

New in version 0.0.4.

class PyXA.apps.Chromium.XAChromiumTabList(properties: dict, filter: dict | None = None)[source]

Bases: XAList, XAClipboardCodable

A wrapper around a list of tabs.

See also

XAChromiumTab

New in version 0.0.3.

Methods:

by_id(id)

by_loading(loading)

by_title(title)

by_url(url)

get_clipboard_representation()

Gets a clipboard-codable representation of each tab in the list.

id()

loading()

title()

url()

by_id(id: int) XAChromiumTab | None[source]
by_loading(loading: bool) XAChromiumTab | None[source]
by_title(title: str) XAChromiumTab | None[source]
by_url(url: XAURL) XAChromiumTab | None[source]
get_clipboard_representation() list[str | NSURL][source]

Gets a clipboard-codable representation of each tab in the list.

When the clipboard content is set to a list of Chromium tabs, each tab’s URL is added to the clipboard.

Returns:

A list of tab URLs

Return type:

list[Union[str, AppKit.NSURL]]

New in version 0.0.8.

id() list[int][source]
loading() list[bool][source]
title() list[str][source]
url() list[XAURL][source]
class PyXA.apps.Chromium.XAChromiumWindow(properties)[source]

Bases: XASBWindow

A class for managing and interacting with Chromium windows.

New in version 0.0.3.

Attributes:

active_tab

The currently selected tab.

active_tab_index

The index of the active tab.

given_name

The given name of the window.

minimizable

Whether the window can be minimized.

minimized

Whether the window is currently minimized.

mode

The mode of the window, either 'normal' or 'incognito'.

Methods:

new_tab([url])

Opens a new tab at the specified URL.

tabs([filter])

Returns a list of tabs, as PyXA objects, matching the given filter.

property active_tab: XAChromiumTab

The currently selected tab.

property active_tab_index: int

The index of the active tab.

property given_name: str

The given name of the window.

property minimizable: bool

Whether the window can be minimized.

property minimized: bool

Whether the window is currently minimized.

property mode: str

The mode of the window, either ‘normal’ or ‘incognito’.

new_tab(url: str | XAURL | None = None) XAChromiumTab[source]

Opens a new tab at the specified URL.

Parameters:

url (Union[str, XABase.XAURL, None], optional) – The URL to open in a new tab, or None to open the tab at the homepage, defaults to None

Returns:

The newly created tab object

Return type:

XAChromiumTab

New in version 0.0.5.

tabs(filter: dict | None = None) XAChromiumTabList[source]

Returns a list of tabs, as PyXA objects, matching the given filter.

Parameters:

filter (dict, optional) – Keys and values to filter tabs by, defaults to None

Returns:

A PyXA list object wrapping a list of tabs

Return type:

XAChromiumTabList

New in version 0.0.3.