Open webbrowser, auto complete form components and submit
.net, browser, c#, winforms, wpf
Solution
I wrote an example for filling in an element in a html page. You must do something like this:
Winform
public Form1()
{
InitializeComponent();
//navigate to you destination
webBrowser1.Navigate("https://www.certiport.com/portal/SSL/Login.aspx");
}
bool is_sec_page = false;
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (!is_sec_page)
{
//get page element with id
webBrowser1.Document.GetElementById("c_Username").InnerText = "username";
webBrowser1.Document.GetElementById("c_Password").InnerText = "pass";
//login in to account(fire a login button promagatelly)
webBrowser1.Document.GetElementById("c_LoginBtn_c_CommandBtn").InvokeMember("click");
is_sec_page = true;
}
//secound page(if correctly aotanticate
else
{
//intract with sec page elements with theire ids and so on
}
}
Wpf
public MainWindow()
{
InitializeComponent();
webBrowser1.Navigate(new Uri("https://www.certiport.com/portal/SSL/Login.aspx"));
}
bool is_sec_page = false;
mshtml.HTMLDocument htmldoc;
private void webBrowser1_LoadCompleted(object sender, NavigationEventArgs e)
{
htmldoc = webBrowser1.Document as mshtml.HTMLDocument;
if (!is_sec_page)
{
//get page element with id
htmldoc.getElementById("c_Username").innerText = "username";
//or
//htmldoc.getElementById("c_Username")..SetAttribute("value", "username");
htmldoc.getElementById("c_Password").innerText = "pass";
//login in to account(fire a login button promagatelly)
htmldoc.getElementById("c_LoginBtn_c_CommandBtn").InvokeMember("click");
is_sec_page = true;
}
//secound page(if correctly aotanticate
else
{
//intract with sec page elements with theire ids and so on
}
}
Just navigate to specific URL and fill page element.
Problem
We are currently investigating a method of creating a WPF/winforms application that we can set up internally to :- - automatically open a new instance of a web browser to a predefined URL - automatically complete required fields with predefined data - automatically submit form and wait for the next page to load - automatically complete required fields with predefined data (page 2) - automatically submit form and wait for the next page to load (etc) after much investigation, the only thing we have managed to find is the opening up of a web browser via :- ``` object o = null; SHDocVw.InternetExplorer ie = new SHDocVw.InternetExplorer(); IWebBrowserApp wb = (IWebBrowserApp)ie; wb.Visible = true; wb.Navigate(url, ref o, ref o, ref o, ref o); ``` Any advice / reading recommendations would be appreciated on how to complete the process.