Detect if the Protractor environment is

In an AngularJS app, is it possible to determine if the environment is Protractor?

I would like to disable certain features like Geolocation when running my tests. This is not what I want to test at the moment, and I am pretty sure this is what is causing my tests to not run.

In my application I use window.jasmine

to disable certain polling actions when running Jasmine tests so something like this would be good.


if(!window.protractor) {


It doesn't work and I can't use anything on the window.

Note. I know I can mock the geolocation I can do if this is not possible. This is probably the best approach anyway, however it would be good to know if there is a suitable solution. How to enable geolocation support in chromedriver for Selenium?


source to share

1 answer

I would recommend that you move your geodata code into an angular module. Then you can mock the module in your protractor tests usingbrowser.addMockModule



All Articles