How to get browser sessionId using Selenium webdriver

13,253

You can cast to a concrete type, e.g. RemoteWebDriver, which they all inherit from, and also implements getSessionId:

((RemoteWebDriver) driver).getSessionId()
Share:
13,253
sjr
Author by

sjr

Updated on June 14, 2022

Comments

  • sjr
    sjr almost 2 years

    I'm using selenium webdriver (php-webdriver-bindings Yii extension) and I'm trying to get the browser sessionId (the one that the test will be using). I thought I could get this through webdriver, but that doesn't seem to be the case. Webdriver has a sessionId, but that is not the one the test browser is using.

    I'm trying to login prior to the test running to allow my tests to be an authenticated user which will allow them to access the pages I'm testing.

    I've been researching and testing this for a few days now and I'm at a loss. Any help would be greatly appreciated.

    Thanks.