Git Product home page Git Product logo

Comments (22)

garris avatar garris commented on July 16, 2024

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.

kyanny avatar kyanny commented on July 16, 2024

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.

garris avatar garris commented on July 16, 2024

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.

kyanny avatar kyanny commented on July 16, 2024

Hi @garris, sounds very good and all makes sense! I will try and open Pull Request.

from backstopjs.

jontonsoup avatar jontonsoup commented on July 16, 2024

+1 cookies would be awesome

from backstopjs.

filipecatraia avatar filipecatraia commented on July 16, 2024

+1

from backstopjs.

garris avatar garris commented on July 16, 2024

Sorry this is taking so long. Will absolutely try to get this in this weekend! Thanks for your patience.

from backstopjs.

garris avatar garris commented on July 16, 2024

@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.

garris avatar garris commented on July 16, 2024

Hi @kyanny, did you have a chance to test the cookies feature? Is it working for you?

from backstopjs.

kyanny avatar kyanny commented on July 16, 2024

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.

garris avatar garris commented on July 16, 2024

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.

garris avatar garris commented on July 16, 2024

This functionality can be supported with custom CasperJS scripts. see https://github.com/garris/BackstopJS#running-custom-casperjs-scripts-version-080

from backstopjs.

sveetch avatar sveetch commented on July 16, 2024

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.

TimPerry avatar TimPerry commented on July 16, 2024

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.

TimPerry avatar TimPerry commented on July 16, 2024

@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.

sveetch avatar sveetch commented on July 16, 2024

@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.

garris avatar garris commented on July 16, 2024

@sveetch Thank you for documenting your cookie code here. Much appreciated! Cheers.

from backstopjs.

sveetch avatar sveetch commented on July 16, 2024

@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.

garris avatar garris commented on July 16, 2024

@TimPerry thank you very much for documenting! Do you mind if I add this snippet to the help files?

from backstopjs.

TimPerry avatar TimPerry commented on July 16, 2024

@garris Of course not, go for it and thank you for creating such a great tool.

from backstopjs.

qileilove avatar qileilove commented on July 16, 2024

@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.

TimPerry avatar TimPerry commented on July 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.