From 0d18a35f5d45a5f08295fd93ce51b1c129e16603 Mon Sep 17 00:00:00 2001 From: Ravishankar Chavare Date: Sun, 4 Jun 2023 22:29:06 +0530 Subject: [PATCH 1/4] renamed markdown to rst --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index bc8b5cd..707d453 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ authors = ["Ravishankar Chavare ", "Aahnik Daw Date: Sun, 4 Jun 2023 22:40:02 +0530 Subject: [PATCH 2/4] impproved parser --- tests/test_core.py | 6 +++--- tests/test_parser.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 tests/test_parser.py diff --git a/tests/test_core.py b/tests/test_core.py index 6823783..a1ef4f6 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -29,7 +29,7 @@ def setUpClass(cls): options.add_argument('--disable-gpu') # Last I checked this was necessary. cls.driver = webdriver.Chrome(chrome_options=options,service=ChromeService(ChromeDriverManager().install())) - cls.selenium_tools = SeleniumTools(driver=cls.driver,parser_class=LXMLParser) + cls.selenium_tools = SeleniumTools(driver=cls.driver,parser=LXMLParser) cls.url = "https://www.example.com/" cls.example_file =os.path.join(os.path.dirname(__file__),'data/example.html') cls.selenium_tools.get(cls.url) @@ -44,8 +44,8 @@ def test_get_supported_browsers(self): self.assertIsInstance(supported_browsers, list) self.assertGreater(len(supported_browsers), 0) - def test_get_driver_sessionid(self): - session_id = self.selenium_tools.get_driver_sessionid() + def test_sessionid(self): + session_id = self.selenium_tools.sessionid() self.assertIsInstance(session_id, str) self.assertGreater(len(session_id), 0) diff --git a/tests/test_parser.py b/tests/test_parser.py new file mode 100644 index 0000000..dfce236 --- /dev/null +++ b/tests/test_parser.py @@ -0,0 +1,29 @@ + +import unittest + +from s_tool.parser import LxmlParser + + +class LxmlParserTestCase(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.parser = LxmlParser() + + def test_dropdown(self): + html_string = """ + + + + + """ + + expected_result = [('Option 1', '1'), ('Option 2', '2'), ('Option 3', '3')] + dropdown_options = self.parser.dropdown(html_string) + + self.assertEqual(expected_result,dropdown_options) + self.assertTrue(len(dropdown_options)==3) + From 96d441df79c1a92c909bab0b14beca4aa99fc531 Mon Sep 17 00:00:00 2001 From: Ravishankar Chavare <33047641+chavarera@users.noreply.github.com> Date: Sun, 4 Jun 2023 23:04:28 +0530 Subject: [PATCH 3/4] Update .pre-commit-config.yaml isort upgraded --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5dc8caa..0e9a958 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ repos: - repo: https://github.com/pycqa/isort - rev: 5.8.0 + rev: 5.12.0 hooks: - id: isort name: isort (python) From 5afd7406b31ada4c5dbf6e9b8d06aeabea1af791 Mon Sep 17 00:00:00 2001 From: Ravishankar Chavare Date: Sun, 4 Jun 2023 23:45:46 +0530 Subject: [PATCH 4/4] remove black version issue with python 3.11 --- .pre-commit-config.yaml | 19 ++++--------------- docs/conf.py | 3 --- examples/with_class_object.py | 26 -------------------------- examples/with_context_manager.py | 12 ------------ s_tool/core.py | 2 +- s_tool/driver.py | 2 +- tests/test_core.py | 2 +- 7 files changed, 7 insertions(+), 59 deletions(-) delete mode 100644 examples/with_class_object.py delete mode 100644 examples/with_context_manager.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5dc8caa..593fd61 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ repos: - repo: https://github.com/pycqa/isort - rev: 5.8.0 + rev: 5.12.0 hooks: - id: isort name: isort (python) @@ -11,27 +11,16 @@ repos: - id: isort name: isort (pyi) types: [pyi] - - - repo: https://github.com/psf/black - rev: 20.8b1 - hooks: - - id: black - language_version: python3 - entry: black . --check - - - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.812 - hooks: - - id: mypy - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.27.1 + rev: v0.34.0 hooks: - id: markdownlint entry: markdownlint --ignore .github - repo: https://github.com/econchick/interrogate - rev: 1.4.0 + rev: 1.5.0 hooks: - id: interrogate args: [-vv, -i, --fail-under=80] + exclude: ^tests/ diff --git a/docs/conf.py b/docs/conf.py index c9f1c8e..3008278 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -8,11 +8,8 @@ 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 diff --git a/examples/with_class_object.py b/examples/with_class_object.py deleted file mode 100644 index 50f777b..0000000 --- a/examples/with_class_object.py +++ /dev/null @@ -1,26 +0,0 @@ -"""Example code with class""" - -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() diff --git a/examples/with_context_manager.py b/examples/with_context_manager.py deleted file mode 100644 index 05cb58e..0000000 --- a/examples/with_context_manager.py +++ /dev/null @@ -1,12 +0,0 @@ -"""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") diff --git a/s_tool/core.py b/s_tool/core.py index 571a95b..80b2dfa 100644 --- a/s_tool/core.py +++ b/s_tool/core.py @@ -20,10 +20,10 @@ from selenium.webdriver.support.select import Select from selenium.webdriver.support.ui import WebDriverWait +from .driver import SeleniumDriver from .exceptions import InvalidWebDriverError, SToolException from .logger import logger from .parser import LxmlParser -from .driver import SeleniumDriver class SeleniumTools: diff --git a/s_tool/driver.py b/s_tool/driver.py index 0dbbd42..f6e30a8 100644 --- a/s_tool/driver.py +++ b/s_tool/driver.py @@ -6,8 +6,8 @@ from selenium.webdriver.chrome.service import Service as ChromeService from selenium.webdriver.ie.service import Service as IEService from webdriver_manager.chrome import ChromeDriverManager -from webdriver_manager.microsoft import IEDriverManager from webdriver_manager.firefox import GeckoDriverManager +from webdriver_manager.microsoft import IEDriverManager class SeleniumDriver: diff --git a/tests/test_core.py b/tests/test_core.py index a1ef4f6..346629c 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1,6 +1,6 @@ -import unittest import os +import unittest from selenium import webdriver from selenium.webdriver.chrome.options import Options