Hey i am trying to take a screenshot of an element with nightmare and than i want to extract text from this screenshot with a function und use the result of this in nightmare.type(). The Problem is when i use nightmare.run() i get an error that the screenshot does not exist. How can i fix this? This is my code:
var Nightmare = require('nightmare');
var Screenshot = require('nightmare-screenshot');
var nightmare = new Nightmare();
nightmare.goto('website');
//Takes screenshot of element
nightmare.use(Screenshot.screenshotSelector('screenshot' + i + '.png', 'img[id="yw0"]'));
nightmare.type('input[id=AuthForm_login]', username);
nightmare.type('input[id=AuthForm_password]', password);
nightmare.type('input[id=upload]', image.decodeFile('screenshot' + i + '.png', function(err, result){
//Returns Text from the Screenshot taken above!
return result.text;
}));
nightmare.run();
When i remove the line:
nightmare.type('input[id=upload]', image.decodeFile('screenshot' + i + '.png', function(err, result){
//Returns Text from the Screenshot taken above!
return result.text;
}));
Everything works fine and i get a screenshot.
Aucun commentaire:
Enregistrer un commentaire