Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

240
Views
Selenium Tests add Cookies after login

So i working with one Project written on Svelte. For this application i need to write many tests using Selenium JS. I try to write some of the tests to check the Page-content, but i got a problem with authorisation... By my application on home page there is a button, after press the button it will generating in java backend special access Token, which expires in 15 minutes. So my test look likes :

const URL = "http://localhost:5000"



describe('SVELTE CLIENT APP', function() {
    var driver;
    before(function () {
        driver = new webdriver.Builder()
            .forBrowser('chrome')
            .build();

    });


describe('Navigation with Auth', async function () {


        it('Experiment', async function (){

         
            //get current domain 
            await driver.get(URL);

            //Authorisation Click on Button 
            await driver.findElement(webdriver.By.css('body > div > fieldset:nth-child(6) > div:nth-child(2) > span > button > span')).click();

            
            // try to get actual Cookies after Authorisation, but it doesn't work 
            await driver.manage().getCookies().then(function (cookie) {
                console.log(cookie);
            });
            
            // Set the Cookies per Hand
            await driver.manage().addCookie({name:"AUTH_COOKIE", value:"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJicm9tYmVydGplQGdtYWlsLmNvbSIsIm5iZiI6MTYzNzA5MjE2MywiaWQiOiIxIiwibG9naW4iOiJicm9tYmVydGplIiwiZXhwIjoxNjM3MDkzMDYzLCJlbWFpbCI6ImJyb21iZXJ0amVAZ21haWwuY29tIiwiYXV0aG9yaXRpZXMiOiJS..."});
            // get a page with the cookie
            
            
            //....
        });
    });

So how i can get this Cookie value after Authorisation using Selenium? Any idea ? enter image description here

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!