Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set and Get Cookies #236

Closed
advancedlogic opened this issue Feb 22, 2019 · 5 comments
Closed

Set and Get Cookies #236

advancedlogic opened this issue Feb 22, 2019 · 5 comments
Assignees
Labels
area/drivers/cdp Cdp driver area/drivers HTML drivers status/proposal New proposal
Milestone

Comments

@advancedlogic
Copy link

In case of login into a website it would be helpful to get the cookies and reuse them to control the session (avoiding to login every time)

@ziflex
Copy link
Member

ziflex commented Feb 23, 2019

@advancedlogic currently Ferret uses Incognito window for each query, that's why none of data gets persisted. But it should be okay in between transitions within a single query.

We might consider to pass extra params to the CDP driver in order to change the behavior and use regular windows.
But Incognito mode will remain as a default one.

@ziflex ziflex added status/proposal New proposal area/drivers/cdp Cdp driver area/drivers HTML drivers labels Feb 23, 2019
@advancedlogic
Copy link
Author

I understand the incognito mode’s choice but it would be great to set cookies (getting the cookies and storing them somewhere after the 1st login)to avoid logging in every time with the risk of being banned.

@ziflex ziflex self-assigned this Feb 27, 2019
@ziflex ziflex added this to the v0.7 milestone Mar 13, 2019
ziflex added a commit that referenced this issue Mar 15, 2019
* Added KeepCookies option to CDP driver

* Added LoadDocumentParams

* Added COOKIE_GET and COOKIE_SET methods
@ziflex
Copy link
Member

ziflex commented Mar 16, 2019

@advancedlogic hey, the cookie support has landed on master branch.
Here are example how you can use them:

LET doc = DOCUMENT(@url, {
    driver: "cdp",
    cookies: [{
        name: "x-e2e",
        value: "test"
    }]
})

LET doc = DOCUMENT(@url, {
    driver: "cdp"
})

COOKIE_SET(doc, {
    name: "x-e2e",
    value: "test"
})
LET doc = DOCUMENT(@url, {
    driver: "cdp"
})

LET cookie = COOKIE_GET(doc, "x-ferret")
LET cookie_2 = doc.cookies
LET doc = DOCUMENT(@url, {
    driver: "cdp",
    cookies: [{
        name: "x-e2e",
        value: "test"
    }, {
        name: "x-e2e-2",
        value: "test2"
    }]
})

COOKIE_DEL(doc, COOKIE_GET(doc, "x-e2e"), "x-e2e-2")

@ziflex
Copy link
Member

ziflex commented Mar 16, 2019

Let me know how it works in your case. I would like to make it stable for v0.7 release.

@advancedlogic
Copy link
Author

thanks :)

3timeslazy pushed a commit to 3timeslazy/ferret that referenced this issue Apr 10, 2019
* Added KeepCookies option to CDP driver

* Added LoadDocumentParams

* Added COOKIE_GET and COOKIE_SET methods
3timeslazy pushed a commit to 3timeslazy/ferret that referenced this issue Apr 10, 2019
author Tim Voronov <[email protected]> 1552622815 -0400
committer Владимир Фетисов <[email protected]> 1554919032 +0300

parent b45f889
author Tim Voronov <[email protected]> 1552622815 -0400
committer Владимир Фетисов <[email protected]> 1554919029 +0300

Updated style template

Feature/MontFerret#236 cookies (MontFerret#242)

* Added KeepCookies option to CDP driver

* Added LoadDocumentParams

* Added COOKIE_GET and COOKIE_SET methods

Updated CHANGELOG

Updated nav example

fix order of arguments (MontFerret#269)

Updated RAND function (MontFerret#271)

* Updated RAND function

* renamed a func

Linter Cleanup (MontFerret#276)

* linter cleanup

* fix default case

Bump github.com/mafredri/cdp from 0.22.0 to 0.23.0 (MontFerret#278)

Bumps [github.com/mafredri/cdp](https://github.com/mafredri/cdp) from 0.22.0 to 0.23.0.
- [Release notes](https://github.com/mafredri/cdp/releases)
- [Commits](mafredri/cdp@v0.22.0...v0.23.0)

Signed-off-by: dependabot[bot] <[email protected]>

fix diff
3timeslazy pushed a commit to 3timeslazy/ferret that referenced this issue Apr 10, 2019
* Added KeepCookies option to CDP driver

* Added LoadDocumentParams

* Added COOKIE_GET and COOKIE_SET methods
3timeslazy pushed a commit to 3timeslazy/ferret that referenced this issue Apr 10, 2019
author Tim Voronov <[email protected]> 1552622815 -0400
committer Владимир Фетисов <[email protected]> 1554919032 +0300

parent b45f889
author Tim Voronov <[email protected]> 1552622815 -0400
committer Владимир Фетисов <[email protected]> 1554919029 +0300

Updated style template

Feature/MontFerret#236 cookies (MontFerret#242)

* Added KeepCookies option to CDP driver

* Added LoadDocumentParams

* Added COOKIE_GET and COOKIE_SET methods

Updated CHANGELOG

Updated nav example

fix order of arguments (MontFerret#269)

Updated RAND function (MontFerret#271)

* Updated RAND function

* renamed a func

Linter Cleanup (MontFerret#276)

* linter cleanup

* fix default case

Bump github.com/mafredri/cdp from 0.22.0 to 0.23.0 (MontFerret#278)

Bumps [github.com/mafredri/cdp](https://github.com/mafredri/cdp) from 0.22.0 to 0.23.0.
- [Release notes](https://github.com/mafredri/cdp/releases)
- [Commits](mafredri/cdp@v0.22.0...v0.23.0)

Signed-off-by: dependabot[bot] <[email protected]>

fix diff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/drivers/cdp Cdp driver area/drivers HTML drivers status/proposal New proposal
Projects
None yet
Development

No branches or pull requests

2 participants