How to Obtain the Kobiton Session ID

The Kobiton Session ID is a useful value that you may need for a number of tasks. It can be obtained from the RemoteWebDriver or AppiumDriver instance. See the code snippets for the specified languages below:

JavaScript

  • Webdriver WD
import BPromise from 'bluebird' 
const sessionCapabilities = await BPromise.fromCallback((done) => driver.sessionCapabilities(done))
console.log(sessionCapabilities.kobitonSessionId)
  • WebdriverIO
const sessionInfo = await client.getSession() 
console.log('kobitonSessionId', sessionInfo.kobitonSessionId)
  • Protractor
browser.getSession().then((session) => { 
let capabilities = new Map()
capabilities = session.caps_.map_
const kobitonSessionId = capabilities.get('kobitonSessionId')
console.log('kobitonSessionId', kobitonSessionId)
})

Java

  • Selenium Webdriver
String kobitonSessionId = driver.getCapabilities().getCapability("kobitonSessionId").toString(); 
System.out.println("kobitonSessionId: " + kobitonSessionId);
  • Appium Driver
String kobitonSessionId = driver.getSessionDetails().get("kobitonSessionId").toString(); 
System.out.println("kobitonSessionId: " + kobitonSessionId);

C#

  • Selenium Webdriver
string kobitonSessionId = driver.Capabilities.GetCapability("kobitonSessionId").ToString(); 
Console.WriteLine("kobitonSessionId: " + kobitonSessionId);
  • Appium Driver
string kobitonSessionId = driver.SessionDetails["kobitonSessionId"].ToString(); 
Console.WriteLine("kobitonSessionId: " + kobitonSessionId);

Python (Selenium Webdriver & Appium Driver)

kobitonSessionId = self.driver.desired_capabilities.get('kobitonSessionId') 
print(kobitonSessionId)

PHP

Selenium Webdriver

$getCapabilities = $this->driver->getCapabilities()->toArray(); 
$kobitonSessionId = $getCapabilities['kobitonSessionId'];
print($kobitonSessionId);

Ruby

Selenium Webdriver

puts @driver.capabilities['kobitonSessionId']

Appium Driver

puts @driver.driver.capabilities['kobitonSessionId']

 

Was this article helpful?
0 out of 0 found this helpful