Creating Cookies in Ranorex

Ask general questions here.
tiffin.filion
Posts: 56
Joined: Thu Oct 29, 2020 12:47 am

Creating Cookies in Ranorex

Post by tiffin.filion » Wed Jun 01, 2022 2:22 am

I'm trying to use C# to create a cookie to block a popup on a site we're testing. But using code from: https://docs.microsoft.com/en-us/previo ... (v=vs.100) it doesn't appear that Ranorex will let me even use HttpRequest.

I've tried adding ("using") System.Net.Http, System.Web.Http, but it still isn't available when I start typing the code.

I tried HttpServer.ResponseCookies & HttpServer.ResponseCookie but they don't seem to work for setting cookies. They both say they don't contain a constructor that contains 1 argument.

Any ideas?

Here's what I've tried:

Code: Select all

 HttpServer.ResponseCookie myHelmsCookie = new HttpServer.ResponseCookie("helms-dismissed");
         	myHelmsCookie.Value = "true";
And this code can't be found when I start entering into Ranorex:

Code: Select all

HttpCookie HelmsCookie = Request.Cookies.Get("helms-dismissed");

    if (HelmsCookie == null) {
      // Cookie doesn't exist so create it
      HelmsCookie = new HttpCookie("helms-dismissed");
      HelmsCookie.Value = "true";
      Response.Cookies.Add(HelmsCookie);
    }
    else {
      // change value to true
      HelmsCookie.Value = "true";
      Response.Cookies.Add(HelmsCookie);
    }

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

Re: Creating Cookies in Ranorex

Post by odklizec » Wed Jun 01, 2022 8:25 am

Hi,

Please check this post...
https://stackoverflow.com/a/32194110/11712123
Hope this helps?
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

tiffin.filion
Posts: 56
Joined: Thu Oct 29, 2020 12:47 am

Re: Creating Cookies in Ranorex

Post by tiffin.filion » Wed Jun 01, 2022 8:15 pm

Still not able to access HttpCookies or HttpResponse when I begin typing in Http.

I'm trying to do it this way, as using JavaScript doesn't seem to work when running tests on Android devices in BrowserStack.

rajkumar14
Posts: 1
Joined: Fri Jun 03, 2022 11:06 am

Re: Creating Cookies in Ranorex

Post by rajkumar14 » Sat Jun 04, 2022 8:46 am

I'm trying to do it this way..