Handing Cookies in Selenium Automated Tests

QAutomation News / By  Andreea Draniceanu

Cookies, or HTTP cookies, are pieces of data stored on the user’s computer containing information about the user and the user’s preference on a specific website. For example, a cookie can store the authentication information of the user or session information such as browsing history, so the website can improve the user’s experience based on their preferences.

In this article, we’ll see the commands used for working with cookies in Selenium.

Why we need to work with cookies in Selenium 🍪

One of the good practices in test automation states that each test should focus on only one functionality. This means that we don’t want our tests to perform too many actions through the UI before we get to the actual condition we want to verify. Let’s look at an example: you’re trying to test items added to the cart that can be ordered in an e-commerce application. But to finalize the purchase, you need to be logged in to the application. Instead of logging in through the UI, which means additional lines of code, extra test execution time, and probably some test duplication, too, you can use cookies with the user information.

Continue reading from source link

One thought on “Handing Cookies in Selenium Automated Tests

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s