diff --git a/.github/CONTRIBUTING.md b/CONTRIBUTING.md similarity index 100% rename from .github/CONTRIBUTING.md rename to CONTRIBUTING.md diff --git a/README.md b/README.md index e60b69a..64e1c69 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,132 @@ -# s-tool - -Selenium wrapper to make your life easy. - -## Features - -- [X] Manage multiple webdrivers. -- [X] Click any type of element. -- [X] Extract Page source. -- [X] Select different type of elements. -- [X] Retrive cookies. -- [X] take fullpage and elementwise screenshots. -- [X] display and hide elements. - -## TODO - -- [ ] Fill information(forms) -- [ ] horizontal and vertical scrolling -- [ ] Handeling alerts and popup -- [ ] Switching windows,tabs,frames. -- [ ] adding universal login functionality with forms -- [ ] handling iframe windows. -- [ ] Writing Parser to extract data from WebDriver. -- [ ] Logging driver activities +# S-Tool + +![S-tool](https://user-images.githubusercontent.com/33047641/125023819-41998700-e09d-11eb-8076-7fad81f98f70.png) + +## Selenium wrapper to make your life easy + +![python](https://img.shields.io/badge/Python-FFD43B?style=for-the-badge&logo=python) +![selemium](https://img.shields.io/badge/Selenium-e5dfde?style=for-the-badge&logo=selenium) +![s-tool](https://img.shields.io/badge/S-Tool-3776AB?style=for-the-badge) +![Python-World](https://img.shields.io/badge/Python-World-FFD43B?style=for-the-badge&logo=python&logoColor=white) + +## Table of Contents + +- [Key Features](#key-features) +- [How To Use](#how-to-use) +- [Examples](#examples) +- [Todo](#todo) +- [License](#license) + +## Key Features + +- WebDriver + - Manage multiple web drivers such as chrome,chromium,firefox. +- Different Utilities + - Retrieve element with 5 different attribute. + - Perform clicks on element + - Take full page and element screenshot. + - Hide and show elements. + - Information filling on different form elements such as text,radio,checkbox. + - Retrieves current cookies from browser. + - Retrieve url and web page source +- Element Parser + - table Information + - Retrieve dropdown options in dictionary + +## How To Use + +### Install using PYPI + +```bash +pip install s-tool +``` + +### Setup for development + +To clone and run this application, you'll need [Git](https://git-scm.com) and +[Poetry](https://python-poetry.org/) and [python Version ^3.8](http://python.org/) + +```bash +# 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](CONTRIBUTING) + +## Examples + +### Example 1 + +```python +"""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"\nurl : {url} \nsession : {sessionid}\ncookies : {cookies}\n") + + +bot = SBot("firefox", headless=True) # change headless=False to run with gui mode +bot.run() +bot.close() + +``` + +### Example 2 + +```python +"""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"\nurl : {url} \nsession : {sessionid}\ncookies : {cookies}\n") + +``` + +## Todo + +- Web driver utilities + - Scrolling element and page. + - Handling popup and alert boxes. + - Switching windows,frame,tabs,iframes. + - logger. +- Element Parser + - list + - radio and checkboxes + +Note: If you have any idea to improve or optimized in better way +[create issue](https://github.com/Python-World/s-tool/issues/new) for discussion. + +## License + +[MIT](LICENSE) diff --git a/examples/with_class_object.py b/examples/with_class_object.py new file mode 100644 index 0000000..8b7a856 --- /dev/null +++ b/examples/with_class_object.py @@ -0,0 +1,24 @@ +"""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"\nurl : {url} \nsession : {sessionid}\ncookies : {cookies}\n") + + +bot = SBot("firefox", headless=True) # change headless=False to run with gui mode +bot.run() +bot.close() diff --git a/examples/with_context_manager.py b/examples/with_context_manager.py new file mode 100644 index 0000000..05cb58e --- /dev/null +++ b/examples/with_context_manager.py @@ -0,0 +1,12 @@ +"""Example code with context manager""" + +from s_tool.driver import SeleniumDriver as SBot + +with SBot("firefox", headless=True) as self: + self.get("https://google.com") + sessionid = self.session() + url = self.url() + cookies = self.cookies() + + # print sessionid,url,cookies + print(f"\nurl : {url} \nsession : {sessionid}\ncookies : {cookies}\n")