-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
2,429 additions
and
1,358 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[flake8] | ||
max-line-length = 150 | ||
extend-ignore = E203 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[FORMAT] | ||
max-line-length=150 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
0.0.4 (2023-06-04) | ||
------------------ | ||
|
||
* Functions available: | ||
- 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. | ||
|
||
|
||
0.0.3 (2023-06-04) | ||
------------------ | ||
* Functions available: | ||
- bug fixes | ||
|
||
0.0.2 (2023-06-04) | ||
------------------ | ||
* Functions available: | ||
- bug fixes | ||
|
||
0.0.1 (2023-06-04) | ||
------------------ | ||
* Functions available: | ||
- initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
**S-TOOL** | ||
|
||
.. image:: https://user-images.githubusercontent.com/33047641/125023819-41998700-e09d-11eb-8076-7fad81f98f70.png | ||
:width: 150 | ||
|
||
|
||
``S-Tool`` is a utility module that provides helpful methods for interacting with Selenium WebDriver in Python | ||
|
||
Installation | ||
^^^^^^^^^^^^ | ||
|
||
Installation using PyPi | ||
----------------------- | ||
|
||
.. code:: bash | ||
pip install s-tool | ||
Development Setup | ||
----------------- | ||
|
||
.. code:: bash | ||
# 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 | ||
|
||
.. code-block:: python | ||
"""Example code with context manager""" | ||
from s_tool.core 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") | ||
* Example Using class | ||
|
||
.. code-block:: python | ||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Minimal makefile for Sphinx documentation | ||
# | ||
|
||
# You can set these variables from the command line, and also | ||
# from the environment for the first two. | ||
SPHINXOPTS ?= | ||
SPHINXBUILD ?= sphinx-build | ||
SOURCEDIR = . | ||
BUILDDIR = _build | ||
|
||
# Put it first so that "make" without argument is like "make help". | ||
help: | ||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
|
||
.PHONY: help Makefile | ||
|
||
# Catch-all target: route all unknown targets to Sphinx using the new | ||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). | ||
%: Makefile | ||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Configuration file for the Sphinx documentation builder. | ||
# | ||
# For the full list of built-in configuration values, see the documentation: | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html | ||
|
||
import os | ||
import sys | ||
|
||
sys.path.insert(0, os.path.abspath('..')) | ||
|
||
|
||
import sphinx_rtd_theme | ||
from s_tool import __version__ as _version | ||
|
||
|
||
# -- Project information ----------------------------------------------------- | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information | ||
|
||
project = 'S-Tool' | ||
copyright = '2023, Ravishankar Chavare' | ||
author = 'Ravishankar Chavare' | ||
release = '0.0.4' | ||
|
||
|
||
# The short X.Y version | ||
version = _version | ||
|
||
# The full version, including alpha/beta/rc tags | ||
release = _version | ||
|
||
# -- General configuration --------------------------------------------------- | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration | ||
|
||
source_suffix = ['.rst', '.md'] | ||
|
||
extensions = [ | ||
'sphinx.ext.autodoc', | ||
'sphinx.ext.doctest', | ||
'sphinx.ext.coverage', | ||
'sphinx.ext.viewcode', | ||
'sphinx_rtd_theme', | ||
] | ||
|
||
templates_path = ['_templates'] | ||
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] | ||
|
||
master_doc = 'index' | ||
|
||
|
||
pygments_style = 'sphinx' | ||
|
||
|
||
# -- Options for HTML output ------------------------------------------------- | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output | ||
|
||
html_theme = 'sphinx_rtd_theme' | ||
add_module_names = False | ||
html_title = 'Python' | ||
|
||
html_static_path = ['_static'] | ||
|
||
# Output file base name for HTML help builder. | ||
htmlhelp_basename = 's-tooldoc' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Changelog | ||
********* | ||
.. include:: ../HISTORY.rst |
Oops, something went wrong.