Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create cookie using selenium?

Tags:

selenium-rc

I want to create a cookie using selenium. I have seen a method which supports this like selenium.createcookie(arg1,arg0), but I'm a bit confused about the arguments passed. Can anyone please give me an example?

like image 204
pooh Avatar asked Feb 18 '11 05:02

pooh


People also ask

Can we add cookies in Selenium?

We can send cookies with Selenium webdriver. A cookie is stored in a key value pair. First, we have to add cookies, then can delete them.

How we can clear the cookie in Selenium?

Navigate to the chrome settings page with Selenium by executing the driver. get('chrome://settings/clearBrowserData') . Click on the Clear Data button to clear the cache.


1 Answers

createCookie ( nameValuePair,optionsString ) Create a new cookie whose path and domain are same with those of current page under test, unless you specified a path for this cookie explicitly.

Arguments:

  1. nameValuePair - name and value of the cookie in a format "name=value"

  2. optionsString - options for the cookie. Currently supported options include 'path' and 'max_age'. the optionsString's format is "path=/path/, max_age=60". The order of options are irrelevant, the unit of the value of 'max_age' is second.

source: Selenium reference

like image 104
Aleksi Yrttiaho Avatar answered Nov 04 '22 02:11

Aleksi Yrttiaho