RJC
RJC

Reputation: 385

Protractor 5.1.1 selenium-webdriver version inconsitency

I've recently upgraded to Protractor 5.1.1 and am facing some issues when setting cookies via browser.manage().addCookie()

The API has changed between versions 2 and 3 of Selenium-webdriver to expect an object rather than the previous 2..6 arguments. When I make the changes to my code to use the object, the typescript compiler complains saying that it expects 2..6 arguments.

old api:

browser.manage().addCookie('cookieName',  'cookieVal');

new api:

browser.manage().addCookie({name:'cookieName', value: 'cookieVal'});

I think this is because the @types/selenium-webdriver in the package.json of protractor v5.1.1 is pointing at version 2.53.39. The version of the actual selenium-webdriver the same package.json is referencing is 3.0.1.

Should this be the same value? Is anyone else experiencing problems with this?

Upvotes: 6

Views: 519

Answers (2)

craig
craig

Reputation: 5016

Yup, this is happening because the type definitions was not written at the time.

workaround

Here is the workaround for now:

(browser.manage() as any).addCookie({name:'cookieName', value: 'cookieVal'});

We are setting browser.manage returned options object to any. Then we can give it the addCookie method.

OR

upgrade definitions

you could upgrade your @types/selenium-webdriver type definitions to version 3.

Upvotes: 2

Jason Ruesch
Jason Ruesch

Reputation: 1

I'm having the same problem! I do know that the @types/selenium-driver is now updated to version 3.0.0.

I haven't had luck with this, but you could try installing it directly (i.e. npm install --save-dev @types/selenium-webdriver) and adding it to your list of types in your tsconfig.json file (i.e. types: [ "selenium-webdriver" ].

Upvotes: 0

Related Questions