You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge pull request #114 from douglasdcm/performance-improvements
Performance improvements and simplification of code classes
- Update documentation with new classes and methods
- Add support to single connection by `aiohttp.ClientSession`
- Improve type-hints
- Add support to `W3C` and `Jsonwire` specifications
- Convert all locators to CSS Selector in runtime to improve performance
- Add pool of elements in `AsyncDriver` for better performance
- Rename `AsyncPage` class to `AsyncDriver`
- Merge `OptionsBuilder` class to `CapabilitiesBuilder` class
- Rename `Server` class to `LocalServer` class
- Rename internal variables for better code understanding
- Add the parameter `executable_path` to `LocalServer` to use existing local drivers
- Add specific methods in `LocalServer` to start web drivers
- Fix skipped tests
- Test all functions with Chrome, Opera, Edge and Firefox
**Caqui**executes commands against Drivers synchronously and asynchronously. The intention is that the user does not worry about which Driver they're using. It can be **Web**Drivers like [Selenium](https://www.selenium.dev/), **Mobile**Drivers like [Appium](http://appium.io/docs/en/2.0/), or **Desktop**Drivers like [Winium](https://github.com/2gis/Winium.Desktop). It can also be used in remote calls. The user can start the Driver as a server in any host and provide the URL to **Caqui** clients.
6
+
**Caqui**is a Python library for browser, mobile, and desktop automation that works with any driver that exposes a WebDriver-style REST API. It lets you send commands **synchronously or asynchronously**, and you don’t need to think about which underlying driver you’re using.
6
7
7
-
# Tested WebDrivers
8
+
Caqui is designed for developers who want a unified automation API that can run:
Caqui runs seamlessly on a local machine or across remote hosts, and supports both **multitasking with asyncio** and **multiprocessing** for high-throughput use cases such as parallel testing, web scraping, or distributed automation.
| Appium | 2.0.0+ | Y | Accepts remote calls by default. Tested with Appium in Docker |
24
+
| Firefox (geckodriver) | 113+ | Y | Requires defining the host IP, e.g. `--host 123.45.6.78`|
25
+
| Google Chrome | 113+ | Y | Requires allowed IPs, e.g. `--allowed-ips=123.45.6.78`|
26
+
| Opera | 99+ | Y | Same restrictions as Chrome |
27
+
| WinAppDriver | 1.2.1+ | Y | Requires host IP, e.g. `WinApppage.exe 10.0.0.10 4723`|
28
+
| Winium Desktop | 1.6.0+ | Y | Accepts remote calls by default |
29
+
30
+
*Remote = can accept REST requests when running as a server.
31
+
32
+
---
33
+
34
+
# Installation
22
35
23
36
```bash
24
37
pip install caqui
25
38
```
26
39
27
-
# Version 2.0.0+
28
-
In version 2.0.0+ it is possible to use Python objects similarly to Selenium. **Read the [API documentation](https://caqui.readthedocs.io/en/latest/caqui.html) for more information.**
40
+
---
41
+
42
+
# Using Caqui 2.0.0+
43
+
44
+
From version **2.0.0+**, Caqui includes a high-level API that mirrors Selenium’s object model and exposes async methods for browser, mobile, and desktop automation.
To execute the test in multiple tasks, use [pytest-async-cooperative](https://github.com/willemt/pytest-asyncio-cooperative). It will speed up the execution considerably.
101
+
# Running Tests with Multitasking
102
+
103
+
Caqui supports asyncio out of the box.
104
+
To run multiple async tests concurrently, use **pytest-async-cooperative**:
element =await page.find_element(locator=By.XPATH, value="//button")
103
-
assertstr(element) == element_string
104
112
113
+
@mark.asyncio_cooperative
114
+
asyncdeftest_click(caqui_driver: AsyncDriver):
115
+
await caqui_driver.get(PAGE_URL)
116
+
element =await caqui_driver.find_element(By.XPATH, "//button")
117
+
await element.click()
105
118
```
106
119
107
-
## Running as multiprocessing
108
-
To run the tests in multiple processes use [pytest-xdist](https://github.com/pytest-dev/pytest-xdist). The execution is even faster than running in multiple tasks. Check this article [Supercharge Your Web Crawlers with Caqui: Boosting Speed with Multi-Processing](https://medium.com/@douglas.dcm/speed-up-your-web-crawlers-at-90-148f3ca97b6) to know how to increase the velocity of the executions in 90%.
120
+
Running tests this way significantly reduces execution time, especially when interacting with multiple drivers or sessions.
121
+
122
+
---
123
+
124
+
# Running Tests with Multiprocessing
125
+
126
+
If your workloads benefit from multiple processes, Caqui also works with **pytest-xdist**.
127
+
This approach is often faster than cooperative multitasking.
128
+
129
+
A guide to optimizing performance (including a real benchmark):
130
+
[Speed up your web crawlers at 90%](https://medium.com/@douglas.dcm/speed-up-your-web-crawlers-at-90-148f3ca97b6)
element =await page.find_element(locator=By.XPATH, value="//button")
121
-
assertstr(element) == element_string
142
+
asyncdeftest_click(caqui_driver: AsyncDriver):
143
+
await caqui_driver.get(PAGE_URL)
144
+
element =await caqui_driver.find_element(By.XPATH, "//button")
145
+
await element.click()
122
146
123
147
```
124
148
125
-
# Driver as a server
126
-
In case you are using Appium, Winium or other driver not started by the library, just start the driver as a server.
149
+
---
127
150
128
-
For example. Download the same [ChromeDriver](https://chromepage.chromium.org/downloads) version as your installed Chrome and start the Driver as a server using the port "9999"
151
+
# Running a Driver as a Server
152
+
153
+
If you use external drivers such as Appium, Winium, or a standalone ChromeDriver, run them as servers and point Caqui to their URL.
154
+
155
+
Example for ChromeDriver on port 9999:
129
156
130
157
```bash
131
158
$ ./chromedriver --port=9999
@@ -134,11 +161,24 @@ Only local connections are allowed.
134
161
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
135
162
ChromeDriver was started successfully.
136
163
```
137
-
# Webdriver Manager
138
164
139
-
Caqui depends on [Webdriver Manager](https://pypi.org/project/webdriver-manager/) that can be configured independenly and has some limitations. Check the project documentation for more information.
165
+
---
166
+
167
+
# WebDriver Manager
168
+
169
+
Caqui’s `LocalServer` class uses [Webdriver Manager](https://pypi.org/project/webdriver-manager/).
170
+
The tool comes with its own constraints.
171
+
Check its documentation for details if you need custom driver handling.
140
172
173
+
---
141
174
142
175
# Contributing
143
-
Read the [Code of Conduct](https://github.com/douglasdcm/caqui/blob/main/docs/CODE_OF_CONDUCT.md) before push new Merge Requests.
144
-
Now, follow the steps in [Contributing](https://github.com/douglasdcm/caqui/blob/main/docs/CONTRIBUTING.md) session.
176
+
177
+
Before submitting a pull request, review the project guidelines:
178
+
Code of Conduct:
179
+
[CODE OF CONDUCT](https://github.com/douglasdcm/caqui/blob/main/docs/CODE_OF_CONDUCT.md)
0 commit comments