Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ From version **2.0.0+**, Caqui includes a high-level API that mirrors Selenium
Chrome Devtools Protocol example:
```python
import time
from pytest import raises
from pytest import raises, fixture
from caqui.cdp.by import By
from caqui.cdp.connection import SyncCDPConnection
from caqui.cdp.synchronous.drivers import SyncDriverCDP
from caqui.exceptions import WebDriverError
from tests.constants import OTHER_URL
Expand Down
6 changes: 6 additions & 0 deletions caqui/cdp/asynchronous/drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from caqui.cdp.by import By
from caqui.cdp.connection import AsyncCDPConnection
from caqui.cdp.engine import asynchronous
from caqui.helper import deprecated

TIMEOUT = 120 # seconds

Expand Down Expand Up @@ -190,6 +191,11 @@ async def add_cookie(self, cookie: dict) -> None:
cookie,
)

@deprecated
async def implicitly_wait(self, timeouts: int) -> None:
"""Set implicty timeouts. `NOte` Present for backward-compatibility only"""
pass

async def back(self) -> None:
"""This command causes the browser to traverse one step backward
in the joint session history of the
Expand Down
7 changes: 7 additions & 0 deletions caqui/cdp/synchronous/drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from caqui.cdp.synchronous.element import Element
from caqui.cdp.synchronous.switch_to import SwitchTo
from caqui.cdp.synchronous.window import Window
from caqui.helper import deprecated

TIMEOUT = 120 # seconds

Expand Down Expand Up @@ -57,6 +58,7 @@ def switch_to(self) -> SwitchTo:
"""Returns the `SwithTo` object"""
return SwitchTo(self)


# TODO test it
def get_current_window_handle(self) -> str:
"""Returns the current window handle"""
Expand Down Expand Up @@ -187,6 +189,11 @@ def add_cookie(self, cookie: dict) -> None:
cookie,
)

@deprecated
def implicitly_wait(self, timeouts: int) -> None:
"""Set implicty timeouts.`Note` Present for backward-compatibility only"""
pass

def back(self) -> None:
"""This command causes the browser to traverse one step backward
in the joint session history of the
Expand Down
5 changes: 5 additions & 0 deletions caqui/cdp/synchronous/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ def __init__(self, element: str, driver: "SyncDriverCDP") -> None:
def __str__(self) -> str:
return f"type: Element. NodeId: {self._element}"


@property
def text(self):
return self.get_text()

@property
def element_id(self) -> str:
return self._element
Expand Down
14 changes: 14 additions & 0 deletions caqui/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Visit: https://github.com/douglasdcm/caqui

import base64
import warnings
from functools import lru_cache

from caqui.by import By
Expand Down Expand Up @@ -159,3 +160,16 @@ def convert_locator_to_css_selector_or_xpath(locator_type: str, locator_value: s
locator_type = By.XPATH
return locator_type, locator_value
return locator_type, locator_value

def deprecated(func):
"""Use this decorator to mark functions as deprecated.
Every time the decorated function runs, it will emit
a "deprecation" warning."""
def new_func(*args, **kwargs):
warnings.simplefilter('always', DeprecationWarning) # turn off filter
warnings.warn(f"Call to a deprecated function '{func.__name__}'.",
category=DeprecationWarning,
stacklevel=2)
warnings.simplefilter('default', DeprecationWarning) # reset filter
return func(*args, **kwargs)
return new_func
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
author = "Douglas Cardoso"

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


# -- General configuration ---------------------------------------------------
Expand Down
29 changes: 15 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
[build-system]
requires = ["setuptools>=61.8", "wheel"]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[tool.setuptools.packages.find]
include = ["caqui*"]
exclude = ["tests*", "utils", ".vscode", ".git*", "dist"]

[project]
name = "caqui"
version = "5.0.0-rc"
authors = [
{ name="Douglas Cardoso", email="[email protected]" },
]
version = "5.0.0rc2"
description = "Run asynchronous commands in WebDrivers"
keywords = ["automation", "asynchronous", "test", "crawler", "robotic process automation", "rpa"]
readme = "README.md"
requires-python = ">=3.7"

authors = [
{ name="Douglas Cardoso", email="[email protected]" }
]

classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
]
[project.license]
"file" = "LICENSE"

dependencies = [
"requests",
"aiohttp",
"webdriver_manager",
"types-requests",
"beautifulsoup4",
"git+https://github.com/HyperionGray/python-chrome-devtools-protocol.git@5915dce242d4f0cd8c5f8a5e843a535dacc57fc3"
"chrome-devtools-protocol @ git+https://github.com/HyperionGray/python-chrome-devtools-protocol.git@5915dce242d4f0cd8c5f8a5e843a535dacc57fc3"
]

license = { file = "LICENSE" }

[project.urls]
"Homepage" = "https://github.com/douglasdcm/caqui"
Homepage = "https://github.com/douglasdcm/caqui"
"Bug Tracker" = "https://github.com/douglasdcm/caqui/issues"

[tool.setuptools.packages.find]
where = ["."]
include = ["caqui*"]
4 changes: 4 additions & 0 deletions tests/feature/test_sync_cdp_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
element_after = driver.find_element(By.XPATH, "//input")
assert element_before != element_after

def test_cdp_implicity_wait_is_deprecated(self, setup_sync_cdp_playground: SyncDriverCDP):
driver = setup_sync_cdp_playground
assert driver.implicitly_wait(3) is None

def test_cdp_go_forward(self, setup_sync_cdp_playground: SyncDriverCDP):
driver = setup_sync_cdp_playground
title = "Sample page"
Expand Down
220 changes: 0 additions & 220 deletions tests/test_sniffer.py

This file was deleted.

Loading