Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dvarrazzo/bromine
Pythonic web testing
https://github.com/dvarrazzo/bromine
Last synced: 22 days ago
JSON representation
Pythonic web testing
- Host: GitHub
- URL: https://github.com/dvarrazzo/bromine
- Owner: dvarrazzo
- License: mit
- Created: 2020-02-01T11:28:12.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-05-23T13:34:42.000Z (over 1 year ago)
- Last Synced: 2024-10-14T17:58:24.368Z (25 days ago)
- Language: Python
- Size: 54.7 KB
- Stars: 11
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Bromine: pythonic web testing
Bromine is a wrapper around [selenium] to allow writing testing in a terse and
*pythonic* rather that *java-esque* way.[selenium]: https://www.seleniumhq.org/
Selenium is cool: you register browser to a hub, you ask browsers from a hub,
you use the browser, and you put it back. It works like magic.Except if you want to use https. But who needs https these days?
Anyway, enough dissing well intentioned web testing systems. Let's talk bad
about bad testing system. You know what you have to do to wait for a page to
load after a get, and then check if an element is visible? The selenium docs
[will tell you](https://selenium-python.readthedocs.io/waits.html#explicit-waits):```python
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC# ...
driver.get("http://example.com")
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, "myDynamicElement"))
)
```I've been kind and I've stripped some boilerplate. If you are happy about
importing three objects from 4 levels of namespaces and create a wait object
and pass a 2-element tuple to the "convenience method"
`selenium.webdriver.support.expected_conditions.visibility_of_element_located`
for a thing you have to do pretty much every time you click on a link, please
stop reading here: type `pip install selenium` and off you go. The following
paragraph is only for people who think the above is unsatisfactory in Python.Still reading? Sure?
Well, I'll be honest: what I prefer to do is:
```python
import bromine
browser = bromine.Browser(driver)
element = browser.get("http://example.com/").wait(id='myDynamicElement')
```