waitForAngular function like Protractor offers?

1,006 views
Skip to first unread message

buc rogers

unread,
Dec 8, 2014, 10:27:15 PM12/8/14
to thucydid...@googlegroups.com
For Angular apps, Protractor is a recommended test tool due in part to its built-in clean mechanism to wait for angular pages to load.

Two Serenity questions related to this:

1) Has anyone implemented a waitForAngular() function (as Protractor uses under the covers)? We've had some success with the following javascript, but this does not seem to be sufficient in all cases: 

window.angular != null && angular.element(document) != null

2) Some of the Serenity docs imply that it may be used as a reporting framework with .NET or Javascript selenium test tools - how is this done? For example, is it possible to use Serenity reporting (including screenshot harvesting) with Protractor?

br

buc rogers

unread,
Dec 11, 2014, 10:21:23 AM12/11/14
to thucydid...@googlegroups.com
With regard to 1) above, the following solution is working well for me. I call the ngWebDriver java port of selected Protractor code (including waitForAngular) which implements the second statement below:

//Wait for DOM ready (avoids occasional error accessing angular var in next statement)
//Use wait construct to wait for the below
( (JavascriptExecutor) driver).executeScript("return document.readyState").equals("complete")

//Wait for angular ready
( (JavascriptExecutor) driver).executeAsyncScript("var callback = arguments[arguments.length - 1];" + "angular.element(document.body).injector().get('$browser').notifyWhenNoOutstandingRequests(callback);");

Silviu Badea

unread,
Jul 17, 2015, 12:44:37 PM7/17/15
to thucydid...@googlegroups.com
How do you get driver in Serenity to work with this library?

Theo

unread,
Aug 7, 2015, 10:18:40 AM8/7/15
to Serenity BDD Users Group
Hi Silviu,

I would assume that you figure out how to use Paul Hammant library with Serenity? But just in case someone might be interested as well, this is how I did it:

Put the dependency in the pom.xml

        <dependency>
            <groupId>com.paulhammant</groupId>
            <artifactId>ngwebdriver</artifactId>
            <version>0.9.1</version>
        </dependency>


Then I was able to use all the examples provided here

private ByAngular ng;
ng = new ByAngular((JavascriptExecutor) getDriver());
    
List<WebElementFacade> elements= findAll(ng.repeater("location in Locations"));

or

WebElementFacade element = findAll(ng.repeater("location in Locations").row(2));

etc

It works for ng-repeat and ng-binding. ng-model is covered by Serenity out of the box

John Smart

unread,
Aug 7, 2015, 10:24:08 AM8/7/15
to Theo, Serenity BDD Users Group
Yes, it is a nice library - I will get round to integrating it at some point.

--
You received this message because you are subscribed to the Google Groups "Serenity BDD Users Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to thucydides-use...@googlegroups.com.
To post to this group, send email to thucydid...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
___________________________________________________
John Smart | Wakaleo Consulting  |  +61 407 247 642
Optimizing your software development process
http://www.wakaleo.com  |  john....@wakaleo.com
___________________________________________________

We love breaking down silos and helping smart teams collaborate better! Ask about our tailored on-site workshops in Agile Requirements Discovery, Behaviour Driven Development, Agile Development Practices, and Test Automation!
___________________________________________________

Sampathkumar S

unread,
Jan 19, 2016, 1:47:57 AM1/19/16
to Serenity BDD Users Group, itheo...@gmail.com
Hi John 

Is the ngwebdriver library integrated with latest Serenity versions?

Erik

unread,
Feb 18, 2016, 2:37:35 AM2/18/16
to Serenity BDD Users Group, itheo...@gmail.com
Good question. For now I am using the following Webdriver command to sync with Angular. It seems to work well:

evaluateJavascript( "var mycallback = function(){ console.log('Synced page.'); return true; };"+
"var app = angular.element(document.querySelector('html'));" +
"var $browser = app.injector().get('$browser');" +
"$browser.notifyWhenNoOutstandingRequests(mycallback);");

Manoj K

unread,
Feb 19, 2016, 5:38:42 AM2/19/16
to Serenity BDD Users Group
Am a core contributor to the ng-webdriver library.

I can help integrating into Serenity , for sure it would help many. 

Regards,
Manoj
Message has been deleted

Ramu Vairavan

unread,
Mar 29, 2016, 2:57:36 PM3/29/16
to Serenity BDD Users Group
Manoj / John -
Did we get a chance to integrate ngWebDriver into Serenity?

Thanks
Ramu.

adi....@outlook.com

unread,
Sep 6, 2016, 8:30:46 AM9/6/16
to Serenity BDD Users Group

I have posted in https://groups.google.com/d/msg/thucydides-users/48cAQItiSs8/dkDzbrzwAAAJ 2 functions (1 for Angular1.x and 1 for Angular2.x) that work for me if anyone needs them.
Reply all
Reply to author
Forward
0 new messages