Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Handling Cookies in Selenium WebDriver

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 423
    Comment on it

    User can handle the cookies in Selenium WebDriver. Here, we discuss this in detail:

     

     

    1. Add Cookie: User can add a specific cookie. Also, if the cookie's domain name left blank then it will be assumed that cookie is meant for the domain of the current document.


    Method Name:addCookie(Cookie cookie)


    Syntax: driver.manage().addCookie(arg0);


    Parameters: cookie - Name of the cookie to add.

     

     

    2. Delete Cookie: User can delete a cookie.


    Method Name: deleteCookie(Cookie cookie)


    Syntax: driver.manage().deleteCookie(arg0);


    Parameter: Cookie

     

     

    3. Delete Cookie with Name: User can delete the specific cookie by given its name.


    Method Name: deleteCookieNamed(java.lang.String name)


    Syntax: driver.manage().deleteCookieNamed(arg0);


    Parameters: The name of the cookie to delete

     

     

    4. Delete All Cookies: User can delete all cookies from the current domain.


    Method Name: deleteAllCookies()


    Syntax: driver.manage().deleteAllCookies();

     

     

    5. Get Cookies: User can get all cookies from the current domain.


    Method Name: getCookies()


    Syntax: driver.manage().getCookies();


    Returns: Set of cookies for the current domain.

     

     

    6. Get the Cookie with Specific Name: User can get a specific cookie by given its name.


    Method Name: getCookieNamed(java.lang.String name)


    Syntax: driver.manage().getCookieNamed(arg0);


    Parameters: name - the name of the cookie


    Returns: It returns the cookie value according to the given cookie name. Also, if not found then it will return null.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: