Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get session id on Selenium webdriver using Python?

Im using SauceLabs and I need the sessionId to get the Job Id there and use it to set pass/fail status during execution of the test. How can I get the session Id using python?

like image 521
Gus Avatar asked Nov 13 '13 03:11

Gus


People also ask

How can I get Webdriver session ID in Selenium?

We can get the webdriver session id with Selenium webdriver using the SessionId class. A session id is a distinctive number that is given to the webdriver by the server. This number is utilized by the webdriver to establish communication with the browser.

Can Selenium interact with an existing browser session Python?

We can interact with an existing browser session. This is performed by using the Capabilities and ChromeOptions classes. The Capabilities class obtains the browser capabilities with the help of the getCapabilities method.

How do I keep a browser session alive in Selenium?

We can keep a session alive for long Selenium scripts in automation. In Chrome browser, this can be achieved with the help of the ChromeOptions and Capabilities classes. Capabilities class can get the capabilities of the browser by using the method – getCapabilities.


1 Answers

Found it!

The value of the Selenium Remote Webdriver sessionId can be retrieved by

self.driver.session_id

That value is used on SauceLabs to identify the Jobs (Job ID)

like image 168
Gus Avatar answered Sep 21 '22 03:09

Gus