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.9.tar.gz.

File metadata

  • Download URL: robotframework-seleniumtestability-0.0.9.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.4.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15

File hashes

Hashes for robotframework-seleniumtestability-0.0.9.tar.gz
Algorithm Hash digest
SHA256 3bc76d8451f89f1e84a8f044c28e7c0726375b5f4e96f7181bdd1ad218b8992c
MD5 a01553899c83a796b15718715d66fae0
BLAKE2b-256 c21eb241252fcb532f0fb04ab349449dac799d7cb3594f6f6ceb583c1813be3a

See more details on using hashes here.

Supported by

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