Pyleniumio

Latest version: v1.20.0

Safety actively analyzes 613705 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 7

1.20.0

The goal of this release was to replace `webdriver-manager`, which was having issues with Chrome 115, with Selenium's new `Selenium Manager` ๐Ÿ‘๐Ÿฝ

These changes were "under the hood", so things should just continue to work without you having to do anything. However, I highly recommend reading Selenium's documentation about how to use Selenium Manager: https://www.selenium.dev/blog/2023/whats-new-in-selenium-manager-with-selenium-4.11.0/

Changes

* Replace `webdriver-manager` with the new, official `Selenium Manager`. This fixes the Chrome 115 issues ๐ŸŽ‰
* `driver.version` has been removed from `pylenium.json`
* Selenium Manager uses the installed browser(s) to determine which driver binaries to use
* For example, if you have Chrome 116 installed, it will automatically make sure to use driver 116
* Updated package version constraints. For example, `selenium = "^4.11.2"`

Considerations

* You can still use `driver.local_path` if you want Selenium Manager to use a locally installed driver instead of downloading and caching from the internet
* Just upgrade to the latest Pylenium version and you should be good to go with these changes and fixes ๐ŸŽ‰

1.19.0

Short and sweet release that focused on updating Pylenium dependencies. This is a minor version bump because there is a breaking change, but these are the highlights you will care about:

* Updated multiple packages to their newer versions: https://github.com/ElSnoMan/pyleniumio/pull/305
* Pylenium now has a minimum Python version requirement of `3.8.1` or higher

> ๐Ÿ’กSo, make sure to update your Python version if you're still using `3.7.x` ๐Ÿ‘๐Ÿฝ

Contributers ๐ŸŽ‰

Thank you, LostInDarkMath, for taking the time to create this PR and making Pylenium better ๐Ÿ™๐Ÿฝ

1.18.0

* Make webdriver version optional by rnestler in https://github.com/ElSnoMan/pyleniumio/pull/299
* Bug fixes including Browser Version and SeleniumWire flag by ElSnoMan in https://github.com/ElSnoMan/pyleniumio/pull/302

Highlights ๐Ÿ’ก

This release focused on making improvements to our `webdriver_factory.py` which uses `webdriver_manager` under the hood:

* `pylenium.json` now has `driver.version: null` by default. This means that Pylenium will use the driver on the PATH, if any, or default to using the latest version. This should solve most problems people were experiencing with driver versions ๐Ÿ‘๐Ÿฝ
* `pylenium.json` now has `driver.seleniumwire_enabled: false` by default. This new flag allows you to use a regular WebDriver or a SeleniumWire Webdriver. Some people have reported issues related to SeleniumWire, so we wanted users to have the ability to "opt in" to using it if they wanted ๐Ÿ‘๐Ÿฝ
* Report Portal Integration removed ๐Ÿ˜ฎ - I like Report Portal, but keeping it up to date natively was proving more work than the value it provided. Only Allure is "natively" supported now, but remember:

> ๐Ÿ’กUsers can always add the integration themselves if they would like since using plugins and extending Pylenium is easy ๐Ÿ‘๐Ÿฝ

Chores ๐Ÿงน

These have no effect on users of Pylenium, but contributors will appreciate these improvements! ๐Ÿ˜„

* Do not install another flake8 version in CI by rnestler in https://github.com/ElSnoMan/pyleniumio/pull/300
* Add typer and remove rich-click by ElSnoMan in https://github.com/ElSnoMan/pyleniumio/pull/304
* Finally removed `setup.py` ๐ŸŽ‰ - Now we exclusively use `pyproject.toml` and use pypi's OICD to publish to pypi!

Fixes ๐Ÿ›

* https://github.com/ElSnoMan/pyleniumio/issues/301
* https://github.com/ElSnoMan/pyleniumio/issues/298
* https://github.com/ElSnoMan/pyleniumio/issues/294

Contributers ๐Ÿ™‡๐Ÿฝโ€โ™‚๏ธ

As always, thank you so much for those of you who are using Pylenium, but also opening issues, having discussions, and especially for submitting PRs! Y'all are the real MVPs ๐Ÿ‘๐Ÿฝ ๐ŸŽ‰

* rnestler

**Full Changelog**: https://github.com/ElSnoMan/pyleniumio/compare/v1.17.0...v1.18.0

1.17.2

Overview

> ๐Ÿ’ก Contributing to Pylenium is even easier now that you can use [Gitpod](https://www.gitpod.io/docs/introduction/getting-started) - by ElSnoMan in https://github.com/ElSnoMan/pyleniumio/pull/290

* Add ability to pass `local_path` via CLI arg by vincent-olivert-riera in https://github.com/ElSnoMan/pyleniumio/pull/285
* Add allure reporting and update logging by ElSnoMan in https://github.com/ElSnoMan/pyleniumio/pull/291
* Add `pyc` and `pys` fixtures by ElSnoMan in https://github.com/ElSnoMan/pyleniumio/pull/293

See the Details section below for... well, more details ๐Ÿ˜„

Fixes

- ๐Ÿ› That pesky `webdriver_manager` bug has been resolved (278)
- ๐Ÿ‘• pylint fixes by marksmayo in https://github.com/ElSnoMan/pyleniumio/pull/288

Documentation

- ๐Ÿ“ Github Repo README updated to include the crucial `$ pylenium init` step (283)
- ๐Ÿ“ [Viewport configuration docs](https://docs.pylenium.io/configuration/viewport) updated to show how to use viewport settings (#282)

Details

The major update for version `1.17` is the native integration with Allure for test reporting and the addition of the `pys` and `pyc` fixtures.

Allure Reporting

Currently, Pylenium integrates natively with [ReportPortal.io](https://reportportal.io) which is free and open source, but is relatively complex to setup and use. I wanted a simpler reporting tool that still had rich reporting; enter [Allure](https://docs.qameta.io/allure-report/#_about) and their [pytest plugin](https://github.com/allure-framework/allure-python)

In three easy steps you can leverage their awesome reporting! We also added some convenient CLI commands to help with this, although using `allure` directly is recommended:

1. Install allure CLI
- You can use `pylenium allure install`
- or visit their [docs](https://docs.qameta.io/allure-report/#_installing_a_commandline) for your machine's appropriate installation instructions (recommended)
- then you can check the installation with `pylenium allure check`

2. Run tests
- It's just pytest, but now add where you want the allure results to be saved:
bash
pytest --alluredir=allure-report


3. Then _serve_ the results to generate a beautiful report in your browser!
- You can use `pylenium allure serve --folder allure-report`
- or `allure serve allure-report` (recommended)

Session- and class-scoped Pylenium instances

When writing automated tests, it's recommended that each test be atomic and independent - meaning that `Test B` should not be reliant on `Test A`. This is a good principle to follow and enables things like running tests in parallel, but there are times when you want a single Pylenium instance for a session or for a group of tests in a Test Class.

> This is what the `pys` and `pyc` fixtures are for!

- The recommended `py` fixture is an instance of Pylenium for each test function which also comes with `py_config` which is the configuration for each test function
py
from pylenium.driver import Pylenium

def test_function(py: Pylenium):
py.visit("https://qap.dev")
...


- `pys` and `pys_config` are used if you want a single Pylenium instance for the entire Test Session
py
from pylenium.driver import Pylenium

def test_a(pys: Pylenium):
py.visit("https://qap.dev")
...

def test_b(pys: Pylenium):
uses same Pylenium instance as test_a
...


- `pyc` and `pyc_config` are used if you want a single Pylenium instance for an entire Test Class
py
from pylenium.driver import Pylenium

class TestClass:
def test_a(self, pyc: Pylenium):
py.visit("https://qap.dev")
...

def test_b(self, pyc: Pylenium):
uses same Pylenium instance as test_a
...


> ๐Ÿ’ก Using `py` is highly recommended, but now you have more options for your context ๐Ÿ’ช๐Ÿฝ

New Contributors ๐ŸŽ‰

As always, a big THANK YOU to everyone that uses and contributes to Pylenium! Y'all are amazing ๐Ÿ‘๐Ÿฝ

* vincent-olivert-riera made their first contribution in https://github.com/ElSnoMan/pyleniumio/pull/285
* marksmayo made their first contribution in https://github.com/ElSnoMan/pyleniumio/pull/288

**Full Changelog**: https://github.com/ElSnoMan/pyleniumio/compare/v1.16.0...v1.17.0

1.17.0

1.16.0

pylenium.json

[267]

The major update for this release is the ability to pass in any `pylenium.json` config file when executing your tests! Before v1.16.0, there was only a _single_ `pylenium.json` file that existed at your Project Root (after running `$ pylenium init`) and this was the main config file to change.

> ๐Ÿ’ก Now you can keep multiple versions of the file and use the one you need (see the Example below ๐Ÿ‘€ โฌ‡๏ธ

Example

You can keep different versions stored at your Project Root or in a separate folder.

Keep things at the Project Root...


๐Ÿ“‚ Project
๐Ÿ“ƒ conftest.py
๐Ÿ“ƒ pylenium.json
๐Ÿ“ƒ local.pylenium.json
...


or put your custom ones in a different folder.
> Keep the original `pylenium.json` at the Project Root so the default behavior continues to work ๐Ÿ˜‰


๐Ÿ“‚ Project
๐Ÿ“ƒ conftest.py
๐Ÿ“ƒ pylenium.json
๐Ÿ“‚ config
๐Ÿ“ƒ local.pylenium.json
๐Ÿ“ƒ dev.pylenium.json
๐Ÿ“ƒ stage.config.json


> ๐Ÿ’ก You can name your custom Pylenium config files whatever you like, but they MUST be `.json` and have the same shape (aka schema) as the default `pylenium.json`

Finally, when you execute the tests, you can pass in which Pylenium config file to use for that run using the `--pylenium_json` argument:

bash
pytest --pylenium_json="local.pylenium.json"

pytest --pylenium_json="config/dev.pylenium.json"


Updated Logging

[206]

The other big change was around using `rich-click` (which is a combination of the `rich` and `click` packages) for cleaner and prettier logging and printing. With this change, a few other things were added:

- Two new, custom Log Levels: `COMMAND` and `USER`
- A global, Pylenium Logger instance that _can_ be used by the User if they choose

Log Levels

<table>
<tr>
<td>Name
<td>Level
<td>
<tr>
<td>CRITICAL
<td>50
<td>
<tr>
<td>ERROR
<td>40
<td>
<tr>
<td>WARNING
<td>30
<td>
<tr>
<td>USER
<td>25
<td>new
<tr>
<td>INFO
<td>20
<td>
<tr>
<td>COMMAND (new and default)
<td>15
<td>new, default
<tr>
<td>DEBUG
<td>10
<td>
</table>

If you are familiar with logging, then the above table is straightforward. If not, then all you really need to know about these levels is that you can set the Log Level when executing tests, and any logs at the specified level or higher will be captured.

For example, if you wanted to set the Log Level to see only logs at `INFO` and higher, you would do this:

bash
pytest --log-cli-level=INFO


> ๐Ÿ’ก The above command would ignore logs _below_ the `INFO` level. In other words, ignore the `COMMAND` and `DEBUG` logs.

COMMAND Level

The `COMMAND` Log Level is used by Pylenium for logging its commands in a cleaner and easier to parse format. You shouldn't use this level unless you _really want to_. Take a look at our `visit()` command to see it in action:

py
def visit(self, url: str) -> "Pylenium":
"""Navigate to the given URL.

Returns:
The current instance of Pylenium
"""
log.command("py.visit() - Visit URL: `%s`", url)
self.webdriver.get(url)
return self


> ๐Ÿ’ก Notice how the string uses the `%s` format and NOT the f-string format. This is intentional!

USER Level

The `USER` Log Level is meant for you! This is a convenient way for logging things if you don't want everything from the `INFO` level.

> ๐Ÿ’ก I highly recommend creating your own loggers, but sometimes something simple like this is all you need ๐Ÿ˜„

To take advantage of this level, use `log.this()`:

py
You can import this in any file
from pylenium.log import logger as log

Log this
def add_to_cart(item: str, quantity: int):
log.this("Adding %s %s to my cart", quantity, item)
...

Then call the function
add_to_cart("Charizard", 3)
>>> USER Adding 3 Charizard to my cart


You can also directly use `py.log`:

py
Log this
def add_to_cart(py: Pylenium, item: str, quantity: int):
py.log.this("Adding %s %s to my cart", quantity, item)
...

Then call the function
add_to_cart(py, "Charizard", 3)
>>> USER Adding 3 Charizard to my cart


Other Changes

- Add `Element.upload()` command (258)
- Add `Element.focus()` command (257)
- Resolve ReportPortal warnings from `pytest.ini` (255)
- Fix dependency conflicts with the `black` package (263)
- Fix outdated ReportPortal imports in `conftest.py` (268)
- Rename `Element.get_cookies()` to `Element.get_all_cookies()`

Page 1 of 7

ยฉ 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.