Closed jonathansamines closed 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).
@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.
Would like to see a stack trace @jonathansamines. Can you please provide?
@jonathansamines merge/publish of #65 should resolve this.
should be fixed with v2.2.5
@grawk I can confirm the problem was resolved. Thanks!
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 latestsnemo-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.