Skip to main content

SeleniunTestability library that helps speed up tests withasyncronous evens

Project description

robotframework-seleniumtestability

Extension library for SeleniumLibrary that provides either manual or automatic waiting asyncronous events within SUT.

This is accomplished by utilizing following 2 libraries. First one provides an API and second one provides bindings.

Installation

pip install robotframework-seleniumtestability

Usage

Initialize library

Library         SeleniumLibrary
Library         SeleniumTestability     enable_implicit_wait=True

If enable_implicit_wait is set to true, just before a selenium library keyword is executed, SeleniumTestability library will wait until testability.js api call returns. Example:

  Click Element   id:button_that_triggers_ajax_request
  Click Element   id:some_other_element

In above example, second Click Element keyword wont be executed before action triggered by the button is finished.

If the enable_implicit_wait is set to false, user needs to call Wait For Testability Ready keyword manually. Example:

  Click Element   id:button_that_triggers_ajax_request
  Wait For Testability Ready
  Click Element   id:some_other_element

Instrumenting the SUT

Because functionality provided by SeleniumTestability relies on predefined javascript api's to be present in the SUT (eg, your web application) before it actually works, SUT itself must be instrumented. There are few options to do that:

Instrument Browser-keyword

After your tests have loaded the webpage you are testing, call Instrument Browser keyword to inject all required javascript code into the sut.

Do note: if page is reloaded or your tests scripts navigate out from the page, you need re-instrument the browser again. This should not be the case with single page applications as typically the javascript context remains the same.

Direct integration.

Inject api.js & bindings.js from testability folder into your application's js bundle and call instrumentBrowser() javascript at the startup. This procedure varies a lot from due to various tooling. Talk to your developers about the possibility.

This could also be archived by MITM Proxy.

Benefit of integration testability api into the application directly is about timing. If the application initialization triggers any asyncronous actions, these are already being detected and there's no need for waiting in the begining for a good state when your testing script can start.

Current Features

  • Can detect setTimeout & setImmediate calls and wait for them.
  • Can detect fetch() call and wait for it to finish
  • Can detect XHR requests and wait for them to finish
  • Can detect CSS Animations and wait form them to finish
  • Can detect CSS Transitions and wait form them to finish

Do note that CSS animations and transitions do not work properly in Chrome.

Documentation

TODO:

  • Support ES6 Promises
  • Support fetching browser logs from Firefox.
  • Investigate on possibility of polyfilling css animations and transitions in Chrome.
  • Addon possibility for bindings. For example, one might want to extend the functionality to support asyncronous actions of any web framework (like Angular, React and what not)
  • Implement other Keywords that might be useful for testing purposes:
    • Remove Element From DOM

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

File details

Details for the file robotframework-seleniumtestability-0.0.10.tar.gz.

File metadata

  • Download URL: robotframework-seleniumtestability-0.0.10.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.3

File hashes

Hashes for robotframework-seleniumtestability-0.0.10.tar.gz
Algorithm Hash digest
SHA256 10c67b91921070e5f7332f24fb66feeb5b2f7d2a205a720fd45e1f56b21fb48d
MD5 ac9b6361960998e168e8c5226f479a5e
BLAKE2b-256 076abed8ce593ed52354fc17597774543de592b998ba95a25c9b3fe5315f096c

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page