Answered question

How can you pass the command line argument for the SeleniumWrapper in Unit-Tests (C#)?

I want to use the NeoloadSeleniumWrapper in Visual Studio (C#) for test design. The recording in Neoload works fine for a console application, if I pass the required program argument via command line: -Dnl.selenium.proxy.mode=Design. However, I want to perform the recording out of a unit test, as shown in the Neoload Documentation: https://www.neotys.com/documents/doc/neoload/latest/en/ht...

The documentation does not state how to pass the argument in this case, and Neoload does not record anything if it is missing. The difficulity of passing command line arguments in unit tests is also discussed here: https://social.msdn.microsoft.com/Forums/en-US/441920ee-e...

Is there any efficient solution for this?

Roman F.
Roman F.

Roman F.

Level
0
22 / 100
points
christophe M.
christophe M.

christophe M.

Level
4
5000 / 5000
points
Team

If you can insert code in the unit test, did you try

System.Environment.SetEnvironmentVariable( name, value ); ?

Did you find this useful ?

No (0)

Yes (1)

100%

100% of users found this answer useful

Other answers

christophe M.
christophe M.

christophe M.

Level
4
5000 / 5000
points
Team

How do you start the C# program? Can you call a "set nl.selenium.proxy.mode=Design" before calling the program?

Roman F.
Roman F.

Roman F.

Level
0
22 / 100
points

The unit tests are started manually in the GUI of Visual Studio (Test -> Run -> etc.). This triggers mstest behind the scenes and represents the default way of unit test execution in C#.

I tried calling "set nl.selenium.proxy.mode=Design" before the test execution (manually in a shell) and also as first step inside the unit test via System.Diagnostics.Process.Start("CMD.exe", "set nl.selenium.proxy.mode=Design"). Unfortunately it didn't work.

Roman F.
Roman F.

Roman F.

Level
0
22 / 100
points

Thank you very much! This did the trick:
System.Environment.SetEnvironmentVariable("nl.selenium.proxy.mode", "Design");

Maybe you should consider to add this to the documentation for the c# client (see link in the initial question).