Skip to content

Commit 4a600d3

Browse files
authored
Merge pull request #58 from Python-World/STOOL2
upgraded to s-tool 2
2 parents df09c6c + 2649371 commit 4a600d3

31 files changed

+2429
-1358
lines changed

.flake8

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[flake8]
2+
max-line-length = 150
3+
extend-ignore = E203

.pylintrc

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[FORMAT]
2+
max-line-length=150

HISTORY.rst

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
0.0.4 (2023-06-04)
2+
------------------
3+
4+
* Functions available:
5+
- get(): Loads a web page with the specified URL or local file or Html Content.
6+
- url(): Returns the current URL of the page.
7+
- text(): Returns the source code of the current page.
8+
- get_driver_sessionid(): Return an session id string.
9+
- get_locator(): Returns a WebDriver locator based on the given element identifier and identifier type.
10+
- get_element(): Returns a single element or a list of elements matching the given element identifier and identifier type.
11+
- fill(): Fills in form elements with the provided values.
12+
- wait_for_element(): Waits for an element to be present and visible on the page.
13+
- element_visibility(): Toggles the visibility of an element on the page.
14+
- cookies(): Returns all cookies present in the current session.
15+
- set_cookies(): Sets cookies for the current session using a dictionary of cookie key-value pairs.
16+
- click(): Clicks on the element identified by the given element identifier and identifier type.
17+
- press_multiple_keys(): Presses multiple keys simultaneously using Selenium.
18+
- execute_script(): Executes JavaScript code in the context of the current page.
19+
- parse(): Parses the HTML content of the current page and returns a list of elements matching the given tag name and attribute value.
20+
21+
22+
0.0.3 (2023-06-04)
23+
------------------
24+
* Functions available:
25+
- bug fixes
26+
27+
0.0.2 (2023-06-04)
28+
------------------
29+
* Functions available:
30+
- bug fixes
31+
32+
0.0.1 (2023-06-04)
33+
------------------
34+
* Functions available:
35+
- initial release

README.md

-137
This file was deleted.

README.rst

+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
**S-TOOL**
2+
3+
.. image:: https://user-images.githubusercontent.com/33047641/125023819-41998700-e09d-11eb-8076-7fad81f98f70.png
4+
:width: 150
5+
6+
7+
``S-Tool`` is a utility module that provides helpful methods for interacting with Selenium WebDriver in Python
8+
9+
Installation
10+
^^^^^^^^^^^^
11+
12+
Installation using PyPi
13+
-----------------------
14+
15+
.. code:: bash
16+
17+
pip install s-tool
18+
19+
20+
Development Setup
21+
-----------------
22+
23+
.. code:: bash
24+
25+
# Clone this repository
26+
git clone https://github.com/Python-World/s-tool.git
27+
28+
# Go into the repository
29+
cd sel-kit
30+
31+
# Install dependencies
32+
poetry config virtualenvs.in-project true
33+
poetry install
34+
35+
# Start Poetry shell
36+
poetry shell
37+
38+
39+
40+
Usage
41+
^^^^^
42+
43+
* Example Using Context Manager
44+
45+
.. code-block:: python
46+
47+
"""Example code with context manager"""
48+
49+
from s_tool.core import SeleniumDriver as SBot
50+
51+
with SBot("firefox", headless=True) as self:
52+
self.get("https://google.com")
53+
sessionid = self.session()
54+
url = self.url()
55+
cookies = self.cookies()
56+
57+
# print sessionid,url,cookies
58+
print(f"\nurl : {url} \nsession : {sessionid}\ncookies : {cookies}\n")
59+
60+
61+
* Example Using class
62+
63+
.. code-block:: python
64+
65+
from s_tool.core import SeleniumTools
66+
67+
class SBot(SeleniumTools):
68+
"""Example Bot using s-tool"""
69+
70+
def __init__(self, *args, **kwargs):
71+
super().__init__(*args, **kwargs)
72+
73+
def run(self):
74+
"""Code to visit url and fetch cookies and basic info"""
75+
url ="https://example.com"
76+
self.get(url)
77+
sessionid = self.sessionid()
78+
url = self.url()
79+
cookies = self.cookies()
80+
81+
# print sessionid,url,cookies
82+
print(f"\nurl : {url} \nsession : {sessionid}\ncookies : {cookies}\n")
83+
84+
85+
bot = SBot(browser ="firefox", headless=True) # change headless=False to run with gui mode
86+
bot.run()
87+
bot.close()
88+
89+
90+
Methods
91+
^^^^^^^
92+
93+
Here are the public methods available in the SeleniumTools class:
94+
- get(): Loads a web page with the specified URL or local file or Html Content.
95+
- url(): Returns the current URL of the page.
96+
- text(): Returns the source code of the current page.
97+
- get_driver_sessionid(): Return an session id string.
98+
- get_locator(): Returns a WebDriver locator based on the given element identifier and identifier type.
99+
- get_element(): Returns a single element or a list of elements matching the given element identifier and identifier type.
100+
- fill(): Fills in form elements with the provided values.
101+
- wait_for_element(): Waits for an element to be present and visible on the page.
102+
- element_visibility(): Toggles the visibility of an element on the page.
103+
- cookies(): Returns all cookies present in the current session.
104+
- set_cookies(): Sets cookies for the current session using a dictionary of cookie key-value pairs.
105+
- click(): Clicks on the element identified by the given element identifier and identifier type.
106+
- press_multiple_keys(): Presses multiple keys simultaneously using Selenium.
107+
- execute_script(): Executes JavaScript code in the context of the current page.
108+
- parse(): Parses the HTML content of the current page and returns a list of elements matching the given tag name and attribute value.
109+
110+
111+
112+
Feel free to refer to the documentation for each method to understand their parameters and usage.
113+
114+
Contributing
115+
^^^^^^^^^^^^
116+
117+
Contributions are welcome! If you find any issues or have suggestions for improvement, please create an issue or submit a pull request.
118+
119+
License
120+
-------
121+
This project is licensed under the MIT License.

docs/Makefile

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/conf.py

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# For the full list of built-in configuration values, see the documentation:
4+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
5+
6+
import os
7+
import sys
8+
9+
sys.path.insert(0, os.path.abspath('..'))
10+
11+
12+
import sphinx_rtd_theme
13+
from s_tool import __version__ as _version
14+
15+
16+
# -- Project information -----------------------------------------------------
17+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
18+
19+
project = 'S-Tool'
20+
copyright = '2023, Ravishankar Chavare'
21+
author = 'Ravishankar Chavare'
22+
release = '0.0.4'
23+
24+
25+
# The short X.Y version
26+
version = _version
27+
28+
# The full version, including alpha/beta/rc tags
29+
release = _version
30+
31+
# -- General configuration ---------------------------------------------------
32+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
33+
34+
source_suffix = ['.rst', '.md']
35+
36+
extensions = [
37+
'sphinx.ext.autodoc',
38+
'sphinx.ext.doctest',
39+
'sphinx.ext.coverage',
40+
'sphinx.ext.viewcode',
41+
'sphinx_rtd_theme',
42+
]
43+
44+
templates_path = ['_templates']
45+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
46+
47+
master_doc = 'index'
48+
49+
50+
pygments_style = 'sphinx'
51+
52+
53+
# -- Options for HTML output -------------------------------------------------
54+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
55+
56+
html_theme = 'sphinx_rtd_theme'
57+
add_module_names = False
58+
html_title = 'Python'
59+
60+
html_static_path = ['_static']
61+
62+
# Output file base name for HTML help builder.
63+
htmlhelp_basename = 's-tooldoc'
64+

docs/history.rst

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Changelog
2+
*********
3+
.. include:: ../HISTORY.rst

0 commit comments

Comments
 (0)