Get a session ID using the Kobiton API

Learn how to get the session ID of a completed test session so you can use the Kobiton API to get session details, collect logs, capture screenshots, and more.

C#

Appium

Run the following command using C#'s Appium.WebDriver package:

string kobitonSessionId = driver.SessionDetails["kobitonSessionId"].ToString();
Console.WriteLine("kobitonSessionId: " + kobitonSessionId);

Selenium

Run the following command using C#'s Selenium.WebDriver package:

string kobitonSessionId = driver.Capabilities.GetCapability("kobitonSessionId").ToString();
Console.WriteLine("kobitonSessionId: " + kobitonSessionId);

Java

Appium

Run the following command using Java’s java-client dependency:

String kobitonSessionId = driver.getSessionDetails().get("kobitonSessionId").toString();
System.out.println("kobitonSessionId: " + kobitonSessionId);

Selenium

Run the following command using Java’s selenium-java dependency:

String kobitonSessionId = driver.getCapabilities().getCapability("kobitonSessionId").toString();
System.out.println("kobitonSessionId: " + kobitonSessionId);

JavaScript

Protractor

Run the following command using JavaScript’s protractor test automation framework:

browser.getSession().then((session) => {
  let capabilities = new Map()
  capabilities = session.caps_.map_
  const kobitonSessionId = capabilities.get('kobitonSessionId')
  console.log('kobitonSessionId', kobitonSessionId)
})

Selenium

Run the following command using JavaScript’s selenium-webdriver package:

import BPromise from 'bluebird'
const sessionCapabilities = await BPromise.fromCallback((done) => driver.sessionCapabilities(done))
console.log(sessionCapabilities.kobitonSessionId)

WebDriverIO

Run the following command using JavaScript’s wdio test automation framework:

const sessionInfo = await client.getSession()
console.log('kobitonSessionId', sessionInfo.kobitonSessionId)

PHP

Appium

Run the following command using PHP’s appium-php library:

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

Selenium

Run the following command using PHP’s php-webdriver library:

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

Python

Appium

Run the following command using Python’s Appium-Python-Client library:

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

Selenium

Run the following command using Python’s selenium package:

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

Ruby

Appium

Run the following command using Ruby’s appium_lib library:

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

Selenium

Run the following command using Ruby’s selenium-webdriver package:

puts @driver.capabilities['kobitonSessionId']