2

I'm trying to save the authentication of my account on Discord and the file successfully saved the cookies after I logged in but when I tried to load the cookies It didn't change the cookies at all and It asked me to log in again this problem happened with raw selenium as well don't provide a solution with pickle package I tried everything only worked with playwright package and I hope I find solution with seleniumbase

from seleniumbase import BaseCase
BaseCase.main(__name__, __file__)

class MyTestClass(BaseCase):
    def test_swag_labs(self):
        self.open("https://discord.com/")
        self.sleep(5)
        # self.save_cookies(name="cookies.txt")
        self.load_cookies(name="cookies.txt")
        self.open("https://discord.com/channels/@me")
        self.sleep(5)

1 Answer 1

0

Saving and loading cookies might not be enough to recreate the state. A better option would be setting a custom user_data_dir for the tests, and then reusing that user_data_dir for later tests.

With the SeleniumBase pytest format, you can set it via command-line option:

pytest --user-data-dir=my_data_dir
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks a lot, Michael, It works fine now, I know you're the one who created the seleniumbase I saw your videos on YouTube when I was searching for bypass Cloudflare, I encourage you to keep developing the package for me it is the best automation package in the market right now so thank you so much and keep it up
Great! Thank you. Be sure to mark the answer as the "Accepted" solution on Stack Overflow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.