Trouble shooting for several days, with reflector I found the real cause.
The problem is under Environment:
Windows Server 2008 R2 x64, IE 9, IE10 and IE12, and every version of Testing framework from 2012.2 to lastest.
IE would not launch, always prompting could not find file. I tried ways from every posts which is similar but get no way.
Then I had to use reflector and found the following code never works in my environment:
ProcessStartInfo startInfo =
new ProcessStartInfo {
Arguments = ((
MajorVersion >=
8) ?
"-nomerge " :
string.
Empty) +
"about:blank",
Verb =
"open",
WindowStyle =
windowStyle,
ErrorDialog =
false,
FileName =
"iexplore.exe"
};
Process process =
Process.
Start(
startInfo);
which resides in
LaunchNewBrowserInstance(
int timeout,
ProcessWindowStyle windowStyle,
string pipename), the above code always throwing exception.
System.ComponentModel.Win32Exception (0x80004005): 系统找不到指定的文件(System could not find specified file)。
在 System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startI
nfo)
在 System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
The correct way is using :
Process.Start(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"Internet Explorer\iexplore.exe"));
and
Process.Start(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), @"Internet Explorer\iexplore.exe"));
for replacement.
Could you guys fix this for this environment, thanks a lot. It confused me for quite a long time.
Thanks!