maxleb
asked on
Ask to my C# application to wait until an action is taken on a Javascript Alert using mshtml
Hi I am bulding an application that opens an IE browser and fill fields out automaticaly using Microsoft.mshtml but when it comes to click on the Next button an Javascript alert open confirming the adress with a yes/no.
How to, I either tell the application to click Yes automaticaly then wait the action to click on the Next button again
My main issue is to wait till the user click yes on the alert windows then tell the application to click on the next button again.
If you could fix both of my problem, it would be awsome.
any ideas??
Thanks
Here is my code snippet:
How to, I either tell the application to click Yes automaticaly then wait the action to click on the Next button again
My main issue is to wait till the user click yes on the alert windows then tell the application to click on the next button again.
If you could fix both of my problem, it would be awsome.
any ideas??
Thanks
Here is my code snippet:
Object o = null;
Object URL = "https://eshiponline.purolator.com/ShipOnline/SecurePages/Public/FormsLogin.aspx";
mshtml.HTMLDocumentClass doc;
InternetExplorer ie = new InternetExplorer();
ie.Visible = true;
ie.Navigate2(ref URL, ref o, ref o, ref o, ref o);
while (ie.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE)
{
Application.DoEvents();
System.Threading.Thread.Sleep(50);
}
// get the document
doc = (mshtml.HTMLDocumentClass)ie.Document;
mshtml.HTMLInputElementClass el = null;
// Login
ieValue("ctl00$CPPC$Username", "username", el, doc); //
ieValue("ctl00$CPPC$Password", "password", el, doc); //
ieClick("ctl00$CPPC$imgLogin", el, doc); //
// Check if shipTo Canada, Else fill field, show Browser
if (d1_ctl00_CPPC_ctrlShipToAddress_ddlCountry.Text == "Canada")
{
// Filling text box from the first page.
fillTextBox("p1_", el, doc);
// Wait If Have to change Shipped From
if (ch_fromDefault.Checked != true)
{
ieClick("ctl00$CPPC$btnNext", el, doc); //
//this is at this point that the alert appear. After clicking yes. I need to call ieClick("ctl00$CPPC$btnNext", el, doc); // again
}
else
{
ie.Visible = true;
ieJavascript("ctrlShipFromAddress_Edit();", el, ie);
}
}
else
{
fillTextBox("p1_", el, doc);
Application.Exit();
return;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.