C# Example Script

This example shows how you can use C# in Eggdrive. For more information about how to use Eggdrive, see Using Eggdrive.

using System;

using CookComputing.XmlRpc;

namespace Eggdrive

{

public class Response

{

public string Output { get; set; }

public double Duration { get; set; }

public object ReturnValue { get; set; }

public object Result { get; set; }

public override string ToString()

{

return String.Format("(Output={0}, Duration={1}, ReturnValue={2}, Result={3})",

this.Output,

this.Duration,

this.ReturnValue,

this.Result);

}

}

[XmlRpcUrl("http://localhost:5400")]

public interface EggdriveProxy : IXmlRpcProxy

{

[XmlRpcMethod("StartSession")]

string StartSession(string epfSuitePath);

 

[XmlRpcMethod("Execute")]

Response Execute(string command);

 

[XmlRpcMethod("EndSession")]

string EndSession(string arg = "");

}

class Program

{

static void Main(string[] args)

 

// Create Eggdrive proxy

 

{

EggdriveProxy proxy =

XmlRpcProxyGen.Create<EggdriveProxy>();

try

{

// Start the session

string message = proxy.StartSession("C:\\Documents\\EPF.suite");

Console.WriteLine(message);

 

//Establish a connection from Eggdrive to a SUT

Response response = proxy.Execute("Connect \"localhost\"");

Console.WriteLine(response.ToString());

 

// Launch Chrome (where, "Chrome" is a saved image of its icon)

response = proxy.Execute("DoubleClick \"Chrome\"");

Console.WriteLine(response.ToString());

 

// Wait for Chrome to load, then click on the search field to type something

response = proxy.Execute("Click (Text: \"Search Google or type a URL\", WaitFor: 10)");

Console.WriteLine(response.ToString());

 

// Go to the Eggplant website

response = proxy.Execute("TypeText(\"https://www.eggplantsoftware.com\" & returnKey)");

Console.WriteLine(response.ToString());

 

// Wait for the banner text

response = proxy.Execute("WaitFor 10.0, (Text: \"Let's rid the world of bad software\")");

Console.WriteLine(response.ToString());

 

// Quit Chrome

response = proxy.Execute("TypeText(altKey, f4)");

Console.WriteLine(response.ToString());

}

catch (Exception exc)

{

Console.WriteLine(exc);

}

//End the session

finally{

string message = proxy.EndSession();

Console.WriteLine(message);

}

}

}

}

 

This topic was last updated on June 10, 2020, at 03:02:15 PM.

Eggplant icon Eggplantsoftware.com | Documentation Home | User Forums | Support | Copyright © 2020 Eggplant