Click here to Skip to main content
15,441,629 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want run chrome window from from c# code.

And i also want the chrome page html source into string object.

i am using following code -

Process process = new Process();
process.StartInfo = new ProcessStartInfo()
{
    WindowStyle = ProcessWindowStyle.Hidden,
    UseShellExecute = false,
    RedirectStandardOutput = true,
    CreateNoWindow = true,
    StandardOutputEncoding = Encoding.UTF8,
    FileName = "chrome.exe",
    Arguments = "https://www.google.co.in"
};

process.Start();
this.Response = process.StandardOutput.ReadToEnd();
this.Completed = true;


but this code gave an error -
The system cannot find the file specified


please help some body. thanx in advance.

What I have tried:

I have not done this type of task before , So please help.
Posted
Updated 31-Dec-18 6:55am

You probably need to use the full path to Chrome, e.g.
FileName = @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe";
Or even better:
FileName = Environment.GetEnvironmentVariable("ProgramFiles(x86)") + "\Google\Chrome\Application\chrome.exe";
 
Share this answer
 
v4
Comments
F-ES Sitecore 31-Dec-18 14:01pm    
What if I installed chrome in a non-standard location?
RickZeeland 31-Dec-18 16:48pm     CRLF
Then you could try to find out the location from the registry: HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\Chrome.exe but this might not work in all situations ...
You can run Chrome and reparent the Chrome window to show up in your own window, like in a Panel control.

However, you cannot get the DOM from Chrome. It does not expose an automation model that your code can interact with to get the DOM.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900