GithubHelp home page GithubHelp logo

marmelab / gremlins.js Goto Github PK

View Code? Open in Web Editor NEW
9.0K 157.0 422.0 4.6 MB

Monkey testing library for web apps and Node.js

Home Page: https://marmelab.com/blog/2020/06/02/gremlins-2.html

License: MIT License

JavaScript 89.21% Makefile 1.48% HTML 8.45% CSS 0.86%
test fuzz-testing frontend

gremlins.js's Issues

This gremlin requires a randomizer to run. Please call randomizer(randomizerObject) before executing the gremlin

From README.md

"For instance, the clicker gremlin is a function that you can execute it directly:"

var clickerGremlin = gremlins.species.clicker();
clickerGremlin(); // trigger a random mouse even in the screen

The code above raises this error:

This gremlin requires a randomizer to run. 
Please call randomizer(randomizerObject) before executing the gremlin

ENV:
Windows Server 2012 R2
Chrome Version 46.0.2490.86 m
gremlins.min.js from master branch

require.js bookmarklet

The current bookmarklet doesn't work with require.js pages.
Can we get a second bookmarklet that will work with require.js?

window.requestAnimationFrame is missing

It's an experimental technology so not all browsers support it.
Would be nice to have a graceful degradation in this case, especially when I redefine gremlins.species.clicker().showAction or make it an empty function.

Uncaught RangeError: Chance: Min cannot be greater than Max.

We got gremlins up and running (neat project, btw) but are encountering an error after a second or two of testing. I was hoping for some insight.

Uncaught RangeError: Chance: Min cannot be greater than Max. gremlins.min.js?bust=1395340612814:22
f gremlins.min.js?bust=1395340612814:22
u.natural gremlins.min.js?bust=1395340612814:22
u.pick gremlins.min.js?bust=1395340612814:22
l gremlins.min.js?bust=1395340612814:22
u gremlins.min.js?bust=1395340612814:22
s gremlins.min.js?bust=1395340612814:22
t gremlins.min.js?bust=1395340612814:22
p gremlins.min.js?bust=1395340612814:22
(anonymous function)

Here is a screenshot of my chrome dev console with the error:

screen shot 2014-03-20 at 11 37 16 am

Any suggestions?

Problems with React.js

gremlins.js seems to have problems with React.js - we can't seem to get it to trigger any event listeners (onChange, onClick, etc.) - any ideas?

Textareas in form filler

It would be great if text area filling could be added, unless I'm being dumb and have missed out some config.

keyup / keydown should be triggered

Gremlins can type into input fields, but keyup / keydown is never triggered. This causes, f. e. angular apps, to not update the view (update is bound to keyup / keydown). I guess after every typing the event could be manually triggered.

Best
Marc

Allow execution of closures in series

All _beforeCallbacks, _afterCallbacks, _monkeys, _runners arrays contain a collection of callbacks. these callbacks can be synchronous:

function() {
 // I'm synchronous
}

or asynchronous:

function(done) {
 // I'm asynchronous
}

We should built a generic executor, taking any array of callbacks as parameter, and running them all in series, calling its final callback upon completion:

function series(callbacks, done) {
}

Use mocha as inspiration.

gremlins not effecting everything

Hi guys, great work, and a very useful concept - thanks!

What I have found though is that the gremlins are only active at low z-indecies, so they do not effect modal popups, or any floating elements sitting on a layer above the main page.

If you load the agent login of our app:
https://dev.ef2f.com/service/1/common/agent.html

And run the following in the console:
releaseTheGremlins(22334);

You should see clearly what I mean - only the page beneath the login popup is effected.

Note you need a webcam plugged in to get to the login screen.

With this issue fixed we can trigger gremlins at any stage in our app, and use it to test all screen states, not only the base layer.

Thanks again for an awesome tool!

Jamie

Touch Gremlins

Would be a nice feature. support for touch events, and also pointer events? Also different gestures like swipe, tap, doubletap, hold, drag, rotate and pinch would be awesome.

I wrote a small tool for this a while ago, might be useful to take a look; https://github.com/jtangelder/faketouches.js

Alternative to Bookmarklet in mobile browsers

Hi,

Is there a way to use this javascript function other than bookmarklet inorder to make it work on mobile browsers on Android

javascript:(function(){function callback(){gremlins.createHorde().allGremlins().gremlin(function() {window.$ = function() {};}).unleash()} var s=document.createElement("script");s.src="https://rawgithub.com/marmelab/gremlins.js/master/gremlins.min.js";if(s.addEventListener){s.addEventListener("load",callback,false)}else if(s.readyState){s.onreadystatechange=callback}document.body.appendChild(s);})()

Please suggest

Regards,
Madhav Pai

Custom Logger functions only receive 'gremlin'/'mogwai'-string instead of full msg

Just created an custom logger-object to redirect gremlinJs logging to use native angular logging-module like this:

// Custom gremlinJS Logger for using Angular std. logging
var angularLogger = {
log: function( msg ) { $log.debug( msg ) }
, info: function( msg ) { $log.info( msg ) }
, warn: function( msg ) { $log.warn( msg ) }
, error: function( msg ) { $log.error( msg ) }
} resulting in only 'gremlin'/'mogwai'-logs being written to console.

Verified that passed msg-parameter only contains this information, but couldn't build unminified version for further debugging. What are you using for generating your minified files?

Thank you, great project! All the best!

Create an event stack

Logging:

  • all calls to monkeys
  • all events triggered by the handlers

Store this in the suite, and create an eccessor

Add non-ASCII characters to inputs

non-ascii (utf-8) symbols, in some cases, can be reason of errors in page rendering or/and in business logic. So each app should be ready to handle non-ascii characters.

Bookmarklet

javascript:(function()%7Bfunction callback()%7Bgremlins.createHorde().unleash()%7Dvar s%3Ddocument.createElement("script")%3Bs.src%3D"https%3A%2F%2Fraw.github.com%2Fmarmelab%2Fgremlins.js%2Fmaster%2Fgremlins.min.js"%3Bif(s.addEventListener)%7Bs.addEventListener("load"%2Ccallback%2Cfalse)%7Delse if(s.readyState)%7Bs.onreadystatechange%3Dcallback%7Ddocument.body.appendChild(s)%3B%7D)()

Run test in an iframe

To avoid losing script when clicking on an page where the script is not included or in an error page, we can retrieve the current page URL and open it in an full screen iframe.

Any opinion on this ?

Untimely Gremlin death?

Greetings,

I am playing around with the fantastic tool, and it appears to stop running after roughly 5 seconds, even though I haven't explicitly halted the siege and there are < 10 errors in the console. Only once in about 10 runs have I see the mogwai gizmo stopped test execution after 10 errors message, so it seems like it's dying before it can complete?

Let me know if you need additional information!

Change name of project

Please could you change the name of the project in the bower and package?

"name": "gremlins.js", ==> "name": "gremlinsjs",

Thanks

gremlins don't trigger click handlers?

I can see the gremlins clicking everywhere on my page but click handlers are not called. I have buttons and a that show messages or expend areas of the page and they don't kick-in.

My app is an AngularJS app. I tried giving some time for the app to bootstrap before I unleash but it does not change the result.

    <script src="tests/lib/gremlins.min.js"></script>
    <script>
        $(function () {
            setTimeout(function () {
                gremlins.createHorde().unleash();
            }, 3000)
        })
    </script>

Can't inject Randomizer into single gremlin

Clicker gremlin has 'randomizer' config, and according to this comment it should be settable
https://github.com/marmelab/gremlins.js/blob/master/src/species/clicker.js#L21

*   clickerGremlin.randomizer(randomizerObject); // inject a randomizer

I want gremlin to do drag'n'drop on the page, so I was going to replace randomizer with something custom, so Clicker will successively call 'mousedown', 'mousemove' and 'mouseup' which is pretty close to what I need.

However, it seems that any custom randomizer (as well as logger) is replaced with the one from the horde object:
https://github.com/marmelab/gremlins.js/blob/master/src/main.js#L449

inject({'logger': this._logger, 'randomizer': this._randomizer}, allCallbacks);

Is this by the design and gremlin can receive randomizer only from horde object (and a comment in clicker.js is innacurate), or it is a bug in the "unleash" method?
Or maybe I'm doing something wrong and there is a way to inject a custom randomizer into gremlin?

The best solution I came so far is to delete setter after I inject my randomizer, although I feel something wrong with it:

gremlin.randomizer({
    ... my fake randomizer
});

delete gremlin.randomizer;

Uncaught Error (Gremlin suicide)

Ran the library by adding the following:

<script src="/s/gremlins.min.js"></script>
<script>
    gremlins.createHorde().unleash();
</script>

However after the first click (or 10), it throws the following error and stops working:

Uncaught RangeError: Chance: Min cannot be greater than Max. (Line 22)

Let me know if you need anything else

Ben

Rename the suite to "Gremlins"

target API:

gremlins.createHorde()
    .before(function(suite) {
        console.log('started!');
    })
    .breed(gremlins.types.clicker().clickTypes(['click']))
    .breed(gremlins.types.scroller())
    .breed(gremlins.types.typer())
    .breed(function(suite) {
        console.log('I\'m Gizmo, don\'t kill me!');
    })
    .after(function(suite) {
        console.log('finished!');
    })
    .unleash(100);

Clicker does not set event position

Clicker does not set event position

When clicker invokes a mouse event, clientX/clientY properties are always empty:

evt.initMouseEvent(clickType, true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);

This can affect the behavior of the tested app (I think not in intended way). Since the event position is known, probably it should be used when event is fired:

evt.initMouseEvent(clickType, true, true, window, 0, 0, 0, posX, posY, false, false, false, false, 0, null);

https://github.com/marmelab/gremlins.js/blob/master/src/species/clicker.js#L121

Issue lauching the script

Hello,
I'm trying to unleash the hord on my website but I get a issue when I launch the script. It tells me ' i is null' (or sometimes 'r is null').
I follow the basic exemple in the README and search in your Git repository but I have not find an answer.
Do you have an idea where the issue could come from ?

Make it a jQuery plugin

To allow configuration (like allowed URL pattern, or secure page credentials) the simpler way IMO is to make this library a jQuery plugin.

We have already a dependency to jQuery for click emulation

Any cons about that ?

Create a method to intercept errors

using window.onerror

Add to the testsuite using something like testSuite.handler():

var JSErrorHandler = function() {
 return function() {
    //
  }
};

MonkeyTest.createSuite()
  .handler(JSErrorHandler())
  .run(100); // executes all handlers before start

If no handler registered, the JSErrorHandler should be used (just llike defaultRunner).

Is it possible to playback an attack in slow-motion?

Seeing some strange behavior that I can't reproduce manually. I'm wanting to get a step by step replay of what the horde is doing so that I can replay it up to the point where the problem occurs.

The issue is in a third party piece of code (ng-grid) and it's making columns disappear from the grid (when that should be disabled).

TypeError: Argument 4 of KeyboardEvent.initKeyEvent does not implement interface WindowProxy

Firefox 28.0 on Ubuntu

Appears to be an issue with line 84 of the typer species picking out an element from the page that does not accept events.

I am not sure which element is the problem, since it occurred when using greasemonkey to unleash a horde at an internal website. But it was also a problem when using a bookmarklet to do the same - try using the bookmarklet (in the bookmarklet issue) on stackoverflow.com

How randomizer works ?

Hi all !
I cannot figure out how use a custom randomizer.
I want my typer gremlins just use keyCode 39 when they type, so i write something like

let myHorde = gremlins.createHorde();

let myGremlins = gremlins.species.typer();
myGremlins.eventTypes(['keydown']);
myGremlins.randomizer({
  natural: function() {
    return 39;
  }
});

myHorde.gremlin(myGremlins);
myHorde.unleash();

But it doesn't work and I don't find any doc to help me.

Where I'm wrong ?
Thanks !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.