Code Monkey home page Code Monkey logo

Comments (7)

dljsjr avatar dljsjr commented on May 27, 2024 4

I might play around with it this weekend! Thanks for pointing me to that WebDriver documentation.

from fantoccini.

dljsjr avatar dljsjr commented on May 27, 2024 1

@jonhoo sorry I never started looking at this! The site I was scraping doubled down on their bot detection and so I pivoted the project 🤷‍♂️ I might still take a stab at it some time.

from fantoccini.

jonhoo avatar jonhoo commented on May 27, 2024 1

Sorry it took me a while to get back to this! I think cookie::Cookie is indeed the way to go 👍

That's awkward about Serialize. I've found the maintainers of webdriver pretty receptive to suggestions, so if you suggest it there, it'll probably be implemented pretty quickly! In the meantime though, I think it's okay to add all but one :)

from fantoccini.

jonhoo avatar jonhoo commented on May 27, 2024

Yup, I agree, that would be really handy! But unfortunately all WebDriver supports is to fetch all the cookies of the current document. Maybe that would still be useful to expose though? There are also commands for adding a cookie, and for deleting one. Together, those three may at least get you close to what you want? It should be pretty easy to add support for those to fantoccini if you want to open a PR for me to look at!

from fantoccini.

Boscop avatar Boscop commented on May 27, 2024

Yes, please support adding cookies :)

from fantoccini.

aksiksi avatar aksiksi commented on May 27, 2024

@jonhoo I'm working on a PR to add the 5 cookie-related functions as defined in 16. Cookies.

One challenge with defining APIs is in how to pass in/return a cookie. The two options I'm considering are:

1. Accept/return cookies as serde_json::Values

Straightforward implementation, just pass everything along to the webdriver crate and you're done. Users will need to make sure the parameters are of the correct types by checking the spec.

2. Accept/return cookies as a cookie::Cookie

This requires a bit more code within fantoccini to convert to/from JSON cookies for WebDriver. In particular, WebDriver encodes the Max-Age of a cookie as a u64 Unix timestamp, whereas cookie::Cookie requires a Duration. We'll probably need to pull in a datetime crate like chrono to be able to resolve this difference.

The two advantages of this approach are that users will be able to:

  1. More easily (and safely) inspect cookies returned by WebDriver (e.g., client.get_named_cookie(&name).await?.value())
  2. Construct cookies dynamically via cookie::CookieBuilder.

Thoughts?

from fantoccini.

aksiksi avatar aksiksi commented on May 27, 2024

Actually, I hit a bit of a snag while implementing the add_cookie operation... webdriver::command::AddCookieParameters does not implement Serialize, which means that fantoccini can't serialize the struct to JSON for the POST request :(

I don't actually need add_cookie, but I'm not sure if it would make sense to add all but one of the supported cookie operations.

from fantoccini.

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.