How to avoid getting redirected?
- Dominant language
- JavaScript
- Stars
- 7.2k
- Forks
- 621
- PR merge metrics
- No merged PRs in 30d
Description
I've set up BackstopJS in our project folder:
{
"id": "backstop_default",
"viewports": [
{
"label": "desktop",
"width": 1200,
"height": 1200
}
],
"onBeforeScript": "chromy/onBefore.js",
"onReadyScript": "chromy/onReady.js",
"scenarios": [
{
"label": "Hover",
"cookiePath": "backstop_data/engine_scripts/cookies.json",
"url": "http://localhost:8080/",
"hoverSelector": ".jumbotron"
},
{
"label": "HoverNavbar",
"cookiePath": "backstop_data/engine_scripts/cookies.json",
"url": "http://localhost:8080/#/sandbox/dashboard/dialog",
"hoverSelector": ".navbar-header"
}
],
"paths": {
"bitmaps_reference": "backstop_data/bitmaps_reference",
"bitmaps_test": "backstop_data/bitmaps_test",
"engine_scripts": "backstop_data/engine_scripts",
"html_report": "backstop_data/html_report",
"ci_report": "backstop_data/ci_report"
},
"report": ["browser"],
"engine": "chrome",
"engineFlags": [],
"asyncCaptureLimit": 5,
"asyncCompareLimit": 50,
"debug": false,
"debugWindow": true
}
When I run `backstop reference` chrome opens the url http://localhost:8080 but is then redirected to the Microsoft login page.
Is it possible to avoid the redirection? I've used the Cookie Inspector tool to download my cookies for the localhost page and set them up in my Backstop config:
[
{
"domain": "localhost",
"expirationDate": 1819630487,
"hostOnly": true,
"httpOnly": false,
"name": "ys-torrentGrid",
"path": "/",
"sameSite": "no_restriction",
"secure": false,
"session": false,
"storeId": "0",
"value": "o%3Acolumns%3Da%253Ao%25253Aid%25253Ds%2525253Aqueue%25255Ewidth%25253Dn%2525253A30%25255Esortable%25253Db%2525253A1%255Eo%25253Aid%25253Ds%2525253Aname%25255Ewidth%25253Dn%2525253A506%25255Esortable%25253Db%2525253A1%255Eo%25253Aid%25253Dn%2525253A2%25255Ewidth%25253Dn%2525253A75%25255Esortable%25253Db%2525253A1%255Eo%25253Aid%25253Dn%2525253A3%25255Ewidth%25253Dn%2525253A150%25255Esortable%25253Db%2525253A1%255Eo%25253Aid%25253Dn%2525253A4%25255Ewidth%25253Dn%2525253A80%25255Esortable%25253Db%2525253A1%255Eo%25253Aid%25253Dn%2525253A5%25255Ewidth%25253Dn%2525253A80%25255Esortable%25253Db%2525253A1%255Eo%25253Aid%25253Dn%2525253A6%25255Ewidth%25253Dn%2525253A60%25255Esortable%25253Db%2525253A1%255Eo%25253Aid%25253Dn%2525253A7%25255Ewidth%25253Dn%2525253A60%25255Ehidden%25253Db%2525253A1%25255Esortable%25253Db%2525253A1%255Eo%25253Aid%25253Dn%2525253A8%25255Ewidth%25253Dn%2525253A60%25255Ehidden%25253Db%2525253A1%25255Esortable%25253Db%2525253A1%255Eo%25253Aid%25253Dn%2525253A9%25255Ewidth%25253Dn%2525253A60%25255Ehidden%25253Db%2525253A1%25255Esortable%25253Db%2525253A1%255Eo%25253Aid%25253Dn%2525253A10%25255Ewidth%25253Dn%2525253A60%25255Ehidden%25253Db%2525253A1%25255Esortable%25253Db%2525253A1%255Eo%25253Aid%25253Dn%2525253A11%25255Ewidth%25253Dn%2525253A80%25255Ehidden%25253Db%2525253A1%25255Esortable%25253Db%2525253A1%255Eo%25253Aid%25253Dn%2525253A12%25255Ewidth%25253Dn%2525253A120%25255Ehidden%25253Db%2525253A1%25255Esortable%25253Db%2525253A1%255Eo%25253Aid%25253Dn%2525253A13%25255Ewidth%25253Dn%2525253A120%25255Ehidden%25253Db%2525253A1%25255Esortable%25253Db%2525253A1%255Eo%25253Aid%25253Dn%2525253A14%25255Ewidth%25253Dn%2525253A75%25255Ehidden%25253Db%2525253A1%25255Esortable%25253Db%2525253A1%255Eo%25253Aid%25253Dn%2525253A15%25255Ewidth%25253Dn%2525253A75%25255Ehidden%25253Db%2525253A1%25255Esortable%25253Db%2525253A1%255Eo%25253Aid%25253Dn%2525253A16%25255Ewidth%25253Dn%2525253A75%25255Ehidden%25253Db%2525253A1%25255Esortable%25253Db%2525253A1%255Eo%25253Aid%25253Dn%2525253A17%25255Ewidth%25253Dn%2525253A75%25255Ehidden%25253Db%2525253A1%25255Esortable%25253Db%2525253A1%255Eo%25253Aid%25253Dn%2525253A18%25255Ewidth%25253Dn%2525253A75%25255Ehidden%25253Db%2525253A1%25255Esortable%25253Db%2525253A1",
"id": 1
},
{
"domain": "localhost",
"expirationDate": 1535731952,
"hostOnly": true,
"httpOnly": false,
"name": "_pk_id.1.1fff",
"path": "/",
"sameSite": "no_restriction",
"secure": false,
"session": false,
"storeId": "0",
"value": "4268a76c4acf56fb.1501776752.34.1505420347.1505420347.",
"id": 2
},
{
"domain": "localhost",
"hostOnly": true,
"httpOnly": true,
"name": "SID",
"path": "/",
"sameSite": "no_restriction",
"secure": false,
"session": true,
"storeId": "0",
"value": "OsW3qqYtvD/2eSfvNzN9o9MnIOas9U+x",
"id": 3
}
]
But I'm still redirected to the microsoft login page. I think I found the problem. When I run BackstopJS it opens a new Chrome window that doesn't have me logged in, so all the preferences aren't available. Any way of changing that?
//Update.
Through Chromy I found that there's something called userDataDir:
I've set that up:
"engineOptions": {
"enableExtensions": true,
"userDataDir": "C:/Users/Peter/AppData/Local/Google/Chrome/User Data/Default"
},
But when I run the test the Chrome sessions still has no user.
//Update.
It seems I do have a session with a user, but the new browser doesn't have the same history as the main client. Passing in the cookies seems to fix the redirection.
Contributor guide
Assessment
This issue has not been assessed yet.