admc / wd

A node.js client for webdriver/selenium 2.
Other
1.53k stars 402 forks source link

driver.getSessionId() returns promise object #508

Open UtsavSaha opened 6 years ago

UtsavSaha commented 6 years ago

I am willing to access the session id String using the getsessionID API. However the API returns a promise object.

While performing a console.log(driver.getSessionId()), the appropriate value gets printed . // ex: d475f0fd-ab92-4c78-a395-b515975e6bcf

However while using the value as an argument to driver.attach() , the url being invoked is object promise as session id. This is primarily as the chaining methods returns the driver itself.

How can the sessionId value be accessed from the promise Object?

imurchie commented 6 years ago

Are you trying to do something like https://github.com/admc/wd/blob/65070da779a91d0e92e8d19fe844a01c766411e5/test/midway/attach-specs.js#L9

byMennen commented 6 years ago

Can you try

Var sel_obj = yield driver.getSessionId();

Then you can access it by

driver.attach(sel_obj.sessionId); //Check the syntax please. I am writing this on my phone. You can also check out async/await functionality too