GithubHelp home page GithubHelp logo

molosonic's Introduction

Molosonic

Molosonic is a Molotov extension to use a real browser in your Molotov tests.

Molosonic integrates Arsenic into the Molotov session, so one browser instance is launched per worker.

Molosonic was not release yet on PyPI, so to try it, make sure you have Python 3 and virtualenv and geckodriver in the PATH, then:

$ virtualenv .
$ bin/python setup.py develop

To make sure your setup works, try this example:

$ bin/molotov -w 5 --max-runs 1 examples/simple.py

It will run five browsers and interact with example.com

Once installed, you can use setup_browser and teardown_browser to create a browser instance.

Load test example:

from molosonic import setup_browser, teardown_browser
import molotov


@molotov.setup_session()
async def _setup_session(wid, session):
    await setup_browser(session)


@molotov.teardown_session()
async def _teardown_session(wid, session):
    await teardown_browser(session)


@molotov.scenario(1)
async def example(session):
    firefox = session.browser

    # go to example.com
    await firefox.get('http://example.com')

    # wait up to 5 seconds to get the h1 element from the page
    h1 = await firefox.wait_for_element(5, 'h1')

    # print the text of the h1 element
    print(await h1.get_text())

Check out Arsenic documentation for the available API.

To run 5 Firefox browsers in parallel, each one doing the test 10 times:

$ molotov -cxv --max-runs 10 -w 5 loadtest.py

molosonic's People

Contributors

tarekziade avatar

Stargazers

Stephen Donner avatar Pavel Savchenko avatar James Peres avatar Bruno Rocha avatar

Watchers

Peter deHaan avatar James Cloos avatar  avatar

Forkers

stephendonner

molosonic's Issues

add options

We shoulc surface options in setup_browser() so one may chose wich browser/engin to run

start() takes 1 positional argument but 2 were given

Seeing this locally when trying to run the example from the README:

# requirements.txt
molotov
git+https://github.com/tarekziade/molosonic.git@master
$ molotov -cxv --max-runs 1 -w 5 loadtest3.py

**** Molotov v1.6. Happy breaking! ****
Preparing 5 workers...
OK
TypeError('start() takes 1 positional argument but 2 were given',)
  File "/Users/pdehaan/dev/github/pdehaan/ensemble-loadtests/venv/lib/python3.6/site-packages/molotov/worker.py", line 89, in session_setup
    await self._session_setup(self.wid, session)
  File "loadtest3.py", line 7, in _setup_session
    await setup_browser(session)
  File "/Users/pdehaan/dev/github/pdehaan/ensemble-loadtests/venv/lib/python3.6/site-packages/molosonic/__init__.py", line 30, in setup_browser
    session.browser = await session._session.start()
  File "/Users/pdehaan/dev/github/pdehaan/ensemble-loadtests/venv/lib/python3.6/site-packages/molosonic/__init__.py", line 19, in start
    self.driver = await self.gecko.start(Client)
SUCCESSES: 0 | FAILURES: 0
*** Bye ***
from molosonic import setup_browser, teardown_browser
import molotov

@molotov.setup_session()
async def _setup_session(wid, session):
    await setup_browser(session)

@molotov.teardown_session()
async def _teardown_session(wid, session):
    await teardown_browser(session)

@molotov.scenario(1)
async def example(session):
    firefox = session.browser

    # go to example.com
    await firefox.get('http://example.com')

    # wait up to 5 seconds to get the h1 element from the page
    h1 = await firefox.wait_for_element(5, 'h1')

    # print the text of the h1 element
    print(await h1.get_text())

Unable to install molosonic

The README says:

$ pip install molosonic

... but when I try that locally, I get the following:

$ python --version # Python 3.6.0

$ pip install molosonic
Collecting molosonic
  Could not find a version that satisfies the requirement molosonic (from versions: )
No matching distribution found for molosonic

Error when running ./examples/simple.py w/ Firefox 60

Re: https://github.com/tarekziade/molosonic/blob/master/examples/simple.py
I'm using a venv w/ Python 3.6 and installing molosonic via Git, and get a pretty verbose debug dump when trying to run the /examples/simple.py file via $ molotov -c --verbose -p 1 -d 1 -w 1 ./simple.py:

$ molotov -c --verbose -p 1 -d 1 -w 1 ./simple.py

**** Molotov v1.6. Happy breaking! ****
Preparing 1 worker...
OK
1524257197820| Fgeckodriver| WORINFO: 0 geckodriver 0.19.1
1524257197825	geckodriver	INFO	Listening on 127.0.0.1:58601
2018-04-20 13:46.37 request                        body={"desiredCapabilities": {"browserName": "firefox", "marionette": true, "acceptInsecureCerts": true}} method=POST url=http://localhost:58601/session
1524257198092	mozrunner::runner	INFO	Running command: "/Applications/Firefox.app/Contents/MacOS/firefox-bin" "-marionette" "-profile" "/var/folders/qc/g_f0szh95k1fzph34rhmf5jw0000gp/T/rust_mozprofile.iqxfjXasTK36"
Unable to read VR Path Registry from /Users/pdehaan/Library/Application Support/OpenVR/.openvr/openvrpaths.vrpath
Unable to read VR Path Registry from /Users/pdehaan/Library/Application Support/OpenVR/.openvr/openvrpaths.vrpath
2018-04-20 13:46:39.755 plugin-container[60772:30298693] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x7e3b, name = 'com.apple.tsm.portname'
See /usr/include/servers/bootstrap_defs.h for the error codes.
1524257200334| FMarionette | WORINFO: 1 Listening on port 58609
1524257200390	Marionette	WARN	TLS certificate errors will be ignored for this session
2018-04-20 13:46.40 response                       body={"desiredCapabilities": {"browserName": "firefox", "marionette": true, "acceptInsecureCerts": true}} data={'value': {'sessionId': '1ab8eea7-89b7-984e-8185-54dbb5813741', 'capabilities': {'acceptInsecureCerts': True, 'browserName': 'firefox', 'browserVersion': '60.0', 'moz:accessibilityChecks': False, 'moz:headless': False, 'moz:processID': 60771, 'moz:profile': '/var/folders/qc/g_f0szh95k1fzph34rhmf5jw0000gp/T/rust_mozprofile.iqxfjXasTK36', 'moz:useNonSpecCompliantPointerOrigin': False, 'moz:webdriverClick': True, 'pageLoadStrategy': 'normal', 'platformName': 'darwin', 'platformVersion': '17.5.0', 'rotatable': False, 'timeouts': {'implicit': 0, 'pageLoad': 300000, 'script': 30000}}}} method=POST response=<ClientResponse(http://127.0.0.1:58601/session) [200 OK]>
<CIMultiDictProxy('Connection': 'close', 'Content-Type': 'application/json; charset=utf-8', 'Cache-Control': 'no-cache', 'Content-Length': '551', 'Date': 'Fri, 20 Apr 2018 20:46:40 GMT')>
 url=http://localhost:58601/session
2018-04-20 13:46.40 request                        body=None method=DELETE url=http://localhost:58601/session/1ab8eea7-89b7-984e-8185-54dbb5813741
1524257200515	addons.xpi	WARN	Exception running bootstrap method shutdown on [email protected]: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIObserverService.removeObserver]"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: resource://activity-stream/lib/SnippetsFeed.jsm :: uninit :: line 185"  data: no] Stack trace: uninit()@resource://activity-stream/lib/SnippetsFeed.jsm:185
onAction()@resource://activity-stream/lib/SnippetsFeed.jsm:201
_middleware/</<()@resource://activity-stream/lib/Store.jsm:49
Store/this[method]()@resource://activity-stream/lib/Store.jsm:28
uninit()@resource://activity-stream/lib/Store.jsm:151
uninit()@resource://activity-stream/lib/ActivityStream.jsm:294
uninit()@resource://gre/modules/addons/XPIProvider.jsm -> jar:file:///Applications/Firefox.app/Contents/Resources/browser/features/[email protected]!/bootstrap.js:73
shutdown()@resource://gre/modules/addons/XPIProvider.jsm -> jar:file:///Applications/Firefox.app/Contents/Resources/browser/features/[email protected]!/bootstrap.js:169
callBootstrapMethod()@resource://gre/modules/addons/XPIProvider.jsm:4436
observe()@resource://gre/modules/addons/XPIProvider.jsm:2287
GeckoDriver.prototype.quit()@driver.js:3300
despatch()@server.js:293
execute()@server.js:267
onPacket/<()@server.js:242
onPacket()@server.js:241
_onJSONObjectReady/<()@transport.js:500
[GFX1-]: Receive IPC close with reason=AbnormalShutdown
2018-04-20 13:46.40 response                       body=None data={'value': {}} method=DELETE response=<ClientResponse(http://127.0.0.1:58601/session/1ab8eea7-89b7-984e-8185-54dbb5813741) [200 OK]>
<CIMultiDictProxy('Connection': 'close', 'Content-Type': 'application/json; charset=utf-8', 'Cache-Control': 'no-cache', 'Content-Length': '13', 'Date': 'Fri, 20 Apr 2018 20:46:40 GMT')>
 url=http://localhost:58601/session/1ab8eea7-89b7-984e-8185-54dbb5813741
SUCCESSES: 0 | FAILURES: 0 | WORKERS: 1
*** Bye ***


$ cat requirements.txt
molotov
git+https://github.com/tarekziade/molosonic.git@master


$ python --version # Python 3.6.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.