Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dsymbol/selench
Selenium wrapper for Python
https://github.com/dsymbol/selench
selenium
Last synced: 3 months ago
JSON representation
Selenium wrapper for Python
- Host: GitHub
- URL: https://github.com/dsymbol/selench
- Owner: dsymbol
- License: mit
- Created: 2022-05-17T15:12:16.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-29T01:00:39.000Z (5 months ago)
- Last Synced: 2024-11-09T13:20:27.790Z (3 months ago)
- Topics: selenium
- Language: Python
- Homepage: https://dsymbol.github.io/selench
- Size: 70.3 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Selench
Selench is a wrapper that simplifies the use of the Selenium library.
It provides a more concise syntax that makes the code more readable and easier to understand.### Key Features
- Concise syntax
- Less imports
- Elements have an explicit wait time by default
- Simple expected_conditions implementation as expect
- Element type detection ( CSS & XPATH )## Installation
To install the library, use pip:
```bash
pip install selench
```Alternatively, install the latest directly from the GitHub repository:
```bash
pip install git+https://github.com/dsymbol/selench.git
```## Examples
Navigate to DuckDuckGo and search for 'Hello World!'
```py
from selench import Selench, Keysdriver = Selench()
driver.get('https://duckduckgo.com')
driver.element('[name=q]').send_keys('Hello World!', Keys.ENTER)
driver.quit()
```Using PyTest: navigate to DuckDuckGo and search for 'github' assert titles contain 'github'
```py
from selench import Selench, Keys
import pytest@pytest.fixture
def driver():
driver = Selench()
yield driver
driver.quit()def test_ddg_search_query(driver):
keyword = 'github'
driver.get('https://duckduckgo.com/')
driver.element('[name=q]').send_keys(keyword, Keys.ENTER)
driver.expect.page_title_to_contain(keyword)
titles = driver.elements('a[data-testid=result-title-a] span')for title in titles:
assert keyword in title.text.lower()
```