You can follow the steps below to explore how to log in to a web page with Cookie.
-
Install “EditThisCookie“ extension on the Chrome browser
-
Open the Chrome browser, and navigate to a web page such as
Stack Overflow - Where Developers Learn, Share, & Build Careers
-
Sign in to this web page manually
-
Click on the “EditThisCookie“ extension, and find the Authentication Cookie information.
Tips: If we don’t know which cookie should we get, try to delete each of them and refresh the page to check if the logged-in account can be signed out.
-
From the Katalon Studio, use the scripts below:
WebUI.openBrowser('')
WebUI.navigateToUrl('https://stackoverflow.com/questions/10340373/how-to-send-cookies-with-selenium-webdriver')
Cookie cookie = new Cookie.Builder("acct", "<<Value of cookie>>")
.domain(".stackoverflow.com")
.expiresOn(new Date(1663752309000))
.isHttpOnly(true)
.isSecure(true)
.path("/")
.build()
WebDriver driver = ((EventFiringWebDriver) DriverFactory.getWebDriver()).getWrappedDriver()
driver.manage().addCookie(cookie)
WebUI.refresh()
Tips: to full fill the information above, you can follow the small steps below
-
Copy the cookie
-
Paste it to a text editor
-
Find out the related information to fill in the scripts such as “httpOnly“, “domain“, “expiresOn“, “secure“, etc.
Finally, the output looks like the video.
Comments
0 comments
Please sign in to leave a comment.