Translator version 5.1.1 malfunction selenium-webdriver

I recently upgraded to Protractor 5.1.1 and ran into some problems setting cookies through browser.manage (). addCookie ()

The API has changed between versions 2 and 3 of Selenium-webdriver to expect an object, not the previous arguments 2..6. When I make changes to my code to use this object, the typescript compiler complains 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 @ types / selenium-webdriver is in the package. json of protractor v5.1.1 points to version 2.53.39. The version of the actual selenium-webdriver is the same package.json reference 3.0.1.

Should it be the same value? Anyone else having problems with this?

+6
source share
2 answers

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

workaround

Here is a workaround:

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

We set the return object of the browser.manage of any objects. Then we can give it the addCookie method.

OR

definitions of updates

you can update @ type / selenium-webdriver definitions to version 3.

+2
source

I have the same problem! I really know that @ type / selenium-driver is now updated to version 3.0.0.

I was not lucky with this, but you can try installing it directly (for example, npm install --save-dev @ types / selenium-webdriver) and add it to your list of types in the tsconfig.json file (i.e. types: [ "selenium-webdriver" ].

0
source

Source: https://habr.com/ru/post/1015661/


All Articles