Here I explained how to install MonoDevelop. As I already explained here, first download Selenium Client & WebDriver Language Bindings, in my case I downloaded this one. You will also need ChromeDriver (this time for linux), in my case I downloaded this one. 

If you try to use chromedriver for windows you will receive errors like:

OpenQA.Selenium.WebDriverException: Unexpected error. System.Net.WebException: Error: ConnectFailure (Connection refused) ---> System.Net.Sockets.SocketException: Connection refused
at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x000f7] in <filename unknown>:0
at System.Net.WebConnection.Connect (System.Net.HttpWebRequest request) [0x0019b] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.EndGetRequestStream (IAsyncResult asyncResult) [0x00043] in <filename unknown>:0
at System.Net.HttpWebRequest.GetRequestStream () [0x00057] in <filename unknown>:0
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute (OpenQA.Selenium.Remote.Command commandToExecute)


run-detectors: unable to find an interpreter for /home/stanko/Downloads/SeleniumTest/SeleniumTest/bin/Debug/chromedriver.exe

Also if you in terminal window write something like:

mono chromedriver.exe

Then you will receive error like:

Cannot open assembly 'chromedriver.exe': File does not contain a valid CIL image

That is why we need to use Linux version of chromedriver.

Download and install Chrome.

Open MonoDevelop, start new solution:

choose console project:

After creating project right click on references:


switch to .Net Assembly tab, and add selenium dll's which we downloaded previously. 

Now open Program.cs, in using section write:

using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;

In main method write something like:

ChromeDriverService service = ChromeDriverService.CreateDefaultService(@"/home/myUserName/projects/SeleniumTest/lib/chromedriver_linux64", "chromedriver");
IWebDriver driver = new ChromeDriver(service);
driver.Navigate ().GoToUrl ("");

Notice line:

ChromeDriverService service = ChromeDriverService.CreateDefaultService(@"/home/myUserName/projects/SeleniumTest/lib/chromedriver_linux64", "chromedriver");

This line we need to tell selenium that we will use Linux chromedriver, otherwise Selenium will always try to load chromedriver.exe (Windows one).

Whole application should look like this:

using System;

using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;

namespace SeleniumTest
	class MainClass
		public static void Main (string[] args)
			ChromeDriverService service = ChromeDriverService.CreateDefaultService(@"/home/myUserName/projects/SeleniumTest/lib/chromedriver_linux64", "chromedriver");
			IWebDriver driver = new ChromeDriver(service);
			driver.Navigate ().GoToUrl ("");

Of course path "/home/myUserName/projects/SeleniumTest/lib/chromedriver_linux64" change to path where you downloaded your chromedriver.

Example download from here, and don't forget to use http in your URL's otherwise Selenium will not work.

Selenium tests in java, I already explained here. Since I am not Java expert I need them to run also in .NET environment, idea is to create console application to parse few web pages, by automatizing Chrome. I am using this web site.

Download Selenium Client & WebDriver Language Bindings, in my case I downloaded this one. You will also need ChromeDriver, in my case I downloaded this one.

Start new project:

Choose console:

 Add references to previously downloaded Selenium Client & WebDriver Language Bindings (in solution explorer right mouse button on References):



In my case I decided to go on net40:

Add dll's:

In my case I decided to add also ChromeDriver to project, then I will not have explicitly to write path. Right click on the project and click add existing item:

Choose chrome driver:

Select chrome driver, choose properties:

In part Copy To Output Directory, choose Copy always. You can also choose copy if newer, but to avoid possible problems I decided to go like this:

Now I added following name spaces:

using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;

Then in Main method add code like:

IWebDriver driver = new ChromeDriver();

In line:

IWebDriver driver = new ChromeDriver();

You can also write something like:

IWebDriver driver = new ChromeDriver(@"C:\Users\myUserName\Downloads\chromedriver_win32");

Then you wouldn't need to add chrome driver into the project...

So, this is all you need to start parsing pages with Selenium. Example project download from here.

using System;
using System.Data.SqlClient;
using System.IO;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo;

namespace ConsoleApplication1
    class Program
        static void Main(string[] args)
            string[] filePaths = Directory.GetFiles(@"c:\myListOfScripts\", "*.sql");

            string connectionString = "server=myServer\\myInstance;database=myDatabase;uid=sa;pwd=mySaPwd";

            SqlConnection cn = new SqlConnection(connectionString);

            Console.WriteLine("Last how many scripts you want to execute?");
            var lastNoScript = Convert.ToInt16(Console.ReadLine());

            FileStream ostrm;
            StreamWriter writer;
            TextWriter oldOut = Console.Out;
                ostrm = new FileStream("./log.txt", FileMode.OpenOrCreate, FileAccess.Write);
                writer = new StreamWriter(ostrm);
            catch (Exception e)
                Console.WriteLine("Cannot open log.txt for writing");

            for (int i = filePaths.Length - lastNoScript; i < filePaths.Length; i++)
                Console.WriteLine("Executing script: ");

                FileInfo file = new FileInfo(@filePaths[i]);
                string script = file.OpenText().ReadToEnd();

                ServerConnection svrConnection = new ServerConnection(cn);
                Server server = new Server(svrConnection);
                catch (Exception e)
                    Console.WriteLine(script + " : Message: " + e.Message + " Inner exception: " + e.InnerException.Message);
            Console.WriteLine("Press any key...");


using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo;

you will need to add reference to files:

C:\Program Files\Microsoft SQL Server\110\SDK\Assemblies\Microsoft.SqlServer.ConnectionInfo.dll


C:\Program Files\Microsoft SQL Server\110\SDK\Assemblies\Microsoft.SqlServer.Management.Sdk.Sfc.dll

C:\Program Files\Microsoft SQL Server\110\SDK\Assemblies\Microsoft.SqlServer.Smo.dll

Your app.config file must to look like:

<?xml version="1.0"?>
<!--<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>-->
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <requiredRuntime version='v4.0.20506' safemode='true'/>
    <supportedRuntime version='v4.0'/>

To add app.config file do next:

1. On the Project menu, click Add New Item.
2. The Add New Item dialog box appears.

Select the Application Configuration File template and then click Add.

A file named app.config is added to your project.

OCR - optical character recognition, with MODI - microsoft office document imaging.

Microsoft has developed tool for OCR, which we can use it as a COM object.

First you need to install MODI on your computer, then, you can use it like this:

Document md = new Document();
String ocrText = String.Empty;

const bool ocrOrientImage = false;
const bool ocrStraightenImage = false;
md.OCR(MiLANGUAGES.miLANG_ENGLISH, ocrOrientImage, ocrStraightenImage);

var image = (MODI.Image)md.Images[0];
var layout = image.Layout;

foreach (Word word in layout.Words)
 if (ocrText.Length > 0)
   ocrText += " ";

  ocrText += word.Text;
textBox1.Text = ocrText;

Only problem is if you want to really release the object md, then you ave to use SaveAs method something like:


string path = Path.GetDirectoryName(openFileDialog1.FileName);

md.SaveAs(path + "\\deleteMe.tif", MODI.MiFILE_FORMAT.miFILE_FORMAT_DEFAULTVALUE, 

Taken from here, and from this source code.

My source you can download from here, and exe file can be found here.