Comments (22)
Hi @kyanny, can you send me an example cookies.js file with a sample config file so I can see how they work together? Thank you.
from backstopjs.
Hi @garris
Cookie (secure values are masked): https://gist.github.com/kyanny/4feeb13d450f76a49f49
backstop.json: https://github.com/kyanny/BackstopJS-sample/blob/master/backstop.json
from backstopjs.
Hi @kyanny, yes I can see that this is very useful in certain cases. One thing, could you add a config property ('cookiesJsonFile') to the scenario
node to point to the cookies file? Then use that value internally instead of hard coding the filename. This way users can choose where to place their files and BackstopJS won't even try to load a cookies file unless it is specified in the config. It would also be great if you can document this feature in the readme file. How does that sound?
from backstopjs.
Hi @garris, sounds very good and all makes sense! I will try and open Pull Request.
from backstopjs.
+1 cookies would be awesome
from backstopjs.
+1
from backstopjs.
Sorry this is taking so long. Will absolutely try to get this in this weekend! Thanks for your patience.
from backstopjs.
@kyanny, Please take a look at the cookies
branch. I've added your code and it looks like there is an issue saving the cookies -- the cookie string does not appear in the page. Please let me know what you come up with. Thank you.
from backstopjs.
Hi @kyanny, did you have a chance to test the cookies feature? Is it working for you?
from backstopjs.
Hi @garris, sorry for delay.
Could you show me the exact command line to run test suite?
I read files in test directory carefully, but I'm still not sure how to integrate them to BackstopJS.
from backstopjs.
Thank you @kyanny -- it's no problem. I have a break coming up in a week -- I will write instructions for running the tests. I will get back to you as soon as I can. :)
from backstopjs.
This functionality can be supported with custom CasperJS scripts. see https://github.com/garris/BackstopJS#running-custom-casperjs-scripts-version-080
from backstopjs.
Is there some sample to achieve this with CasperJS ? I'm a little bit lost with casper as i need some session cookie to be set before the page is rendered, else i won't have the "authenticated only" content.
And from what i understood from the documentation, it seems the page is already rendered when onReadyScript
is executed, did i miss something ?
from backstopjs.
I've got this working in my capser tests by first loading the inital homepage or somerthing, then calling
casper.page.addCookie({some: 'cookie'});
However it seems that the implementation for backstop is to use phantom.addCookie, which means you have to know the domain up front, which isnt ideal. I've tried explicitly stating the domain in my cookies.json file but that doesn't seem to work either?
I have noticed that this section about this functionality in the readme is commented out? Are cookies no longer supported?
from backstopjs.
@sveetch Got something working by creating a set_cookies.js file in the /scripts directory:
module.exports = function(casper, scenario, vp) {
casper.echo("Setting cookies");
casper.then(function(){
casper.page.addCookie({some: 'cookie'});
});
casper.thenOpen(scenario.url);
}
Then in my scenario I have added this:
"onReadyScript": "set_cookies.js"
from backstopjs.
@TimPerry thank you
I'm trying to achieve my problem with a CasperJS script to launch before just for login and using persistent cookie. I will try your code if i don't succeed.
from backstopjs.
@sveetch Thank you for documenting your cookie code here. Much appreciated! Cheers.
from backstopjs.
@TimPerry @garris here it is: https://gist.github.com/sveetch/4a20793b77f2a8b5c045
It works well, it's little bit verbose and maybe messy, but it just works.
from backstopjs.
@TimPerry thank you very much for documenting! Do you mind if I add this snippet to the help files?
from backstopjs.
@garris Of course not, go for it and thank you for creating such a great tool.
from backstopjs.
@TimPerry @kyanny hi Tim and kyanny, I used the demo for cookies,but it didn't work.
module.exports = function(casper, scenario, vp) {
casper.echo("Setting cookies");
casper.then(function(){
casper.page.addCookie({some: 'cookie'});
});
casper.thenOpen(scenario.url);
}
casper.page.addCookie({some: 'cookie'});
what's the meaning of this piece of code ?
({some:'cookie'}) is cookie file or the cookie hash?
from backstopjs.
That would be the cookie hash. I believe it is a call to this method in phantomJS: http://phantomjs.org/api/webpage/method/add-cookie.html
from backstopjs.
Related Issues (20)
- Embedded media showing blank HOT 3
- How about switching back to resemblejs? HOT 1
- Derived security vulnerability from `ip` package through `puppeteer` dependency HOT 2
- Unable to use approve button
- Can't install on debian 11 | Fails to install puppeteer HOT 1
- Multiple Screenshots in a Single Script HOT 1
- Looks like fonts or chrome is breaking the docker build HOT 18
- Can TypeScript be used with BackstopJS?
- Optimizing Environment Comparison to Prevent Redundant Runs
- Will there be a tagged version on Dockerhub for version 6.3.6? HOT 2
- Issue: Backstop test pass, even with the timeout error HOT 1
- Puppeteer Delay is not supported
- `scenario.misMatchThreshold` is ignored HOT 2
- `requireSameDimensions` property is not working HOT 1
- How to View snapshot comparisons when running backstop js in GH CICD workflows?
- Failed to launch the browser process when running inside of docker container HOT 3
- Request for Node Module Update to Enable Multiple Screenshot Support (createBitmaps.js, runPuppet.js) HOT 3
- Test errors, but there is no difference in the snapshots when observed with the naked eye HOT 2
- Ready event seems to be unreliable HOT 1
- Unreliable font loading causes difference between test and reference HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from backstopjs.