Reputation: 15
I would like to understand why #2 is not allowed. I cannot access class method using "app" object?
Note: I have not touched C# or any other programming language since 6 years so my concepts are a bit shaky. Please correct me If I have used wrong terminology. Meanly I wanted to know if I want to call Launch() method why I cannot do it via object app.Launch();
Upvotes: 0
Views: 1058
Reputation: 81262
Here's how I do it:
public static ApplicationUnderTest LaunchApplicationUnderTest(string applicationPath,string processName,
bool closeOnPlaybackCleanup)
{
Process[] processes = Process.GetProcessesByName(processName);
if (processes.Length > 0)
{
_application = ApplicationUnderTest.FromProcess(processes[0]);
}
else
{
_application = ApplicationUnderTest.Launch(applicationPath);
_application.CloseOnPlaybackCleanup = closeOnPlaybackCleanup;
}
return _application;
}
Upvotes: 0
Reputation: 958
The ApplicationUnderTest class is static, meaning it cannot be instantiated (what you're doing when you call = new ApplicationUnderTest()
). Thus, the methods that you're trying to access can only be accessed in the static class. MSDN is a good resource for a more in depth explanation of class accessibility types.
Upvotes: 3