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?
            Asked
            
        
        
            Active
            
        
            Viewed 1.8k times
        
    11
            
            
        - 
                    Just doing a cursory glance over at google, I found [this](http://webpython.codepoint.net/cgi_session) that might help you. Of course, if it doesn't... then I'm a jerk, and I apologize. – QuestionMarcs Nov 13 '13 at 03:36
 - 
                    Yep, that's not what I'm looking for. Thanks though – Gus Nov 13 '13 at 13:34
 
3 Answers
19
            
            
        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)
        Gus
        
- 573
 - 1
 - 5
 - 18
 
- 
                    2
 - 
                    it seems to be context.driver.session_id when in a @step, but not when in the environment handlers – simpleuser Jul 31 '19 at 21:46
 
0
            
            
        This worked for me:
BuiltIn().get_library_instance('SeleniumLibrary').driver.session_id
        Chunter4
        
- 85
 - 1
 - 1
 - 5