In my Angular5 app, I have an E2E test suite running on protractor that includes logging in to a google account. Recently, after the password has been entered, Chrome is being redirected to https://accounts.google.de/accounts/SetSID
displaying a blank screen and nothing else happens. Eventually, the suite runs into a timeout.
When I enter the username and password manually (outside of the E2E environment), the browser also gets redirected to this URL for a second, but then promptly navigates to https://accounts.google.com/signin/oauth/consent
where I get to allow or decline access to my account.
It looks like I need to fix some Chrome settings for the E2E environment, but which ones and how?
Edit: The page itself is blank, but the HTML body contains a single script tag:
<script nonce>
location.replace('https:\/\/accounts.google.com\/signin\/oauth\/consent?authuser\x3d0\x26part\x3dAJi8hAMUl_5gA4GrIozXAyYpERMmUqdSAaQS-oLzjkegEK6wmwghwqKNYFd8jKuz3WjirmqMLgnvk9FNR-hVvO0bnWthA-dCrOVWyLKXl_GYL_xVerzhfMSNGPn7wziNYoQ5nKVyaWtH67YUR-O7gwmSW0dukrSjIUpg954e1KcAiMfrCf4dKRBFd8ENTdy4U5KHphQjWKPKnqsXf0hCUob6DFaLiiyUrDq9BaBkOFdnafHz0hP99JFGDa1Anul9oWYonB8ce4z485rPHpuGYBVmioRauqBXWQ1q62oNgDuo8qhFDsGUyxUyywgKQ-veZO05WHJcmmtbL_q0bmrPHD3yNl91vwl0uiF5NdRS_kZ6oKY_bxD562yawqNQdZ1nVfAGWmaYXyXjFd6EX0He351ugpyyezOZ0zBb-5BKv7IXWu2DiD3bd_E\x26as\x3dOnTvuJ0NpqEd3bqD8MVs-g\x26auth\x3dAwanw8ZCzvMxUzucWfpIL9mB__vh3DFsXzQGdSuyMdWciXu7MY6ww1lukyPl3EJ0B4FX5A.#');
</script>
It is actually possible to extract the callback URL from the script, but it requires some meddling since the url string escapes special characters:
const returnScript = element(by.xpath('//body/script'));
browser.wait(protractor.ExpectedConditions.presenceOf(returnScript), 10000)
.then(() => {
returnScript.getAttribute('innerHTML')
.then(text => {
let callbackUrl = text
.match(/\'.*\'/)[0]
.slice(1, -1);
callbackUrl = callbackUrl.replace(/\\\//g, '/');
callbackUrl = callbackUrl.replace(/\\x3d/g, '=');
callbackUrl = callbackUrl.replace(/\\x26/g, '&');
// This was necessary for some reason, I assume you need to replace .de with your country domain
callbackUrl = callbackUrl.replace(/.com/, '.de');
console.log(callbackUrl);
browser.driver.get(callbackUrl);
})
})
Edit: When I launched the same suite yesterday, the problem was simply gone. The above code was not necessary.