How do you set a cookie in Chrome?

Ranorex Studio, Spy, Recorder, and Driver.
RanoTester
Posts: 19
Joined: Mon Jan 14, 2013 7:16 pm

How do you set a cookie in Chrome?

Post by RanoTester » Fri Oct 23, 2020 12:54 am

Currently running Ranorex 9.1.1, will upgrade to the most current version sometime next week.

Any advise on how to set cookies when running Chrome?

There is one specific page in the login sequence to an app that Ranorex logs into. Once that page appears, we need to be able to instruct Ranorex to set a cookie, i.e., so that a Windows level - Username / PW prompt won't potentially appear.

This is how Katalon sets the cookie: https://docs.katalon.com/katalon-studio ... wsers.html

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

Re: How do you set a cookie in Chrome?

Post by odklizec » Fri Oct 23, 2020 7:58 am

Hi,

I'm afraid, there is no simple action to do this. You will have to use some C# code, as described here:
https://stackoverflow.com/questions/254 ... okies-file

Eventually, it may be possible to set/modify cookies via Ranorex ExecuteScript action and some JavaScript code?

Here are some examples of Ranorex ExecuteScript and JavaScript commands:
viewtopic.php?f=4&t=13048&p=51768#p51768
viewtopic.php?f=4&t=6581&p=27235#p27307
And here is an article about how to work with cookies via JavaScript...
https://www.w3schools.com/js/js_cookies.asp
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