robotframework-angularjs


Namerobotframework-angularjs JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/MarketSquare/robotframework-angularjs
SummaryAn AngularJS/Angular extension to Robotframework's SeleniumLibrary
upload_time2024-02-23 04:27:05
maintainer
docs_urlNone
authorZephraph, Ed Manlove
requires_python
licenseApache License 2.0
keywords robotframework testing testautomation angular selenium webdriver
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            AngularJSLibrary - robotframework-angularjs
===========================================
An AngularJS and Angular extension to Robotframework's SeleniumLibrary.
AngularJSLibrary primarily provides functionality to deal with **waiting** and
thus timing issue when testing Angular based websites. The library does this by
providing first an implicit wait and, subsequently, an explicit keyword for
waiting on angular.

About this library
------------------
The AngularJSLibrary, despite the name including JS, supports testing against
both Angular 2.0+ (known as simply Angular) and Angular 1.0 (also known as
Angular JS).

This library is considered mature and feature complete. Ongoing support is
provided through the Robot Framework community Slack. Thus it may appear
to be abandoned or neglected for which it is not.

**Please carefully read through this README in its entirety**. It covers how
to configure and import the library into your test scripts, use and understand
its key functionality, as well as troubleshooting and debugging information.

Installation
------------
To install **AngularJSLibrary**, run:

.. code:: bash

    pip install robotframework-angularjs


Alternatively, to install from source:

.. code:: bash

    python setup.py install


Identifying the Angular root element
------------------------------------
Prior to importing the library, one must identify the Angular root element or root
component. For more information about 

Here are a few examples of Angular sites and their corresponding root elements or
components. The first example is from the `AngularJS.org PhoneCat tutorial <http://angular.github.io/angular-phonecat/step-14/app>`_.
The base html code is

.. code::  html

    <html lang="en" ng-app="phonecatApp">
      <head>
        <!-- ... -->
      </head>
      <body>
    
        <div class="view-container">
          <div ng-view class="view-frame"></div>
        </div>
    
      </body>
    </html>

In the PhoneCat tutorial the html element with the ng-app attribute is the root
element. Thus for this website the root selector would be :code:`[ng-app]`. The
next example is the `Getting started with Angular tutorial <https://angular.io/start>`_
on angular.io site. It's main html looks like

.. code::  html

    <!DOCTYPE html>
    <html lang="en">
      <head>
        <!-- ... -->
      </head>
      <body>
        <app-root></app-root>
      </body>
    </html>

Here the root component is the app-root element and thus the root selector for
this website would be :code:`app-root`. The last example is the `example tab of
the Dialog UI component <https://material.angular.io/cdk/dialog/examples>`_
within the Angular.io Component Dev Kit (CDK).

.. code::  html

    <!DOCTYPE html><html lang="en-US"><head>
    <!-- ... -->
    </head>
    

    <body class="docs-app-background">
      <material-docs-app></material-docs-app>
      <!-- ... -->
    
    </body></html>

The root component for the Dialog component example page is the material-docs-app
element. The root selector will be :code:`material-docs-app`.

Now we will use the root selector when we import the library.

Importing the library
---------------------
The proper name for importing the library is :code:`AngularJSLibrary`. You will
need to include the SeleniumLibrary **before** you import the AngularJSLibrary.
The first of two library options is `root_selector`. So using our first example,
the PhoneCat tutorial from AngularJS.org above, our import may look like,

.. code::  robotframework

    *** Settings ***
    Library    SeleniumLibrary
    Library    AngularJSLibrary    root_selector=[ng-app]
    
    *** Test Cases ***
    Search Through The Phone Catalog For Samsung Phones
        Open Browser  http://angular.github.io/angular-phonecat/step-14/app  Chrome
        Input Text  //input  Samsung
        Click Link  Samsung Galaxy Tab™
        Element Text Should Be    css:phone-detail h1    Samsung Galaxy Tab™

As the default value for the root_selector argument is :code:`[ng-app]`, for
the PhoneCat tutorial we did not need to specify the root_selector and could
have written the Library import as

.. code::  robotframework

    *** Settings ***
    Library    SeleniumLibrary
    Library    AngularJSLibrary
    
    *** Test Cases ***
    Search Through The Phone Catalog For Samsung Phones
        Open Browser  http://angular.github.io/angular-phonecat/step-14/app  Chrome
        Input Text  //input  Samsung
        Click Link  Samsung Galaxy Tab™
        Element Text Should Be    css:phone-detail h1    Samsung Galaxy Tab™

*If you get an "Unable to find root selector ..." error* then you should re-check
your root_selector. Note that unlike locators used with the SeleniumLibrary the
root_selector **should not** contain the css locator prefix.

The second library option, ignore_implicit_angular_wait, is a flag which when
set to True the AngularJS Library will not wait for Angular $timeouts nor
$http calls to complete when finding elements by locator. The default value is
False.

*If the application under test starts on a non angular page,* for example a
login page that is not angular which leads into an angular app, then one should
start with the implicit angular wait turned off. For example,

.. code::  robotframework

    *** Settings ***
    Library    SeleniumLibrary
    Library    AngularJSLibrary    ignore_implicit_angular_wait=True
    
    *** Test Cases ***
    Login Into Non Angular Page
        # ...

Usage of the Waiting functionality
----------------------------------
The AngularJS Library provides two types of waiting: a built-in implicit wait
that automatically waits when using a locator strategy and then an explicit
keyword that one calls out or writes into their script. In the tutorial and
examples above the scripts there aren't any expicit wait calls. Here instead
the script is relying on the implicit wait which by default is turned on.
This means as soon as you import the library you will have waiting enabled.

This can be demostrated by importing the library with the implicit wait turned
off and using instead the library's explicit `Wait For Angular` keyword.

.. code::  robotframework

    *** Settings ***
    Library    SeleniumLibrary
    Library    AngularJSLibrary    ignore_implicit_angular_wait=True
    
    *** Test Cases ***
    Search Through The Phone Catalog For Samsung Phones
        Open Browser  http://angular.github.io/angular-phonecat/step-14/app  Chrome
        Wait For Angular
        Input Text  //input  Samsung
        Wait For Angular
        Click Link  Samsung Galaxy Tab™
        Wait For Angular
        Element Text Should Be    css:phone-detail h1    Samsung Galaxy Tab™

With the implicit wait functionality it is expected that most of the situations
where waiting is needed will be handled "automatically" by this "hidden" implicit
wait. Thus if one examined your test case they would not see many, if any,
`Wait For Angular` keywords but instead would see actions keywords with no
"waiting" keywords in between actions. There are times, though, when one needs to
explicitly call out to wait for angular. For example when using a SeleniumLibrary
keyword that does not use a locator strategy, like :code:`Alert Should Be Present`
and :code:`Page should contain`, or if you use webelement.

In addition to the option to turn off the implicit wait on library import, you
may turn it off using the :code:`Set Ignore Implicit Angular Wait` keyword with
an argument of :code:`${True}`. 


Understanding and verifying the angular waits
---------------------------------------------
Although the waits seem like "Magic" they are not. Let's look into how the
waits are implimented and work to gain insight as to how they work. The waits,
both the implicit and explicit, poll what I call the "angular queue".
Technically it is checking that angular has "finished rendering and has no
outstanding $http or $timeout calls". It does this by checking the
`notifyWhenNoOutstandingRequests` function for AngularJS applications. For
Angular applications the library is checking the `isStable` function on the
Angular Testibility service.

This can be seen within the log file by setting the loglevel to DEBUG or TRACE.
Rerunning the PhoneCat demo (:code:`robot --loglevel DEBUG demo_phonecat.robot`)
one should see in the log file

.. code::  robotframework

    20:01:04.658	INFO	Typing text 'Samsung' into text field '//input'.	
    20:01:04.658	DEBUG	POST http://localhost:50271/session/f75e7aaf5a00c717ae5e4af34a6ce516540611dae4b7f6079ce1a753c308cde2/execute/sync {"script": "...snip..."]}	
    20:01:04.661	DEBUG	http://localhost:50271 "POST /session/f75e7aaf5a00c717ae5e4af34a6ce516540611dae4b7f6079ce1a753c308cde2/execute/sync HTTP/1.1" 200 14	
    20:01:04.661	DEBUG	Remote response: status=200 | data={"value":true} | headers=HTTPHeaderDict({'Content-Length': '14', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})	
    20:01:04.661	DEBUG	Finished Request	

For space reasons I snipped out the core script on the POST execute/sync line.
One should see these lines repeated several times over. This is the polling the
library is doing to see if the application is ready to test. It will repeat
this query till either it returns true or it will repeat till the "give up"
timeout. If it gives up, it will silently and gracefully fail continuing onto
the actions it was waiting to perform. It is important for the user of this
library to see and understand, at a basic level, this functionality. As the
primary usage are these implicit, and thus hidden, waits it is key to see how
to check the library is operating properly and when it is waiting.

*When using the AngularJS Library, if all waits timeout then the AngularJS
Library may not wait properly with that application under test.* This,
recalling all previously outlined information, is telling you that the
Angular app is constantly busy. This can happen depending on how the angular
application is designed. It may also affect only a portion of the application
so it is important to test out various parts of the application.

Further debugging techniques
----------------------------
In addition to using the AngularJS Library, one can use the Browser's DevTools
as a way to test out and demonstrate the core operation of the library against
an application. To be clear, this is not library code but similar Javascript
code which one uses outside of robot to exhibit, to a dev team for example,
what the library is seeing when it querys the application. When viewing the
application under test open the DevTools, preferably under Chrome, and on the
Console tab type the following,

If the application is built with AngularJS or Angular 1.x then the script is

.. code::  javascript

    var callback = function () {console.log('*')}
    var el = document.querySelector('[ng-app]');
    var h = setInterval(function w4ng() {
        console.log('.');
        try {
            angular.element(el).injector().get('$browser').
                notifyWhenNoOutstandingRequests(callback);
        } catch (err) {
          console.log(err.message);
          callback(err.message);
        }
      }, 10);

For Angular v2+ then the script is

.. code::  javascript

    var callback = function () {console.log('*')}
    var el = document.querySelector('material-docs-app');
    var h = setInterval(function w4ng() {
        console.log('.');
        try {
            var readyToTest = window.getAngularTestability(el).isStable();
        } catch (err) {
          console.log(err.message);
          callback(err.message);
        }
        if (!readyToTest) {
          callback()
        } else {
          console.log('.');
        }
      }, 10);

This will display a :code:`.` when "stable". Otherwise it will show a :code:`*`
when "busy". To shut down the javascript interval and stop this script type on
the console prompt :code:`clearInterval(h);`. [Chrome Browser is preferred
because repeated output within its DevTools console will be displayed as a
single line with a count versus a new line for each output making it much
easier to see and read.] I have personally used this myself both in developing
this library as well as demonstrating to various Angular developers how a
design/implementation is blocking testability.

Additional Angular Specific Locator Strategies
-------------------------------------------------
**Note: It is no longer recommended to use these angular specific locator
strategies. Although functional, the SeleniumLibrary locator strategies are more
than sufficient and in most cases easier to use then these strategies. For backward
compatablity reasons these will be left in but it is strongly recommended not to
use.**

The library provides three new locator strategies, including ``binding``,
``model``, and ``repeater``.

For example, you can look for an Angular ng-binding using

.. code::  robotframework

    Get Text  binding={{greeting}}


or by using partial match

.. code::  robotframework

    Get Text  binding=greet


or by simply using the binding {{…}} notation

.. code::  robotframework

    Get Text  {{greeting}}


One can also find elements  by model

.. code::  robotframework

    Input Text  model=aboutbox  Something else to write about

    
.. role:: rf(code)
   :language: robotframework

Finally there is the strategy of find by repeat. This takes the general form of :rf:`repeater=some ngRepeat directive@row[n]@column={{ngBinding}}`. Here we specify the directive as well as the row, an zero-based index, and the column, an ngBinding. Using this full format will return, if exists the element matching the directive, row and column binding.  One does not need to specify the row and column but can specify either both, one or the other or neither. In such cases the locator may return  list  of elements or even a list of list of elements. Also the ordering of row and column does not matter; using :rf:`repeater=baz in days@row[0]@column=b` is the same as :rf:`repeater=baz in days@column=b @row[0]`.


Getting Help
------------
If you need help with AngularJSLibrary, SeleniumLibrary, or Robot Framework usage, please reach out within the Robot Framework community `Slack <https://slack.robotframework.org/>`_.

    
Keyword Documentation
---------------------
The keyword documentation can be found on the `Github project page <https://marketsquare.github.io/robotframework-angularjs/>`_.


Testing
-------
For information on how we test the AngularJSLibrary see the `Testing.rst <https://github.com/Selenium2Library/robotframework-angularjs/blob/master/TESTING.rst>`_ file.


References
----------

`SeleniumLibrary <https://github.com/robotframework/SeleniumLibrary>`_: Web testing library for Robot Framework

`Protractor <http://www.protractortest.org>`_: E2E test framework for Angular apps

`isStable reference <https://angular.io/api/core/ApplicationRef#is-stable-examples>`_

`Angular Testability service <https://angular.io/api/core/Testability>`_

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/MarketSquare/robotframework-angularjs",
    "name": "robotframework-angularjs",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "robotframework testing testautomation angular selenium webdriver",
    "author": "Zephraph, Ed Manlove",
    "author_email": "emanlove@verizon.net",
    "download_url": "",
    "platform": null,
    "description": "AngularJSLibrary - robotframework-angularjs\r\n===========================================\r\nAn AngularJS and Angular extension to Robotframework's SeleniumLibrary.\r\nAngularJSLibrary primarily provides functionality to deal with **waiting** and\r\nthus timing issue when testing Angular based websites. The library does this by\r\nproviding first an implicit wait and, subsequently, an explicit keyword for\r\nwaiting on angular.\r\n\r\nAbout this library\r\n------------------\r\nThe AngularJSLibrary, despite the name including JS, supports testing against\r\nboth Angular 2.0+ (known as simply Angular) and Angular 1.0 (also known as\r\nAngular JS).\r\n\r\nThis library is considered mature and feature complete. Ongoing support is\r\nprovided through the Robot Framework community Slack. Thus it may appear\r\nto be abandoned or neglected for which it is not.\r\n\r\n**Please carefully read through this README in its entirety**. It covers how\r\nto configure and import the library into your test scripts, use and understand\r\nits key functionality, as well as troubleshooting and debugging information.\r\n\r\nInstallation\r\n------------\r\nTo install **AngularJSLibrary**, run:\r\n\r\n.. code:: bash\r\n\r\n    pip install robotframework-angularjs\r\n\r\n\r\nAlternatively, to install from source:\r\n\r\n.. code:: bash\r\n\r\n    python setup.py install\r\n\r\n\r\nIdentifying the Angular root element\r\n------------------------------------\r\nPrior to importing the library, one must identify the Angular root element or root\r\ncomponent. For more information about \r\n\r\nHere are a few examples of Angular sites and their corresponding root elements or\r\ncomponents. The first example is from the `AngularJS.org PhoneCat tutorial <http://angular.github.io/angular-phonecat/step-14/app>`_.\r\nThe base html code is\r\n\r\n.. code::  html\r\n\r\n    <html lang=\"en\" ng-app=\"phonecatApp\">\r\n      <head>\r\n        <!-- ... -->\r\n      </head>\r\n      <body>\r\n    \r\n        <div class=\"view-container\">\r\n          <div ng-view class=\"view-frame\"></div>\r\n        </div>\r\n    \r\n      </body>\r\n    </html>\r\n\r\nIn the PhoneCat tutorial the html element with the ng-app attribute is the root\r\nelement. Thus for this website the root selector would be :code:`[ng-app]`. The\r\nnext example is the `Getting started with Angular tutorial <https://angular.io/start>`_\r\non angular.io site. It's main html looks like\r\n\r\n.. code::  html\r\n\r\n    <!DOCTYPE html>\r\n    <html lang=\"en\">\r\n      <head>\r\n        <!-- ... -->\r\n      </head>\r\n      <body>\r\n        <app-root></app-root>\r\n      </body>\r\n    </html>\r\n\r\nHere the root component is the app-root element and thus the root selector for\r\nthis website would be :code:`app-root`. The last example is the `example tab of\r\nthe Dialog UI component <https://material.angular.io/cdk/dialog/examples>`_\r\nwithin the Angular.io Component Dev Kit (CDK).\r\n\r\n.. code::  html\r\n\r\n    <!DOCTYPE html><html lang=\"en-US\"><head>\r\n    <!-- ... -->\r\n    </head>\r\n    \r\n\r\n    <body class=\"docs-app-background\">\r\n      <material-docs-app></material-docs-app>\r\n      <!-- ... -->\r\n    \r\n    </body></html>\r\n\r\nThe root component for the Dialog component example page is the material-docs-app\r\nelement. The root selector will be :code:`material-docs-app`.\r\n\r\nNow we will use the root selector when we import the library.\r\n\r\nImporting the library\r\n---------------------\r\nThe proper name for importing the library is :code:`AngularJSLibrary`. You will\r\nneed to include the SeleniumLibrary **before** you import the AngularJSLibrary.\r\nThe first of two library options is `root_selector`. So using our first example,\r\nthe PhoneCat tutorial from AngularJS.org above, our import may look like,\r\n\r\n.. code::  robotframework\r\n\r\n    *** Settings ***\r\n    Library    SeleniumLibrary\r\n    Library    AngularJSLibrary    root_selector=[ng-app]\r\n    \r\n    *** Test Cases ***\r\n    Search Through The Phone Catalog For Samsung Phones\r\n        Open Browser  http://angular.github.io/angular-phonecat/step-14/app  Chrome\r\n        Input Text  //input  Samsung\r\n        Click Link  Samsung Galaxy Tab\u2122\r\n        Element Text Should Be    css:phone-detail h1    Samsung Galaxy Tab\u2122\r\n\r\nAs the default value for the root_selector argument is :code:`[ng-app]`, for\r\nthe PhoneCat tutorial we did not need to specify the root_selector and could\r\nhave written the Library import as\r\n\r\n.. code::  robotframework\r\n\r\n    *** Settings ***\r\n    Library    SeleniumLibrary\r\n    Library    AngularJSLibrary\r\n    \r\n    *** Test Cases ***\r\n    Search Through The Phone Catalog For Samsung Phones\r\n        Open Browser  http://angular.github.io/angular-phonecat/step-14/app  Chrome\r\n        Input Text  //input  Samsung\r\n        Click Link  Samsung Galaxy Tab\u2122\r\n        Element Text Should Be    css:phone-detail h1    Samsung Galaxy Tab\u2122\r\n\r\n*If you get an \"Unable to find root selector ...\" error* then you should re-check\r\nyour root_selector. Note that unlike locators used with the SeleniumLibrary the\r\nroot_selector **should not** contain the css locator prefix.\r\n\r\nThe second library option, ignore_implicit_angular_wait, is a flag which when\r\nset to True the AngularJS Library will not wait for Angular $timeouts nor\r\n$http calls to complete when finding elements by locator. The default value is\r\nFalse.\r\n\r\n*If the application under test starts on a non angular page,* for example a\r\nlogin page that is not angular which leads into an angular app, then one should\r\nstart with the implicit angular wait turned off. For example,\r\n\r\n.. code::  robotframework\r\n\r\n    *** Settings ***\r\n    Library    SeleniumLibrary\r\n    Library    AngularJSLibrary    ignore_implicit_angular_wait=True\r\n    \r\n    *** Test Cases ***\r\n    Login Into Non Angular Page\r\n        # ...\r\n\r\nUsage of the Waiting functionality\r\n----------------------------------\r\nThe AngularJS Library provides two types of waiting: a built-in implicit wait\r\nthat automatically waits when using a locator strategy and then an explicit\r\nkeyword that one calls out or writes into their script. In the tutorial and\r\nexamples above the scripts there aren't any expicit wait calls. Here instead\r\nthe script is relying on the implicit wait which by default is turned on.\r\nThis means as soon as you import the library you will have waiting enabled.\r\n\r\nThis can be demostrated by importing the library with the implicit wait turned\r\noff and using instead the library's explicit `Wait For Angular` keyword.\r\n\r\n.. code::  robotframework\r\n\r\n    *** Settings ***\r\n    Library    SeleniumLibrary\r\n    Library    AngularJSLibrary    ignore_implicit_angular_wait=True\r\n    \r\n    *** Test Cases ***\r\n    Search Through The Phone Catalog For Samsung Phones\r\n        Open Browser  http://angular.github.io/angular-phonecat/step-14/app  Chrome\r\n        Wait For Angular\r\n        Input Text  //input  Samsung\r\n        Wait For Angular\r\n        Click Link  Samsung Galaxy Tab\u2122\r\n        Wait For Angular\r\n        Element Text Should Be    css:phone-detail h1    Samsung Galaxy Tab\u2122\r\n\r\nWith the implicit wait functionality it is expected that most of the situations\r\nwhere waiting is needed will be handled \"automatically\" by this \"hidden\" implicit\r\nwait. Thus if one examined your test case they would not see many, if any,\r\n`Wait For Angular` keywords but instead would see actions keywords with no\r\n\"waiting\" keywords in between actions. There are times, though, when one needs to\r\nexplicitly call out to wait for angular. For example when using a SeleniumLibrary\r\nkeyword that does not use a locator strategy, like :code:`Alert Should Be Present`\r\nand :code:`Page should contain`, or if you use webelement.\r\n\r\nIn addition to the option to turn off the implicit wait on library import, you\r\nmay turn it off using the :code:`Set Ignore Implicit Angular Wait` keyword with\r\nan argument of :code:`${True}`. \r\n\r\n\r\nUnderstanding and verifying the angular waits\r\n---------------------------------------------\r\nAlthough the waits seem like \"Magic\" they are not. Let's look into how the\r\nwaits are implimented and work to gain insight as to how they work. The waits,\r\nboth the implicit and explicit, poll what I call the \"angular queue\".\r\nTechnically it is checking that angular has \"finished rendering and has no\r\noutstanding $http or $timeout calls\". It does this by checking the\r\n`notifyWhenNoOutstandingRequests` function for AngularJS applications. For\r\nAngular applications the library is checking the `isStable` function on the\r\nAngular Testibility service.\r\n\r\nThis can be seen within the log file by setting the loglevel to DEBUG or TRACE.\r\nRerunning the PhoneCat demo (:code:`robot --loglevel DEBUG demo_phonecat.robot`)\r\none should see in the log file\r\n\r\n.. code::  robotframework\r\n\r\n    20:01:04.658\tINFO\tTyping text 'Samsung' into text field '//input'.\t\r\n    20:01:04.658\tDEBUG\tPOST http://localhost:50271/session/f75e7aaf5a00c717ae5e4af34a6ce516540611dae4b7f6079ce1a753c308cde2/execute/sync {\"script\": \"...snip...\"]}\t\r\n    20:01:04.661\tDEBUG\thttp://localhost:50271 \"POST /session/f75e7aaf5a00c717ae5e4af34a6ce516540611dae4b7f6079ce1a753c308cde2/execute/sync HTTP/1.1\" 200 14\t\r\n    20:01:04.661\tDEBUG\tRemote response: status=200 | data={\"value\":true} | headers=HTTPHeaderDict({'Content-Length': '14', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})\t\r\n    20:01:04.661\tDEBUG\tFinished Request\t\r\n\r\nFor space reasons I snipped out the core script on the POST execute/sync line.\r\nOne should see these lines repeated several times over. This is the polling the\r\nlibrary is doing to see if the application is ready to test. It will repeat\r\nthis query till either it returns true or it will repeat till the \"give up\"\r\ntimeout. If it gives up, it will silently and gracefully fail continuing onto\r\nthe actions it was waiting to perform. It is important for the user of this\r\nlibrary to see and understand, at a basic level, this functionality. As the\r\nprimary usage are these implicit, and thus hidden, waits it is key to see how\r\nto check the library is operating properly and when it is waiting.\r\n\r\n*When using the AngularJS Library, if all waits timeout then the AngularJS\r\nLibrary may not wait properly with that application under test.* This,\r\nrecalling all previously outlined information, is telling you that the\r\nAngular app is constantly busy. This can happen depending on how the angular\r\napplication is designed. It may also affect only a portion of the application\r\nso it is important to test out various parts of the application.\r\n\r\nFurther debugging techniques\r\n----------------------------\r\nIn addition to using the AngularJS Library, one can use the Browser's DevTools\r\nas a way to test out and demonstrate the core operation of the library against\r\nan application. To be clear, this is not library code but similar Javascript\r\ncode which one uses outside of robot to exhibit, to a dev team for example,\r\nwhat the library is seeing when it querys the application. When viewing the\r\napplication under test open the DevTools, preferably under Chrome, and on the\r\nConsole tab type the following,\r\n\r\nIf the application is built with AngularJS or Angular 1.x then the script is\r\n\r\n.. code::  javascript\r\n\r\n    var callback = function () {console.log('*')}\r\n    var el = document.querySelector('[ng-app]');\r\n    var h = setInterval(function w4ng() {\r\n        console.log('.');\r\n        try {\r\n            angular.element(el).injector().get('$browser').\r\n                notifyWhenNoOutstandingRequests(callback);\r\n        } catch (err) {\r\n          console.log(err.message);\r\n          callback(err.message);\r\n        }\r\n      }, 10);\r\n\r\nFor Angular v2+ then the script is\r\n\r\n.. code::  javascript\r\n\r\n    var callback = function () {console.log('*')}\r\n    var el = document.querySelector('material-docs-app');\r\n    var h = setInterval(function w4ng() {\r\n        console.log('.');\r\n        try {\r\n            var readyToTest = window.getAngularTestability(el).isStable();\r\n        } catch (err) {\r\n          console.log(err.message);\r\n          callback(err.message);\r\n        }\r\n        if (!readyToTest) {\r\n          callback()\r\n        } else {\r\n          console.log('.');\r\n        }\r\n      }, 10);\r\n\r\nThis will display a :code:`.` when \"stable\". Otherwise it will show a :code:`*`\r\nwhen \"busy\". To shut down the javascript interval and stop this script type on\r\nthe console prompt :code:`clearInterval(h);`. [Chrome Browser is preferred\r\nbecause repeated output within its DevTools console will be displayed as a\r\nsingle line with a count versus a new line for each output making it much\r\neasier to see and read.] I have personally used this myself both in developing\r\nthis library as well as demonstrating to various Angular developers how a\r\ndesign/implementation is blocking testability.\r\n\r\nAdditional Angular Specific Locator Strategies\r\n-------------------------------------------------\r\n**Note: It is no longer recommended to use these angular specific locator\r\nstrategies. Although functional, the SeleniumLibrary locator strategies are more\r\nthan sufficient and in most cases easier to use then these strategies. For backward\r\ncompatablity reasons these will be left in but it is strongly recommended not to\r\nuse.**\r\n\r\nThe library provides three new locator strategies, including ``binding``,\r\n``model``, and ``repeater``.\r\n\r\nFor example, you can look for an Angular ng-binding using\r\n\r\n.. code::  robotframework\r\n\r\n    Get Text  binding={{greeting}}\r\n\r\n\r\nor by using partial match\r\n\r\n.. code::  robotframework\r\n\r\n    Get Text  binding=greet\r\n\r\n\r\nor by simply using the binding {{\u2026}} notation\r\n\r\n.. code::  robotframework\r\n\r\n    Get Text  {{greeting}}\r\n\r\n\r\nOne can also find elements  by model\r\n\r\n.. code::  robotframework\r\n\r\n    Input Text  model=aboutbox  Something else to write about\r\n\r\n    \r\n.. role:: rf(code)\r\n   :language: robotframework\r\n\r\nFinally there is the strategy of find by repeat. This takes the general form of :rf:`repeater=some ngRepeat directive@row[n]@column={{ngBinding}}`. Here we specify the directive as well as the row, an zero-based index, and the column, an ngBinding. Using this full format will return, if exists the element matching the directive, row and column binding.  One does not need to specify the row and column but can specify either both, one or the other or neither. In such cases the locator may return  list  of elements or even a list of list of elements. Also the ordering of row and column does not matter; using :rf:`repeater=baz in days@row[0]@column=b` is the same as :rf:`repeater=baz in days@column=b @row[0]`.\r\n\r\n\r\nGetting Help\r\n------------\r\nIf you need help with AngularJSLibrary, SeleniumLibrary, or Robot Framework usage, please reach out within the Robot Framework community `Slack <https://slack.robotframework.org/>`_.\r\n\r\n    \r\nKeyword Documentation\r\n---------------------\r\nThe keyword documentation can be found on the `Github project page <https://marketsquare.github.io/robotframework-angularjs/>`_.\r\n\r\n\r\nTesting\r\n-------\r\nFor information on how we test the AngularJSLibrary see the `Testing.rst <https://github.com/Selenium2Library/robotframework-angularjs/blob/master/TESTING.rst>`_ file.\r\n\r\n\r\nReferences\r\n----------\r\n\r\n`SeleniumLibrary <https://github.com/robotframework/SeleniumLibrary>`_: Web testing library for Robot Framework\r\n\r\n`Protractor <http://www.protractortest.org>`_: E2E test framework for Angular apps\r\n\r\n`isStable reference <https://angular.io/api/core/ApplicationRef#is-stable-examples>`_\r\n\r\n`Angular Testability service <https://angular.io/api/core/Testability>`_\r\n",
    "bugtrack_url": null,
    "license": "Apache License 2.0",
    "summary": "An AngularJS/Angular extension to Robotframework's SeleniumLibrary",
    "version": "1.0.0",
    "project_urls": {
        "Homepage": "https://github.com/MarketSquare/robotframework-angularjs"
    },
    "split_keywords": [
        "robotframework",
        "testing",
        "testautomation",
        "angular",
        "selenium",
        "webdriver"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5a9cd4e3b22cef23b35273c7c4898a38949b1d2052922fd389d7115bb90721f5",
                "md5": "fafc63dfd39a77ebddf8fc4ba93addb7",
                "sha256": "d3a834d0475e48adfa3d67decc7c9f3771469745757796bdc09210224c54be20"
            },
            "downloads": -1,
            "filename": "robotframework_angularjs-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fafc63dfd39a77ebddf8fc4ba93addb7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 17448,
            "upload_time": "2024-02-23T04:27:05",
            "upload_time_iso_8601": "2024-02-23T04:27:05.132110Z",
            "url": "https://files.pythonhosted.org/packages/5a/9c/d4e3b22cef23b35273c7c4898a38949b1d2052922fd389d7115bb90721f5/robotframework_angularjs-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-23 04:27:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "MarketSquare",
    "github_project": "robotframework-angularjs",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "robotframework-angularjs"
}
        
Elapsed time: 0.19701s