1

I am trying to to use selenium.exe (actual filename) to open FireFox and execute some stuff. Everyting is working fine if i call the method by a button, for example. But i want to user selenium arg in command prompt.

As seen in How I create exe in that I pass parameters in C#.net and How to pass parameters to an exe? and Launch Program with Parameters it would seem that a simple Main(string[] message) would suffice.

But when i type selenium "test" the application does nothing.

I put the selenium.exe (actual filename) (leave the other files in bin\Release) in C:\ and run it from a prompt.

I found weird that the executable is 10KB, but gecko executable itself is 5,000+KB.

Here is Program.cs, that should call the MyMethod() method:

static void Main(string[] message)
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        System.Console.WriteLine("Page title i");
        MyMethod(message[0]);
        Application.Run(new Form1());
    }

And MyMethod() that is never called from command line, but works perfectly if called from a Form button:

static void MyMethod(string message)
    {
            IWebDriver driver = new FirefoxDriver();
            driver.Navigate().GoToUrl("https://never.gets.here/");
            //MORE STUFF
    }
Tiago
  • 365
  • 1
  • 4
  • 17
  • *But when i type selenium "test" the application does nothing.* Is `selenium` the name of your actual executable or is that the selenium application you are referencing? Should be `yourApplication.exe test` – TyCobb Nov 22 '17 at 20:52
  • it's the name of the executable. I will update the question. Anyway if i were using the wrong name it would reply "bad command or file name" or something... hehe – Tiago Nov 22 '17 at 20:56
  • It won't if you actually had a `selenium.exe` in your folder. You need to call your application with the command line. It also quite possible that your MyMethod is blocking the rest of the application from running and displaying your form. If you go to Task Manager, is your program running? – TyCobb Nov 22 '17 at 20:57
  • I run *cmd.exe* and then navigate to C:\ (where i put the *selenium.exe* executable generated in bin\Release) then i type **selenium test**, that don't have a reply and never opens the browser. The prompt just shows **C:\>** again – Tiago Nov 22 '17 at 21:01
  • Best bet is start adding some logging and wrapping your code in Main with a try/catch to see if it is bombing. – TyCobb Nov 22 '17 at 21:02

0 Answers0