How to get browser sessionId using Selenium webdriver

php, selenium-webdriver, webdriver, yii

Solution

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

((RemoteWebDriver) driver).getSessionId()

Problem

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.

Original source