How to get cookies from Browser

Best practices, code snippets for common functionality, examples, and guidelines.
User avatar
jarrettmk
Posts: 16
Joined: Wed Sep 19, 2018 6:10 pm

How to get cookies from Browser

Post by jarrettmk » Mon Jan 07, 2019 8:32 pm

Our web application sets a cookie that I need to retrieve and decrypt in order to get some information needed to validate later in my test.

I have looked at Host.Current as well as the following to try and get the cookies with no luck...
var cookies = Repository.OURSITE.Self.ExecuteScript("document.cookie");
and
var cookies = Repository.OURSITE.Self.ExecuteScript("document.cookie.split(';');");
both return "undefined".

I know with straight Selenium you can use something like:
var cookies = remoteWebDriver.Manage().Cookies;
or
var cookies = driver.Manage().Cookies;
However, I cannot find anything like this that is equivalent in Ranorex.

Does anyone know how to get the browser's cookies?
Jarrett Karyshyn
Quality Assurance & Automation Engineer
USA - EST (UTC−05:00)/EDT (UTC−04:00)
Image

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to get cookies from Browser

Post by odklizec » Tue Jan 08, 2019 9:40 am

Hi,

Question answered here:
how-to-get-cookies-from-browser-t13240.html#p52198
Please do not post the same question in multiple forum areas. Thanks ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration