liteium package

liteium.back()[source]

Navigate backward in the browser history.

liteium.browser_version()[source]

Get the version of the browser being used.

Returns: str: The version of the browser.

liteium.class_name(value, time=0)[source]

Find a single element by class name.

Parameters: value (str): The class name of the element. time (int, optional): The amount of time to wait for the element to be present. Default is 0.

Returns: WebElement: The located element.

liteium.class_names(value, time=0)[source]

Find multiple elements by class name.

Parameters: value (str): The class name of the elements. time (int, optional): The amount of time to wait for the elements to be present. Default is 0.

Returns: list[WebElement]: The located elements.

liteium.close()[source]

Close the WebDriver session.

liteium.css_selector(value, time=0)[source]

Find a single element by CSS selector.

Parameters: value (str): The CSS selector of the element. time (int, optional): The amount of time to wait for the element to be present. Default is 0.

Returns: WebElement: The located element.

liteium.css_selectors(value, time=0)[source]

Find multiple elements by CSS selector.

Parameters: value (str): The CSS selector of the elements. time (int, optional): The amount of time to wait for the elements to be present. Default is 0.

Returns: list[WebElement]: The located elements.

liteium.delete_cookies()[source]

Delete all cookies in the browser.

liteium.driver(driver_path)[source]

Initialize the WebDriver with the given path.

Parameters: driver_path (str): Path to the WebDriver executable.

Returns: WebDriver: An instance of the WebDriver.

liteium.forward()[source]

Navigate forward in the browser history.

liteium.id(value, time=0)[source]

Find a single element by ID.

Parameters: value (str): The ID of the element. time (int, optional): The amount of time to wait for the element to be present. Default is 0.

Returns: WebElement: The located element.

liteium.ids(value, time=0)[source]

Find multiple elements by ID.

Parameters: value (str): The ID of the elements. time (int, optional): The amount of time to wait for the elements to be present. Default is 0.

Returns: list[WebElement]: The located elements.

liteium.js(script)[source]

Execute a JavaScript script in the browser.

Parameters: script (str): The JavaScript code to execute.

Find a single element by link text.

Parameters: value (str): The link text of the element. time (int, optional): The amount of time to wait for the element to be present. Default is 0.

Returns: WebElement: The located element.

Find multiple elements by link text.

Parameters: value (str): The link text of the elements. time (int, optional): The amount of time to wait for the elements to be present. Default is 0.

Returns: list[WebElement]: The located elements.

liteium.name(value, time=0)[source]

Find a single element by name attribute.

Parameters: value (str): The name attribute of the element. time (int, optional): The amount of time to wait for the element to be present. Default is 0.

Returns: WebElement: The located element.

liteium.names(value, time=0)[source]

Find multiple elements by name attribute.

Parameters: value (str): The name attribute of the elements. time (int, optional): The amount of time to wait for the elements to be present. Default is 0.

Returns: list[WebElement]: The located elements.

liteium.new_window(url='about:blank')[source]

Open a new browser window with the specified URL.

Parameters: url (str, optional): The URL to open in the new window. Default is “about:blank”.

liteium.open(url)[source]

Open the specified URL in the browser.

Parameters: url (str): The URL to open.

Find a single element by partial link text.

Parameters: value (str): The partial link text of the element. time (int, optional): The amount of time to wait for the element to be present. Default is 0.

Returns: WebElement: The located element.

Find multiple elements by partial link text.

Parameters: value (str): The partial link text of the elements. time (int, optional): The amount of time to wait for the elements to be present. Default is 0.

Returns: list[WebElement]: The located elements.

liteium.refresh()[source]

Refresh the current page.

liteium.save_cookies(filename=None)[source]

Save the browser’s cookies to a file.

Parameters: filename (str, optional): The name of the file to save the cookies. Default is based on the current URL’s hostname.

liteium.screenshot(filename=None)[source]

Take a screenshot and save it to the specified filename.

Parameters: filename (str, optional): The name of the file to save the screenshot. Default is “screenshot.png”.

liteium.set_cookies(filename)[source]

Load cookies from a file and set them in the browser.

Parameters: filename (str): The name of the file to load the cookies from.

liteium.switch_to_alert(action='accept')[source]

Switch to an alert and perform an action (accept, cancel, or get text).

Parameters: action (str, optional): The action to perform on the alert (‘accept’, ‘cancel’, or ‘text’). Default is ‘accept’.

Returns: str: The text of the alert if action is ‘text’.

liteium.switch_to_default()[source]

Switch to the default content (main document).

liteium.switch_to_frame(frame)[source]

Switch to a specified frame.

Parameters: frame: The frame to switch to (can be name, ID, or WebElement).

liteium.switch_to_window(index_or_name)[source]

Switch to a window by index or name.

Parameters: index_or_name (int or str): The index or name of the window to switch to.

liteium.tag_name(value, time=0)[source]

Find a single element by tag name.

Parameters: value (str): The tag name of the element. time (int, optional): The amount of time to wait for the element to be present. Default is 0.

Returns: WebElement: The located element.

liteium.tag_names(value, time=0)[source]

Find multiple elements by tag name.

Parameters: value (str): The tag name of the elements. time (int, optional): The amount of time to wait for the elements to be present. Default is 0.

Returns: list[WebElement]: The located elements.

liteium.window_position(x, y)[source]

Set the position of the browser window.

Parameters: x (int): The x-coordinate of the window position. y (int): The y-coordinate of the window position.

liteium.window_size(width, height)[source]

Set the size of the browser window.

Parameters: width (int): The width of the window. height (int): The height of the window.

liteium.xpath(value, time=0)[source]

Find a single element by XPath.

Parameters: value (str): The XPath of the element. time (int, optional): The amount of time to wait for the element to be present. Default is 0.

Returns: WebElement: The located element.

liteium.xpaths(value, time=0)[source]

Find multiple elements by XPath.

Parameters: value (str): The XPath of the elements. time (int, optional): The amount of time to wait for the elements to be present. Default is 0.

Returns: list[WebElement]: The located elements.