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