Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

251
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda