Chromium Module Reference
New in version 0.0.3.
Control Chromium using JXA-like syntax.
Classes:
|
A class for managing and interacting with Chromium.app. |
|
A class for managing and interacting with bookmark folders in Chromium.app. |
|
A wrapper around a list of bookmark folders. |
|
A class for managing and interacting with bookmarks in Chromium.app. |
|
A wrapper around a list of bookmark items. |
|
A class for managing and interacting with Chromium tabs. |
|
A wrapper around a list of tabs. |
|
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:
The bookmarks bar bookmark folder.
Whether Chromium is the active application.
The name of the application.
The other bookmarks bookmark folder.
The version of Chromium.app.
- class ObjectType(value)[source]
Bases:
Enum
The object types that can be created using
make()
.Attributes:
- 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:
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:
See also
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:
See also
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:
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:
- 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.
Gets a clipboard-codable representation of the bookmark folder.
Attributes:
The unique identifier for the bookmark folder.
The index of the bookmark folder with respect to its parent folder.
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:
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:
New in version 0.0.3.
- 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.
See also
New in version 0.0.3.
Methods:
by_id
(id)by_index
(index)by_title
(title)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.
- 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.
Gets a clipboard-codable representation of the bookmark item.
Attributes:
The unique identifier for the bookmark item.
The index of the item with respect to its parent folder.
The title of the bookmark item.
The URL of the bookmark.
- 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.
- class PyXA.apps.Chromium.XAChromiumBookmarkItemList(properties: dict, filter: dict | None = None)[source]
Bases:
XAList
,XAClipboardCodable
A wrapper around a list of bookmark items.
See also
New in version 0.0.3.
Methods:
by_id
(id)by_index
(index)by_title
(title)by_url
(url)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.
- class PyXA.apps.Chromium.XAChromiumTab(properties)[source]
Bases:
XAObject
,XAClipboardCodable
A class for managing and interacting with Chromium tabs.
See also
New in version 0.0.3.
Methods:
close
()Closes the tab.
Copies the selected element to the clipboard.
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.
Gets a clipboard-codable representation of the tab.
go_back
()Goes to the previous URL in the tab's history.
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.
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])Selects all text content within the tab.
stop
()Forces the tab to stop loading.
undo
()Undoes the last action done on the tab.
Opens the source HTML of the tab's document in a separate tab.
Attributes:
The unique identifier for the tab.
Is the tab currently loading?
The title of the tab.
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:
- 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
New in version 0.0.1.
- 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:
- 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
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.
- 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
New in version 0.0.3.
Methods:
by_id
(id)by_loading
(loading)by_title
(title)by_url
(url)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.
- class PyXA.apps.Chromium.XAChromiumWindow(properties)[source]
Bases:
XASBWindow
A class for managing and interacting with Chromium windows.
See also
New in version 0.0.3.
Attributes:
The currently selected tab.
The index of the active tab.
The given name of the window.
Whether the window can be minimized.
Whether the window is currently minimized.
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:
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:
New in version 0.0.3.