How can I get the SessionId from a SeleniumWebDriver?

28 views
Skip to first unread message

Roy Miller

unread,
Jan 8, 2015, 9:45:36 PM1/8/15
to co...@googlegroups.com
I'm running tests at SauceLabs. I used the sample code at the bottom of the Coypu README at GitHub (specifically the SauceLabsDriver class).

The SauceLabsDriver class drives my tests without a hitch. The problem is, I want to get the SessionId when I set up a new session at SauceLabs, so I can use that Id later to retrieve the job via their REST API and update the test status "passed" attribute.

I've tried everything I can think of within the SauceLabsDriver class, but I can't figure out how to get to the SessionId. If SauceLabsDriver subclassed RemoteWebDriver, the SessionId is available, but not if it subclasses SeleniumWebDriver. I haven't been able to test with a RemoteWebDriver class yet (can't connect to Sauce from work at the moment), so I'm not sure that option would even work.

I also tried using the SauceLabsDriver class as written, then creating a Coypu BrowserSessionusing that driver, thinking that maybe I could get the native driver and cast to a RemoteWebDriver to get at the SessionId. I could do the cast, but SessionId isn't available when I do. I'm stumped.

So, a couple questions:

* Does Coypu require a SeleniumWebDriver, or can it use a straight RemoteWebDriver?
* If the former, is there any way I can get the SessionId from within the SauceLabsDriver class in the README?

Thanks. 

Adrian Longley

unread,
Jan 11, 2015, 5:59:00 AM1/11/15
to co...@googlegroups.com
On Fri, Jan 9, 2015 at 2:45 AM, Roy Miller <r...@theotherroad.com> wrote:
I'm running tests at SauceLabs. I used the sample code at the bottom of the Coypu README at GitHub (specifically the SauceLabsDriver class).

The SauceLabsDriver class drives my tests without a hitch. The problem is, I want to get the SessionId when I set up a new session at SauceLabs, so I can use that Id later to retrieve the job via their REST API and update the test status "passed" attribute.

I've tried everything I can think of within the SauceLabsDriver class, but I can't figure out how to get to the SessionId. If SauceLabsDriver subclassed RemoteWebDriver, the SessionId is available, but not if it subclasses SeleniumWebDriver.

So I think you should subclass RemoteWebDriver first, to expose the SessionId property, then you should be able to modify that sample class from the README to create an instance of your subclass instead of RemoteWebDriver, and also expose a reference to to the SessionId on that. Do you see what I mean?

Have a go, if you can't get it working I'll knock up an example for you.
 
I haven't been able to test with a RemoteWebDriver class yet (can't connect to Sauce from work at the moment), so I'm not sure that option would even work.

I also tried using the SauceLabsDriver class as written, then creating a Coypu BrowserSessionusing that driver, thinking that maybe I could get the native driver and cast to a RemoteWebDriver to get at the SessionId. I could do the cast, but SessionId isn't available when I do. I'm stumped

I would have tried this first myself. Not tried it myself, but from what you say and what I've read SessionId should be a member of RemoteWebDriver.
 
So, a couple questions:

* Does Coypu require a SeleniumWebDriver, or can it use a straight RemoteWebDriver?
* If the former, is there any way I can get the SessionId from within the SauceLabsDriver class in the README?

The example in the README is:
Thanks. 

--
You received this message because you are subscribed to the Google Groups "Coypu" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coypu+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages