Selenium core for Python
Project description
Selenium CORE for Python
Introduction
It's a library with core functions simplifying work with Selenium-controlled applications.
This package is based on Aquality Selenium CORE for .NET and provides a set of methods related to the most common actions performed with elements. So you shouldn't have a lot of difficulties with this solution if you interacted with Aquality Selenium CORE.
To simplify overriding of implementations this solution uses Dependency Injection.
Supported Python Versions
- Python 3.7-3.9
Installation
If you have pip on your system, you can simply install or upgrade the Python bindings:
pip install py-selenium-auto-core
Alternately, you can download the source distribution from PyPI, unarchive it, and run:
python setup.py install
Quick start
- Setup Dependency Injection container using Startup
The simplest way is to create your own Services class extended from abstract CoreServices with the following simple signature:
class BrowserService(CoreService):
@staticmethod
def is_application_started() -> bool:
return CoreService._is_application_started()
@staticmethod
def application() -> YourApplication:
return CoreService.get_application(lambda service: BrowserService._start_application(service))
@staticmethod
def service_provider() -> ServiceProvider:
return CoreService.get_service_provider(lambda service: BrowserService.application())
@staticmethod
def _start_application(service_provider: ServiceProvider):
... # your implementation
If you need to register your own services / rewrite the implementation, you need override Startup and implement BrowserServices like in example below:
class BrowserService(CoreService):
_browser_startup_container: CustomStartup = CustomStartup()
@staticmethod
def is_application_started() -> bool:
return CoreService._is_application_started()
@staticmethod
def application() -> Application:
return CoreService.get_application(lambda service: your_implementation, lambda: BrowserService._browser_startup_container.configure_services(lambda service: BrowserService.application()))
@staticmethod
def service_provider() -> ServiceProvider:
return CoreService.get_service_provider(lambda service: BrowserService.application())
@staticmethod
def _start_application(service_provider: ServiceProvider):
... # your implementation
class CustomStartup(Startup):
@staticmethod
def configure_services(application_provider: Callable, settings: JsonSettingsFile = None) -> ServiceProvider:
service_provider = Startup.configure_services(application_provider, settings)
# your implementation service_provider.timeout_configuration.override(Singleton(TimeoutConfiguration, service_provider.settings_file))
return service_provider
- Work with Application via the implemented BrowserServices or via element services
All the services could be resolved from the Dependency Injection container via ServiceProvider
BrowserServices.application().driver.find_element(ELEMENT).click()
BrowserServices.service_provider().conditional_wait().wait_for_driver(
lambda driver: len(driver.find_elements(Locator(By.XPATH, "//*"))) > 0
)
License
Library's source code is made available under the Apache 2.0 license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for py-selenium-auto-core-0.4.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3fddef4c453da96f5d6e7e29080ea56452983ce849d67e9437391ee70dc7157 |
|
MD5 | 5e8e6c596091a1c48629e373cb5b847f |
|
BLAKE2b-256 | 4b298a29c9ed7aa416f6b0e70242287e097f8fc50d7c88ab49ff9241783eaa04 |
Hashes for py_selenium_auto_core-0.4.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6512e5068c0433c54f365d269e54fc738ec85b1eb7dfe5a6cd158c26263c14c0 |
|
MD5 | 4d6b7a1ecc2143a20185f62df84b1bba |
|
BLAKE2b-256 | 442c56f6d238ba6cb0d7b88d0f418c913af10e5727b1da82b4b6d43138d0658f |