Selene

Latest version: v1.0.2

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

Scan your dependencies

Page 4 of 16

2.0.0b11

NEW: upgraded selenium to 4.4.3 & webdriver-manager to 3.8.3

BREAKING CHANGE: removed 'opera' support for shared.browser.config.browser_name

see reasons at:
- [Selenium Changelog for 4.3.0](https://github.com/SeleniumHQ/selenium/blob/31190f8edd801a2ead8ba3d49982cbdbc838885d/py/CHANGES#L22)
- [[🐛 Bug]: Opera Browser in Selenium 4 Usage](https://github.com/SeleniumHQ/selenium/issues/10835)

2.0.0b10

NEW: BREAKING CHANGE: removed deprecated selene.core.entity.Collection.:

- `caching(self)` in favor of `cashed(self)`
- `all_by(self, condition) -> Collection` in favor of `by(conditioin)`
- `filter_by(self, condition) -> Collection` in favor of `by(condition)`
- `find_by(self, condition) -> Element`
- `size(self) -> int` in favor of `__len__(self)`

2.0.0b9

NEW: `browser.all(selector).by(condition)` to filter collection

python
import examples.run_cross_platform.wikipedia_e2e_tests.utils.locators
from selene.support.shared import browser
from selene import have

browser.open('https://todomvc.com/examples/emberjs/')
browser.element('new-todo').type('a').press_enter()
browser.element('new-todo').type('b').press_enter()
browser.element('new-todo').type('c').press_enter()

examples.run_cross_platform.wikipedia_e2e_tests.utils.locators.by(have.text('b')).first.element('.toggle').click()

examples.run_cross_platform.wikipedia_e2e_tests.utils.locators.by(have.css_class('active')).should(have.texts('a', 'c'))
examples.run_cross_platform.wikipedia_e2e_tests.utils.locators.by(have.no.css_class('active')).should(have.texts('b'))


Hence, considering to deprecate:
- `collection.filtered_by(condition)` in favor of `collection.by(condition)`
- `collection.element_by(condition)` in favor of `collection.by(condition).first`

NEW: `collection.even` and `collection.odd` shortcuts

python
from selene.support.shared import browser
from selene import have

browser.open('https://todomvc.com/examples/emberjs/')

browser.element('new-todo').type('1').press_enter()
browser.element('new-todo').type('2').press_enter()
browser.element('new-todo').type('3').press_enter()

browser.all('todo-list>li').even.should(have.texts('2'))
browser.all('todo-list>li').odd.should(have.texts('1', '3'))


NEW: defaults for all params of `collection.sliced(start, stop, step)`

Now you can achieve more readable `collection.sliced(step=2)` instead of awkward `collection.sliced(None, None, 2)`

Remember that you still can use less readable but more concise `collection[::2]` ;)

DEPRECATED:

- selene.core.entity.SeleneElement
- you can use selene.core.entity.Element
- selene.core.entity.SeleneCollection
- you can use selene.core.entity.Collection
- selene.core.entity.SeleneDriver
- you can use selene.core.entity.Browser

NEW: BREAKING CHANGE: removed deprecated

- selene.browser module
- selene.browsers module
- selene.bys module
- selene.driver module
- selene.wait module
- selene.elements module
- selene.core.entity.Browser:
- .quit_driver(self) in favor of .quit(self)
- .wrap(self, webdriver) in favor of Browser(Config(driver=webdriver))
- .find(self, css_or_xpath_or_by: Union[str, tuple]) -> Element:
- in favor of .element(self, selector) -> Element
- .find_all(self, css_or_xpath_or_by: Union[str, tuple]) -> Collection:
- in favor of .all(self, selector) -> Collection
- .find_elements in favor of browser.driver.find_elements
- .find_element in favor of browser.driver.find_element
- selene.core.entity.Collection:
- .should(self, condition, timeout)
- in favor of selene.core.entity.Collection.should(self, condition)
with ability to customize timeout via collection.with_(timeout=...).should(condition)
- .should_each(self, condition, timeout)
- in favor of selene.core.entity.Collection.should_each(self, condition)
with ability to customize timeout via collection.with_(timeout=...).should_each(condition)
- .assure*(self, condition) -> Collection
- .should_*(self, condition) -> Collection
- selene.core.entity.Element:
- .should(self, condition, timeout)
- in favor of selene.core.entity.Element.should(self, condition)
with ability to customize timeout via element.with_(timeout=...).should(condition)
- .assure*(self, condition) -> Element
- .should_*(self, condition) -> Element
- .caching(self)
- .find(self, css_or_xpath_or_by: Union[str, tuple]) -> Element
- .find_all(self, css_or_xpath_or_by: Union[str, tuple]) -> Collection
- .parent_element(self) -> Element
- use .element('..') instead
- .following_sibling(self) -> Element
- use .element('./following-sibling::*') instead
- .first_child(self) -> Element
- use .element('./*[1]')) instead
- .scroll_to(self) -> Element
- use .perform(command.js.scroll_into_view) instead
- .press_down(self) -> Element
- use .press(Keys.ARROW_DOWN) instead
- .find_element(self, by, value)
- .find_elements(self, by, value)
- .tag_name(self)
- .text(self)
- .attribute(self, name)
- .js_property(self, name)
- .value_of_css_property(self, name)
- .get_attribute(self, name)
- .get_property(self, name)
- .is_selected(self)
- .is_enabled(self)
- .is_displayed(self)
- .location(self)
- .location_once_scrolled_into_view(self)
- .size(self)
- .rect(self)
- .screenshot_as_base64(self)
- .screenshot_as_png(self)
- .screenshot(self, filename)
- .parent(self)
- .id(self)

2.0.0b8

NEW: `selene.support._logging.wait_with(context, translations)`

Added selene.support._logging experimental module with «predefined recipe» of wait_decorator for easier logging of Selene waiting commands (yet riskier, cause everything marked as experimental is a subject to change).

Now, given added allure dependency to your project, you can configure logging Selene commands to Allure report as simply as:

python
from selene.support.shared import browser
from selene import support
import allure_commons

browser.config._wait_decorator = support._logging.wait_with(
context=allure_commons._allure.StepContext
)


... or implement your own version of StepContext – feel free to use [Alure's context manager](https://github.com/allure-framework/allure-python/blob/481ea54759b0d8f6aa083a9f70f66cca33cae67c/allure-python-commons/src/_allure.py#L151) as example or the one from Selene's [browser__config__wait_decorator_with_decorator_from_support_logging_test.py](https://github.com/yashaka/selene/tree/master/tests/integration/shared_browser/browser__config__wait_decorator_with_decorator_from_support_logging_test.py) test.

You also can pass a list of translations to be applied to final message to log, something like:

python
from selene.support.shared import browser
from selene import support
import allure_commons

browser.config._wait_decorator = support._logging.wait_with(
context=allure_commons._allure.StepContext,
translations=(
('browser.element', '$'),
('browser.all', '$$'),
)
)


But check the default value for this parameter, maybe you'll be fine with it;)

And remember, the majority of selene extensions from the support.* package, including its `_logging` module – are things you'd better implement on your side to be less dependent to 3rd party helpers;) Feel free to Copy&Paste it into your code and adjust to your needs.

2.0.0b7

- BREAKING_CHANGE: change type of config._wait_decorator to access entities, not just commands on them
- from `Callable[[F], F]`
- to `Callable[[Wait[E]], Callable[[F], F]]`
- i.e. now it should be not a simple decorator
that maps function F to a new F with for example added logging,
but it should be «decorator with parameter»
or in other words – a «decorator factory» function
that based on passed parameter of Wait type will return an actual decorator
to be applied to the main logic of waiting inside Waitfor_ method.
- This change will allow inside the decorator
to access entities (browser, element, element-collection),
for example, to log them too;)
- see examples at:
- simpler one: [examples/log_all_selene_commands_with_wait.py](https://github.com/yashaka/selene/tree/master/examples/log_all_selene_commands_with_wait.py)
- more «frameworkish» one: [examples/log_all_selene_commands_with_wait__framework](https://github.com/yashaka/selene/tree/master/examples/log_all_selene_commands_with_wait__framework)

2.0.0b6

- NEW: added "opera" and "edge" support for shared browser
- example:

python
from selene.support.shared import browser

browser.config.browser_name = 'opera'
browser.config.browser_name = 'edge'


- NEW: added config._wait_decorator
- decorating Waitfor_ method
- that is used when performing any element command
and assertion (i.e. should)
- hence, can be used to log corresponding commands with waits
and integrate with something like allure reporting;)
- prefixed with underscore, indicating that method is experimental,
and can be e.g. renamed, etc.
- see example at [examples/log_all_selene_commands_with_wait.py](https://github.com/yashaka/selene/tree/master/examples/log_all_selene_commands_with_wait.py)

- NEW: added config.click_by_js [420](https://github.com/yashaka/selene/issues/420)
- for usage like in:

python
from selene.support.shared import browser

browser.config.click_by_js = True
'''
if we would want to make all selene clicks to work via JS
as part of some CRAZY workaround, or maybe to make tester faster o_O :p
(it was a joke, nothing will be much faster :D with click via js)
'''

button = browser.element('btn').with_(click_by_js=True)
'''
to make all clicks for element('btn') to work via js
as part of some workaround ;)
'''

button.click()
...
button.click()

Page 4 of 16

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.