Skip to main content

S-TOOL

https://user-images.githubusercontent.com/33047641/125023819-41998700-e09d-11eb-8076-7fad81f98f70.png

S-Tool is a utility module that provides helpful methods for interacting with Selenium WebDriver in Python

Installation

Installation using PyPi

pip install s-tool

Development Setup

# Clone this repository
 git clone https://github.com/Python-World/s-tool.git

 # Go into the repository
 cd sel-kit

 # Install dependencies
 poetry config virtualenvs.in-project true
 poetry install

 # Start Poetry shell
 poetry shell

Usage

  • Example Using Context Manager

"""Example code with context manager"""

from s_tool.core import SeleniumTools as SBot

with SBot(browser="firefox", headless=True) as self:
    self.get("https://example.com")
    sessionid = self.sessionid()
    url = self.url()
    cookies = self.cookies()

    # print sessionid,url,cookies
    print(f"\nurl     :   {url} \nsession :   {sessionid}\ncookies :   {cookies}\n")
  • Example Using class

from s_tool.core import SeleniumTools

class SBot(SeleniumTools):
    """Example Bot using s-tool"""

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

    def run(self):
        """Code to visit url and fetch cookies and basic info"""
        url ="https://example.com"
        self.get(url)
        sessionid = self.sessionid()
        url = self.url()
        cookies = self.cookies()

        # print sessionid,url,cookies
        print(f"\nurl     :   {url} \nsession :   {sessionid}\ncookies :   {cookies}\n")


bot = SBot(browser ="firefox", headless=True)  # change headless=False to run with gui mode
bot.run()
bot._close()

Methods

Here are the public methods available in the SeleniumTools class:
  • get(): Loads a web page with the specified URL or local file or Html Content.

  • url(): Returns the current URL of the page.

  • text(): Returns the source code of the current page.

  • get_driver_sessionid(): Return an session id string.

  • get_locator(): Returns a WebDriver locator based on the given element identifier and identifier type.

  • get_element(): Returns a single element or a list of elements matching the given element identifier and identifier type.

  • fill(): Fills in form elements with the provided values.

  • wait_for_element(): Waits for an element to be present and visible on the page.

  • element_visibility(): Toggles the visibility of an element on the page.

  • cookies(): Returns all cookies present in the current session.

  • set_cookies(): Sets cookies for the current session using a dictionary of cookie key-value pairs.

  • click(): Clicks on the element identified by the given element identifier and identifier type.

  • press_multiple_keys(): Presses multiple keys simultaneously using Selenium.

  • execute_script(): Executes JavaScript code in the context of the current page.

  • parse(): Parses the HTML content of the current page and returns a list of elements matching the given tag name and attribute value.

Feel free to refer to the documentation for each method to understand their parameters and usage.

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvement, please create an issue or submit a pull request.

License

This project is licensed under the MIT License.

Release files for s-tool 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for s-tool 0.0.5
File Size Uploaded
s_tool-0.0.5.tar.gz 11.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for s-tool 0.0.5
File Interpreter ABI Platform
s_tool-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 23.9 kB

Release files / s_tool-0.0.5.tar.gz

Download URL s_tool-0.0.5.tar.gz
Size 11.9 kB
Tags Source
SHA-256 checksum
How to use checksums
04d5e76dba32ba1dd639f3754bd4b7191fc3150e316f37cec88653f6c30bd5cf
BLAKE2b-256 checksum
How to use checksums
cd7b6e708116f0848bcf4fecb4fb7b9f29e1c686087a5dc30c9fe1ccec418a73
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.4

Release files / s_tool-0.0.5-py3-none-any.whl

Download URL s_tool-0.0.5-py3-none-any.whl
Size 12.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7b9e8f000e70573e5045baa596937246b2fb380838020c72bbceb410869230ab
BLAKE2b-256 checksum
How to use checksums
4e0f25313d845199c5861e38fcc7762540c81c0d448ceee8feb5fdd984997229
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.4

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page