/s-tool

Selenium wrapper to make your life easy.

Primary LanguagePythonMIT LicenseMIT

S-Tool

S-tool

Selenium wrapper to make your life easy

python selemium s-tool Python-World

Table of Contents

Key Features

  • WebDriver
    • Manage multiple web drivers such as chrome,chromium,firefox.
  • Different Utilities
    • Retrieve elements with 5 different attributes.
    • Perform clicks on element.
    • Take a full page and element screenshot.
    • Hide and show elements.
    • Information filling on different form elements such as text,radio,checkbox.
    • Retrieves current cookies from the browser.
    • Injecting new cookies into browser.
    • Retrieve url and web page source.
    • Add or modify existing cookies.
    • Retrieve current user agent.
    • Check Existence of an element on the page.
  • Element Parser
    • table Information.
    • Retrieve dropdown options in the dictionary.

How To Use

Install using PYPI

pip install s-tool

Setup for development

To clone and run this application, you'll need Git and Poetry and python Version ^3.8

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

# Go into the repository
cd s-tool

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

# Start Poetry shell
poetry shell

Note: If you're doing development setup, see this guide

Examples

Example 1

"""Example code with class"""

from s_tool.driver import SeleniumDriver


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

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

   def run(self):
       self.get("https://google.com")
       sessionid = self.session()
       url = self.url()
       cookies = self.cookies()

       # print sessionid,url,cookies
       print(f"\n url     :   {url} \n session :   {sessionid}\n cookies :   {cookies}\n")


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

Example 2

"""Example code with context manager"""

from s_tool.driver import SeleniumDriver as SBot

with SBot("firefox", headless=True) as obj:
   obj.get("https://google.com")
   sessionid = obj.session()
   url = obj.url()
   cookies = obj.cookies()

   # print sessionid,url,cookies
   print(f"\n url     :   {url} \n session :   {sessionid}\n cookies :   {cookies}\n")

Todo

  • Web driver utilities
    • Scrolling element and page.
    • Handling popup and alert boxes.
    • Switching windows,frames,tabs,iframes.
    • logger.
  • Element Parser
    • list
    • radio and checkboxes

Note: If you have any idea to improve or optimized in better way create issue for discussion.

License

MIT