Skip to content

Commit

Permalink
Merge pull request #19 from chavarera/main
Browse files Browse the repository at this point in the history
various changes implemented
  • Loading branch information
chavarera authored Jul 9, 2021
2 parents 3916036 + ea49351 commit 7a5651a
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 24 deletions.
File renamed without changes.
156 changes: 132 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
24 changes: 24 additions & 0 deletions examples/with_class_object.py
Original file line number Diff line number Diff line change
@@ -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()
12 changes: 12 additions & 0 deletions examples/with_context_manager.py
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit 7a5651a

Please sign in to comment.