Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/davidemoro/play_selenium
pytest-play plugin that let you drive a browser with Selenium/Splinter
https://github.com/davidemoro/play_selenium
pytest python selenium splinter testing
Last synced: about 2 months ago
JSON representation
pytest-play plugin that let you drive a browser with Selenium/Splinter
- Host: GitHub
- URL: https://github.com/davidemoro/play_selenium
- Owner: davidemoro
- License: apache-2.0
- Created: 2019-01-22T12:55:34.000Z (almost 6 years ago)
- Default Branch: develop
- Last Pushed: 2019-06-26T12:03:51.000Z (over 5 years ago)
- Last Synced: 2024-11-15T03:59:28.878Z (about 2 months ago)
- Topics: pytest, python, selenium, splinter, testing
- Language: Python
- Homepage: https://github.com/pytest-dev/pytest-play
- Size: 41 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGES.rst
- License: LICENSE
Awesome Lists containing this project
README
=============
play_selenium
=============.. image:: https://travis-ci.org/davidemoro/play_selenium.svg?branch=master
:target: https://travis-ci.org/davidemoro/play_selenium
:alt: See Build Status on Travis CI.. image:: https://readthedocs.org/projects/play_selenium/badge/?version=latest
:target: http://play_selenium.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status.. image:: https://codecov.io/gh/davidemoro/play_selenium/branch/master/graph/badge.svg
:target: https://codecov.io/gh/davidemoro/play_seleniumpytest-play plugin driving browsers using Selenium/Splinter under the hood.
Selenium grid compatible and implicit auto wait actions for more robust scenarios with less pain.More info and examples on:
* pytest-play_, documentation
* cookiecutter-qa_, see ``pytest-play`` in action with a working example if you want to start hackingBrowser based commands
----------------------Browser based commands here.
``play_selenium`` supports by default browser interactions. For example it can be used for running selenium splinter_ scenarios driving your browser for your UI test or system tests.``play_selenium`` is also your friend when page object approach (considered best practice) is not possible. For example:
* limited time, and/or
* lack of programming skillsInstead if you are interested in a page object pattern have a look at pypom_form_ or pypom_.
``play_selenium`` supports automatic waiting that should help to keep your tests more reliable with implicit waits before
moving on. By default it waits for node availability and visibility but it supports also some wait commands and
wait until a given Javascript expression is ok. So it is at the same time user friendly and flexible.
Conditional commands (Javascript)
=================================Based on a browser level expression (Javascript)::
- type: clickElement
provider: selenium
locator:
type: css
value: body
condition: "'$foo' === 'bar'"Supported locators
==================Supported selector types:
* css
* xpath
* tag
* name
* text
* id
* valueOpen a page
===========With parametrization::
- type: get
provider: selenium
url: "$base_url"or with a regular url::
- type: get
provider: selenium
url: https://google.comPause
=====This command invokes a javascript expression that will
pause the execution flow of your commands::- type: pause
provider: selenium
waitTime: 1500If you need a pause/sleep for non UI tests you can use the
``sleep`` command provided by the play_python_ plugin.Click an element
================
::- type: clickElement
provider: selenium
locator:
type: css
value: bodyFill in a text
==============
::- type: setElementText
provider: selenium
locator:
type: css
value: input.title
text: text valueInteract with select input elements
===================================Select by label::
- type: select
provider: selenium
locator:
type: css
value: select.city
text: Turinor select by value::
- type: select
provider: selenium
locator:
type: css
value: select.city
value: '1'Eval a Javascript expression
============================::
- type: eval
provider: selenium
script: alert('Hello world!')Create a variable starting from a Javascript expression
=======================================================The value of the Javascript expression will be stored in
``play.variables`` under the name ``count``::- type: storeEval
provider: selenium
variable: count
script: document.getElementById('count')[0].textContentAssert if a Javascript expression matches
=========================================If the result of the expression does not match an ``AssertionError``
will be raised and the test will fail::- type: verifyEval
provider: selenium
value: '3'
script: document.getElementById('count')[0].textContentVerify that the text of one element contains a string
=====================================================If the element text does not contain the provided text an
``AssertionError`` will be raised and the test will fail::- type: verifyText
provider: selenium
locator:
type: css
value: ".my-item"
text: a textSend keys to an element
=======================All ``selenium.webdriver.common.keys.Keys`` are supported::
- type: sendKeysToElement
provider: selenium
locator:
type: css
value: ".confirm"
text: ENTERSupported keys::
KEYS = [
'ADD', 'ALT', 'ARROW_DOWN', 'ARROW_LEFT', 'ARROW_RIGHT',
'ARROW_UP', 'BACKSPACE', 'BACK_SPACE', 'CANCEL', 'CLEAR',
'COMMAND', 'CONTROL', 'DECIMAL', 'DELETE', 'DIVIDE',
'DOWN', 'END', 'ENTER', 'EQUALS', 'ESCAPE', 'F1', 'F10',
'F11', 'F12', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8',
'F9', 'HELP', 'HOME', 'INSERT', 'LEFT', 'LEFT_ALT',
'LEFT_CONTROL', 'LEFT_SHIFT', 'META', 'MULTIPLY',
'NULL', 'NUMPAD0', 'NUMPAD1', 'NUMPAD2', 'NUMPAD3',
'NUMPAD4', 'NUMPAD5', 'NUMPAD6', 'NUMPAD7', 'NUMPAD8',
'NUMPAD9', 'PAGE_DOWN', 'PAGE_UP', 'PAUSE', 'RETURN',
'RIGHT', 'SEMICOLON', 'SEPARATOR', 'SHIFT', 'SPACE',
'SUBTRACT', 'TAB', 'UP',
]Wait until a Javascript expression matches
==========================================Wait until the given expression matches or raise a
``selenium.common.exceptions.TimeoutException`` if takes too time.At this time of writing there is a global timeout (20s) but in future releases
you will be able to override it on command basis::- type: waitUntilCondition
provider: selenium
script: document.body.getAttribute('class') === 'ready'Wait for element present in DOM
===============================Present::
- type: waitForElementPresent
provider: selenium
locator:
type: css
value: bodyor not present::
- type: waitForElementPresent
provider: selenium
locator:
type: css
value: body
negated: trueWait for element visible
========================Visible::
- type: waitForElementVisible
provider: selenium
locator:
type: css
value: bodyor not visible::
- type: waitForElementVisible
provider: selenium
locator:
type: css
value: body
negated: trueAssert element is present in DOM
================================An ``AssertionError`` will be raised if assertion fails.
Present::
- type: assertElementPresent
provider: selenium
locator:
type: css
value: div.elemor not present::
- type: assertElementPresent
provider: selenium
locator:
type: css
value: div.elem
negated: trueAssert element is visible
=========================An ``AssertionError`` will be raised if assertion fails.
Present::
- type: assertElementVisible
provider: selenium
locator:
type: css
value: div.elemor not present::
- type: assertElementVisible
provider: selenium
locator:
type: css
value: div.elem
negated: true
-------``play_selenium`` tweets happens here:
* `@davidemoro`_
.. _`pytest-play`: https://github.com/davidemoro/pytest-play
.. _`pypom_form`: http://pypom-form.readthedocs.io/en/latest/
.. _`splinter`: https://splinter.readthedocs.io/en/latest/
.. _`pypom`: http://pypom.readthedocs.io/en/latest/
.. _`@davidemoro`: https://twitter.com/davidemoro
.. _`cookiecutter-qa`: https://github.com/davidemoro/cookiecutter-qa
.. _`play_python`: https://github.com/davidemoro/play_python