Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Selenium Essentials

You're reading from   Selenium Essentials Get to grips with automated web testing with the amazing power of Selenium WebDriver

Arrow left icon
Product type Book
Published in Mar 2015
Publisher
ISBN-13 9781784394332
Pages 194 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Prashanth Sams Prashanth Sams
Author Profile Icon Prashanth Sams
Prashanth Sams
Arrow right icon
View More author details
Toc

Cookies


Cookies are generally stored in a web browser to identify the user's activity when browsing a web page. Selenium WebDriver handles web browser cookies by finding, deleting, modifying, and adding the cookies. It provides an excellent mechanism to modify cookies for high-level automation testing. Let's discuss Selenium WebDriver cookies, as follows:

  • The getCookies() method returns cookies present in a loaded page. The following is the syntax for this function:

    driver.manage().getCookies();

    Some of the useful tasks that you can perform with the help of getCookies() function are discussed as follows:

    Return cookies: The getCookies() method captures all the cookies generated in a web page. Let's see a model to get to know how we can return the entire cookie ID and expiry date and time and the domain name of each and every cookie:

    driver.get("https://www.google.co.in");
    System.out.println(driver.manage().getCookies());
    • The following piece of code lets you explain how to get all the cookies in...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime