LambdaTest Community

Find answers, support, and inspiration from other users

LambdaTest Community

keep session after login - selenium - javascript

I am trying to automate couple of pages using selenium web driver and node js . I was able to login , but after login I want to use same session initiated by web driver so that I can do automated testing on session protected page. This is my attempt

async function login(){
    Let  d =  await new Builder()
    await d.get('')
    await d.findElement('username')).sendKeys('admin ')
    await d.findElement('password')).sendKeys('admin');
    await d.findElement(By.css('button[type="submit"]')).click();
    await d.getPageSource().then(function(content) {

            if(content.indexOf('Welcome text') !==-1 ) {
             console.log('Test passed');
             console.log('landing page');
             d.get('') //this is still going to login page as i cannot use the previous session 
            } else {
                console.log('Test failed');
                return false;



Am I accidentally discarding the browser after login.

Up Vote Down Vote 0 Votes
Posted 29 days ago