Nick Dong
Nick Dong

Reputation: 3736

selenium getSessionId did not get JsessionID

When I use getSessionId() to fetch Session ID of current window which should be identified by current driver. Code like this.

String sessionId = ((RemoteWebDriver) driver).getSessionId().toString();

The value of sessionId is different with JSESSIONID in chrome Resources->Cookies->JSESSIONID.

Does RemoteWebDriver not get the correct value? How to do get correct session id? Thanks.

Upvotes: 0

Views: 5863

Answers (1)

Manigandan
Manigandan

Reputation: 5080

Try this:

//Assume Wed Driver is initiated properly 
Cookie cookie= driver.manage().getCookieNamed("JSESSIONID");
System.out.println(cookie.getValue());

Upvotes: 4

Related Questions