Forked from edwindotcom/gist:8b0348d187c3bd8ea823
Last active
August 29, 2015 14:01
-
-
Save pdehaan/6aaa8856ad1e5c0227a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function loadPage(address, route, lang){ | |
page.customHeaders = {'accept-language': lang}; | |
var address = url + route; | |
var docLocator; | |
var fxaHeader; | |
if (page === 'signup'){ | |
docLocator = 'sign-up'; | |
fxaHeader = "fxa-signup-header"; | |
}else if(page === 'signin'){ | |
docLocator = 'sign-in'; | |
fxaHeader = "fxa-signin-header"; | |
} | |
page.open(address, function (status) { | |
if (status !== 'success') { | |
console.log('FAIL to load the address'); | |
} else { | |
waitFor(function() { | |
// Check in the page if a specific element is now visible | |
return page.evaluate(function (docLoc) { | |
console.log(docLoc); | |
return $(document.getElementsByClassName(docLoc)).is(":visible"); | |
}, docLocator); | |
}, function() { | |
var data = page.evaluate(function () { | |
var p = document.getElementsByClassName("privacy-links"); | |
var fxa = document.getElementById(fxaHeader).innerHTML; | |
return {"title":document.title, | |
"privacy-links": p[0].textContent.trim(), | |
"fxa-signup-header": fxa}; | |
}); | |
console.log('accept-language:'+lang); | |
console.log(JSON.stringify(data)); | |
// page.render('fxa-'+page+'-'+lang+'.png'); | |
phantom.exit(); | |
}); | |
} | |
}); | |
} | |
loadPage(url, page, lang); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment