Skip to content

Commit c5ea387

Browse files
authored
Merge pull request #120 from douglasdcm/improvements-and-fixes
- Fix examples in README - Add implict_wait function for backward-compatibility with Selenium spec - Add text function in sync driver for compatibility with Selenium spec - Fix issues in dependencies of pyproject.py
2 parents 679d2b7 + 3857d4d commit c5ea387

File tree

9 files changed

+54
-236
lines changed

9 files changed

+54
-236
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ From version **2.0.0+**, Caqui includes a high-level API that mirrors Selenium
4848
Chrome Devtools Protocol example:
4949
```python
5050
import time
51-
from pytest import raises
51+
from pytest import raises, fixture
5252
from caqui.cdp.by import By
53+
from caqui.cdp.connection import SyncCDPConnection
5354
from caqui.cdp.synchronous.drivers import SyncDriverCDP
5455
from caqui.exceptions import WebDriverError
5556
from tests.constants import OTHER_URL

caqui/cdp/asynchronous/drivers.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from caqui.cdp.by import By
1515
from caqui.cdp.connection import AsyncCDPConnection
1616
from caqui.cdp.engine import asynchronous
17+
from caqui.helper import deprecated
1718

1819
TIMEOUT = 120 # seconds
1920

@@ -190,6 +191,11 @@ async def add_cookie(self, cookie: dict) -> None:
190191
cookie,
191192
)
192193

194+
@deprecated
195+
async def implicitly_wait(self, timeouts: int) -> None:
196+
"""Set implicty timeouts. `NOte` Present for backward-compatibility only"""
197+
pass
198+
193199
async def back(self) -> None:
194200
"""This command causes the browser to traverse one step backward
195201
in the joint session history of the

caqui/cdp/synchronous/drivers.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from caqui.cdp.synchronous.element import Element
1414
from caqui.cdp.synchronous.switch_to import SwitchTo
1515
from caqui.cdp.synchronous.window import Window
16+
from caqui.helper import deprecated
1617

1718
TIMEOUT = 120 # seconds
1819

@@ -57,6 +58,7 @@ def switch_to(self) -> SwitchTo:
5758
"""Returns the `SwithTo` object"""
5859
return SwitchTo(self)
5960

61+
6062
# TODO test it
6163
def get_current_window_handle(self) -> str:
6264
"""Returns the current window handle"""
@@ -187,6 +189,11 @@ def add_cookie(self, cookie: dict) -> None:
187189
cookie,
188190
)
189191

192+
@deprecated
193+
def implicitly_wait(self, timeouts: int) -> None:
194+
"""Set implicty timeouts.`Note` Present for backward-compatibility only"""
195+
pass
196+
190197
def back(self) -> None:
191198
"""This command causes the browser to traverse one step backward
192199
in the joint session history of the

caqui/cdp/synchronous/element.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ def __init__(self, element: str, driver: "SyncDriverCDP") -> None:
2323
def __str__(self) -> str:
2424
return f"type: Element. NodeId: {self._element}"
2525

26+
27+
@property
28+
def text(self):
29+
return self.get_text()
30+
2631
@property
2732
def element_id(self) -> str:
2833
return self._element

caqui/helper.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# Visit: https://github.com/douglasdcm/caqui
55

66
import base64
7+
import warnings
78
from functools import lru_cache
89

910
from caqui.by import By
@@ -159,3 +160,16 @@ def convert_locator_to_css_selector_or_xpath(locator_type: str, locator_value: s
159160
locator_type = By.XPATH
160161
return locator_type, locator_value
161162
return locator_type, locator_value
163+
164+
def deprecated(func):
165+
"""Use this decorator to mark functions as deprecated.
166+
Every time the decorated function runs, it will emit
167+
a "deprecation" warning."""
168+
def new_func(*args, **kwargs):
169+
warnings.simplefilter('always', DeprecationWarning) # turn off filter
170+
warnings.warn(f"Call to a deprecated function '{func.__name__}'.",
171+
category=DeprecationWarning,
172+
stacklevel=2)
173+
warnings.simplefilter('default', DeprecationWarning) # reset filter
174+
return func(*args, **kwargs)
175+
return new_func

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
author = "Douglas Cardoso"
2323

2424
# The full version, including alpha/beta/rc tags
25-
release = "5.0.0-rc"
25+
release = "5.0.0rc2"
2626

2727

2828
# -- General configuration ---------------------------------------------------

pyproject.toml

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,39 @@
11
[build-system]
2-
requires = ["setuptools>=61.8", "wheel"]
2+
requires = ["setuptools", "wheel"]
33
build-backend = "setuptools.build_meta"
44

5-
[tool.setuptools.packages.find]
6-
include = ["caqui*"]
7-
exclude = ["tests*", "utils", ".vscode", ".git*", "dist"]
8-
95
[project]
106
name = "caqui"
11-
version = "5.0.0-rc"
12-
authors = [
13-
{ name="Douglas Cardoso", email="noemail@noemail.com" },
14-
]
7+
version = "5.0.0rc2"
158
description = "Run asynchronous commands in WebDrivers"
16-
keywords = ["automation", "asynchronous", "test", "crawler", "robotic process automation", "rpa"]
179
readme = "README.md"
1810
requires-python = ">=3.7"
11+
12+
authors = [
13+
{ name="Douglas Cardoso", email="noemail@noemail.com" }
14+
]
15+
1916
classifiers = [
2017
"Development Status :: 4 - Beta",
2118
"Programming Language :: Python :: 3",
2219
"Operating System :: OS Independent",
2320
]
24-
[project.license]
25-
"file" = "LICENSE"
2621

2722
dependencies = [
2823
"requests",
2924
"aiohttp",
3025
"webdriver_manager",
3126
"types-requests",
3227
"beautifulsoup4",
33-
"git+https://github.com/HyperionGray/python-chrome-devtools-protocol.git@5915dce242d4f0cd8c5f8a5e843a535dacc57fc3"
28+
"chrome-devtools-protocol @ git+https://github.com/HyperionGray/python-chrome-devtools-protocol.git@5915dce242d4f0cd8c5f8a5e843a535dacc57fc3"
3429
]
3530

31+
license = { file = "LICENSE" }
32+
3633
[project.urls]
37-
"Homepage" = "https://github.com/douglasdcm/caqui"
34+
Homepage = "https://github.com/douglasdcm/caqui"
3835
"Bug Tracker" = "https://github.com/douglasdcm/caqui/issues"
36+
37+
[tool.setuptools.packages.find]
38+
where = ["."]
39+
include = ["caqui*"]

tests/feature/test_sync_cdp_driver.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ def test_cdp_refresh_page(self, setup_sync_cdp_playground: SyncDriverCDP):
2626
element_after = driver.find_element(By.XPATH, "//input")
2727
assert element_before != element_after
2828

29+
def test_cdp_implicity_wait_is_deprecated(self, setup_sync_cdp_playground: SyncDriverCDP):
30+
driver = setup_sync_cdp_playground
31+
assert driver.implicitly_wait(3) is None
32+
2933
def test_cdp_go_forward(self, setup_sync_cdp_playground: SyncDriverCDP):
3034
driver = setup_sync_cdp_playground
3135
title = "Sample page"

tests/test_sniffer.py

Lines changed: 0 additions & 220 deletions
This file was deleted.

0 commit comments

Comments
 (0)