I need to capture an URL on one page and then open the target. What's the most elegant solution? The code below doesn't work, because the variable url is basically local.
function() {
page.open("https://www.google.com/blah");
},
function() {
page.evaluate(function() {
var url=document.getElementById('link42')[0]; //URL captured
});
},
//opening the target
function() {
page.open(url);
},
function() {
page.evaluate(function() {
console.log(document.querySelectorAll('html')[0].outerHTML);
});
}