Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 789
RJC Avatar asked Mar 10 '17 16:03

RJC


1 Answers

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.

like image 161
cnishina Avatar answered Oct 13 '22 01:10

cnishina