paypal / nemo-screenshot

Plugin for Nemo testing framework for adapting selenium screenshot capabilities
Other
12 stars 26 forks source link

Using nemo-screenshot 2.2.4 breaks our test-suit #60

Closed jonathansamines closed 7 years ago

jonathansamines commented 7 years ago

When you have a test-suit which creates multiple nemo instances on the same process (not necessarily in the same test), which therefore initializes all plugins more than once, the latests nemo-screenshot version breaks all, but the first test since it nows overrides the selenium web-driver Click action prototype.

Our tests are currently breaking because of that. What I think is happening is that the the first instance properly replace the click behavior, but on consecutive replacements the prototype was already replaced, but is replaced again with the screenshot code which I think is causing the click behavior to stop working on our tests.

Will try to put together a reproduction later.

skratchdot commented 7 years ago

Interesting. Might need to do something like:

if (autoCaptureOptions.indexOf('click') !== -1 && nemo.wd.WebElement.prototype.click.__patched !== true) {
    var oclick = nemo.wd.WebElement.prototype.click;
    nemo.wd.WebElement.prototype.click = function () {
        var filename = 'ScreenShot_onClick-' + process.pid + '-' + new Date().getTime();
        return nemo.screenshot.snap(filename)
            .then(oclick.bind(this));
    };
    nemo.wd.WebElement.prototype.click.__patched = true;
}

https://github.com/paypal/nemo-screenshot/blob/develop/index.js#L195-L203

I'm also wondering if there's a way to have a nemo instance with autoCaptureOptions set to true, and a separate instance where it's false? If so, then we'd need to modify how we patch WebElement. (I'm not sure that's a real case though).

jonathansamines commented 7 years ago

@skratchdot I was thinking in a solution more like the first one, because ideally for any order the test are run, the test shouldn't fail. A solution providing control over the behavior overriding wouldn't make much sense in these cases. A simple skip on the test which controls the behavior would make the app break.

grawk commented 7 years ago

Would like to see a stack trace @jonathansamines. Can you please provide?

grawk commented 7 years ago

@jonathansamines merge/publish of #65 should resolve this.

grawk commented 7 years ago

should be fixed with v2.2.5

jonathansamines commented 7 years ago

@grawk I can confirm the problem was resolved. Thanks!