William Madonna Jr.
William Madonna Jr.

Reputation: 242

Any way to automate IE *WITHOUT* using webbrowser control?

I have an enterprise app that automates many business functions. I make heavy use of the WebBrowser control for all of my web site interactions (web site scraping, web app automation, etc....)

I've come across two web sites that simply will NOT render properly in the WebBrowser control. Specifically:

Both of these render just fine in my IE10 browser.

I have tried setting the registry keys to change the rendering engine from default IE7 to IE9. But still same results. Something about these web apps just will not render in the WebBrowser control.

So....is there any way to automate IE10 the browser from my C# app? By sending messages of some sort? I need to be able to click links and fill in form data for login info and such. Any advice appreciated...

Upvotes: 1

Views: 1004

Answers (1)

John Koerner
John Koerner

Reputation: 38077

You could use a testing tool like Selenium to automate IE. You can download the IE Driver from their downloads page.

A simple example using google (Make sure you read the instructions on how to get the IE Driver working):

OpenQA.Selenium.IE.InternetExplorerDriver d = new OpenQA.Selenium.IE.InternetExplorerDriver();
d.Navigate().GoToUrl("http://www.google.com");

d.FindElementByName("q").SendKeys("Stack");
d.FindElementByName("btnK").Click();

WebDriverWait waiter = new WebDriverWait(d, TimeSpan.FromSeconds(10));

waiter.Until(ExpectedConditions.ElementExists(By.CssSelector(".rc .r a")));
// Message the first element
MessageBox.Show(d.FindElementByCssSelector(".rc .r a").Text);

Upvotes: 3

Related Questions