Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

sadhakbj's avatar

Session Sharing for Selenium and integrated

I am using Laracasts integrated with selenium. I am getting the problem with the log in. After i log in i am nt able to show the new page. The same log in page displays again and again. I need session sharing mechanism for this. Any one has some idea ?

0 likes
7 replies
sadhakbj's avatar

I have the following test case:

<?php

use Laracasts\Integrated\Extensions\Selenium as Selenium;

class AdminTest extends Selenium
{
 public $baseUrl = 'http://localhost:8000';
    /** @test */
    public function testItShouldCreateNewMainContracts()
    {
          $this->login()
          ->visit('contract')
                 ->andClick('Add Contract')
                 ->visit('contract/create')
                 ->submitForm('Submit', $input);         
         }

    public function login()
    {
        $this->visit('/')
             ->andType('admin@abc.app', 'email')
             ->andType('admin123', 'password')
             ->press('Login');

        return $this;
    }
        
 }

It shows the log in page it provides the credentials and then again the same page in a new window is displayed.

bobbybouwmann's avatar

I guess this is wrong too

->visit('contract')
->andClick('Add Contract') // This will redirect you to contract/create
->visit('contract/create') // You don't need this one here!

Now for your problem, I'm not sure what's going on here... It works fine on my end!

sadhakbj's avatar

I tried the following code:

 /** @test */
    public function firsttest()
  {
    $this->login()
        ->visit('contract/create')
        ->andSee('Add Contract');
  }


    public function login()
{
    return $this->visit('/')
         ->andType('admin@nrgi.app', 'email')
         ->andType('admin123', 'password')
         ->press('Login');

}

But still i do have the same problem.

I just want to share the session on selenium. Is there any way ? Please help me !!

sadhakbj's avatar
sadhakbj
OP
Best Answer
Level 17

I got the solution by myself.

 /** @test */
    public function firstTest()
  {
    $this->login()
        ->click('create')
        ->andSee('Add Contract');
  }

Instead of visiting the url i need to click the links and go to create page else it will start a new session and new window will appear. I need the solution for

$this->visit('contract/create'); also

The solution is:

okawei's avatar

What was your solution for this?

1 like

Please or to participate in this conversation.