Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

Ruby bindings can't get session_id #5240

Closed
lukeis opened this issue Mar 4, 2016 · 14 comments
Closed

Ruby bindings can't get session_id #5240

lukeis opened this issue Mar 4, 2016 · 14 comments

Comments

@lukeis
Copy link
Member

lukeis commented Mar 4, 2016

Originally reported on Google Code with ID 5240

What steps will reproduce the problem?
1. $driver.bridge.session_id

What is the expected output? What do you see instead?
Expected:
"f6fccdac-f9e4-4649-8ba0-d4ede335a9e3"

Actual:
NoMethodError: private method `bridge' called for #<Selenium::WebDriver::Driver:0x427f0529d675aaa4
browser=:iOS>

Selenium version: selenium-webdriver (2.30.0)

It's an API limitation, not specific to OS or browser. I can getSessionId in Java but
not Ruby.
http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/remote/RemoteWebDriver.html#getSessionId%28%29

The method is private in Ruby.
http://selenium.googlecode.com/svn/trunk/docs/api/rb/Selenium/WebDriver/Remote/Bridge.html#session_id-instance_method

Please provide any additional information below. A sample reduced test
case, or a public URL that demonstrates the problem will intrigue our merry
band of Open Source developers far more than nothing at all: they'll be far
more likely to look at your problem if you make it easy for them!

This is a work around:
$driver.send(:bridge).session_id

Reported by matt@bootstraponline.com on 2013-02-26 16:24:54

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Reported by barancev on 2013-02-26 19:31:52

  • Labels added: Lang-Ruby

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

What's the use case? Most people who think they need this are missing the right way
to achieve what they want.

Reported by jari.bakken on 2013-02-26 19:42:54

  • Status changed: NeedsClarification
  • Labels removed: Status-Untriaged

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

It's impossible to use Sauce properly without this feature in the Selenium Ruby bindings.
The Selenium Java bindings support it already.

https://github.com/appium/ruby_console#cucumber-sauce-integration


Reported by matt@bootstraponline.com on 2013-02-26 19:47:12

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

If you're dealing with a remote driver, you should be able to get the session id through
driver.capabilities (can't recall the exact key right now).

Reported by jari.bakken on 2013-02-26 20:12:10

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

I don't see it in driver.capabilities.

#<Selenium::WebDriver::Remote::Capabilities:0x007f87030b8880
 @capabilities=
  {:browser_name=>"iOS",
   :version=>"6.0",
   :platform=>:mac,
   :javascript_enabled=>true,
   :css_selectors_enabled=>nil,
   :takes_screenshot=>true,
   :native_events=>nil,
   :rotatable=>nil,
   :firefox_profile=>nil,
   :proxy=>nil,
   "webStorageEnabled"=>false,
   "locationContextEnabled"=>false,
   "databaseEnabled"=>false}>

Why don't the Ruby bindings have feature parity with the other languages for getting
session id?

Reported by matt@bootstraponline.com on 2013-02-26 20:21:49

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Ruby has a single Driver class, not a RemoteWebDriver, FirefoxDriver etc like Java (it's
not a design I love, but it's what we have). Since not all implementations are based
on the remote protocol, there's no guarantee that a session id is used by the underlying
implementation, thus we don't want to have this method on the generic Driver class.


We do have mechanisms to extend the Driver instance at runtime based on the underlying
implementation though, and that's probably reasonable here since you're facing a misbehaving
server (it should really be sending back the session id as part of the capabilities,
as "webdriver.remote.sessionid").

Reported by jari.bakken on 2013-02-26 23:24:19

  • Status changed: Accepted

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Out of curiosity, what server are you running against? Just did a quick check against
iPhone on Sauce, and they appear to get the capabilities right.

Reported by jari.bakken on 2013-02-26 23:36:27

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

There should be a better way to get session id than $driver.send(:bridge).session_id

I'm running against the iOS Simulator using Appium running locally. The above hack
with .send returns the proper session id. I test locally and then have the tests run
on Sauce.

Reported by matt@bootstraponline.com on 2013-02-26 23:49:56

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

I can fix Appium to send back session ID with desired caps. What should the JSON key
be? "sessionId"? Or as Jari said, "webdriver.remote.sessionid" ?

Reported by jlipps on 2013-02-27 22:54:34

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

"webdriver.remote.sessionid" - which is what's used by the Java server.

Reported by jari.bakken on 2013-02-27 22:55:47

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Oh, and you should be sending back the actual capabilities, not the desired ones :)

Reported by jari.bakken on 2013-02-27 22:56:40

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

This issue was closed by revision 638d6a56051d.

Reported by jari.bakken on 2013-03-02 19:09:12

  • Status changed: Fixed

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

This issue was closed by revision 638d6a56051d.

Reported by jari.bakken on 2013-03-04 22:24:42

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Reported by luke.semerau on 2015-09-17 18:16:55

  • Labels added: Restrict-AddIssueComment-Commit

@lukeis lukeis closed this as completed Mar 4, 2016
@SeleniumHQ SeleniumHQ locked and limited conversation to collaborators Mar 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant