Skip to content

Instantly share code, notes, and snippets.

@dapngn
Last active December 20, 2015 06:29
Show Gist options
  • Save dapngn/6086057 to your computer and use it in GitHub Desktop.
Save dapngn/6086057 to your computer and use it in GitHub Desktop.
A simple call to the Roslyn api.
private readonly ScriptEngine _engine;
public ScriptExecutor()
{
_engine = new ScriptEngine();
_engine.AddReference("System");
_engine.AddReference(this.GetType().Assembly.Location);
_engine
.AddReference( Environment
.CurrentDirectory + "\\WebDriver.dll");
_engine
.AddReference( Environment
.CurrentDirectory + "\\WebDriver.Support.dll");
_engine.ImportNamespace("System");
_engine.ImportNamespace("OpenQA.Selenium");
_engine.ImportNamespace("WebScriptRunner");
_engine.ImportNamespace("WebScriptRunner.Core");
}
public WebInteractionResult Execute(string code)
{
var result = new WebInteractionResult();
var session = _engine.CreateSession(result);
var submission = session.CompileSubmission<object>(code);
var execution = submission.Execute();
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment