C# code to Login

Class library usage, coding and language questions.
Posts: 1
Joined: Tue Sep 22, 2015 11:02 am

C# code to Login

Post by dsingh » Tue Sep 22, 2015 11:06 am

Hi Team,

I am new to your tool and i need some help to login a site. I can do that by recording. But I want to do it using my C# code.
I have to do following tasks using ranorax libraries:
1. Seamless/No browser.
2. Login to website.
3. Once login, I want to read the https cookies form the browser control.

Where can I find the sample code to do the same activity.


Posts: 5
Joined: Thu Apr 03, 2014 6:32 pm

Re: C# code to Login

Post by pkaraya » Wed Sep 23, 2015 4:14 am

//Create a webdocument by domain
WebDocument webDocument = "/dom[@domain=yourdomainname"]";
// Execute a javascript code
string allcookies = webDocument.ExecuteScript("return document.cookie;");
string cookieName="thenameofthecookieyouaresearching";
string[] lines = Regex.Split(allcookies, ";");

foreach (string line in lines) {
// Extract value of selected cookie and return value as string.
if (line.StartsWith(cookieName + "=")){
cookieValue = line.Substring(line.IndexOf("=") + 1);

I hope this help you