How to create .Bat file that runs Selenium C# test cases

1,989 views
Skip to first unread message

robert abaribe

unread,
Dec 18, 2015, 6:18:35 AM12/18/15
to Selenium Users
Hi, I would like to know how to run a bat file that can call selenium test cases from Visual studios?

Thank you in advance

Panikera Raj

unread,
Dec 18, 2015, 9:10:31 AM12/18/15
to selenium-users

Hi Robert,

Write your test scripts in unit test and add all test scripts unit test batch runner then you can call batch execution in .bat
file.

Thanks
Panikera

On 18 Dec 2015 4:48 pm, "robert abaribe" <aba...@gmail.com> wrote:
>
> Hi, I would like to know how to run a bat file that can call selenium test cases from Visual studios?
>
> Thank you in advance
>

> --
> You received this message because you are subscribed to the Google Groups "Selenium Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
> To post to this group, send email to seleniu...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/0154c9fa-238b-4247-8fde-42a86eece92d%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Praveen P

unread,
Dec 18, 2015, 2:02:41 PM12/18/15
to Selenium Users
Selenium is just a library / framework to interact with browser. So, you need to use Selenium in any of the available test framework (like MSTest, NUnit etc) to exercise Selenium tests.

As you are using Visual Studio, I believe you are using MSTest framework. So, these tests can be called/executed using VS or through command line.

So, to create a batch file, you just place this commandline and save it with .bat

eg:
mstest /testcontainer:C:\myWebTests\login.dll /test:validlogin /test:invalidlogin /resultsfile:testResults.trx

You have multiple options to run using mstest or vstest.console
For more info on this: 

Regards,
Praveen

Rahul Bendale

unread,
Feb 8, 2023, 11:00:03 PM2/8/23
to Selenium Users
Hi All,

I am using Specflow BDD framework in C# for selenium automation.
I would like to know how to create batch file for this project. Is it possible to create?

Adrian

unread,
Feb 9, 2023, 3:01:12 PM2/9/23
to Selenium Users
I'm not sure what is required.
Do you want to create a batch file in code?
Do you want to manually create a batch file?
Do you want to run a batch file?

To run a batch file you will need code like this:

            System.Diagnostics.Process process = new System.Diagnostics.Process();

            process.StartInfo.FileName = @"c:\Auto\archive.bat";

            process.StartInfo.WorkingDirectory = @"C:\Auto\" ;

            process.Start();

            process.WaitForExit(3000);


Cheers,
Adrian.

Rahul Bendale

unread,
Feb 13, 2023, 12:51:45 AM2/13/23
to Selenium Users
Yes I want to create batch file for C# selenium specflow bdd framework. But I don't have idea how to create.
Also as in selenium our script interact with browser and we have external input file. Will that be manage in batch file if we create.

Serguei Kouzmine

unread,
Feb 15, 2023, 10:05:04 PM2/15/23
to Selenium Users
tests  are usually run be either mstest.exe or nunit.exe
Either command line options are well documented
Reply all
Reply to author
Forward
0 new messages