本文整理匯總了C#中WatiN.Core.IE.Close方法的典型用法代碼示例。如果您正苦於以下問題:C# IE.Close方法的具體用法?C# IE.Close怎麽用?C# IE.Close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WatiN.Core.IE
的用法示例。
在下文中一共展示了IE.Close方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CloseIEInstance
/// <summary>
/// Closes the given IE instance.
/// </summary>
/// <param name="ieInstance">The IE instance to be closed.</param>
public static void CloseIEInstance(IE ieInstance)
{
if (ieInstance != null)
{
ieInstance.Close();
}
}
示例2: ClickMe
public void ClickMe()
{
IE ie = new IE("http://localhost/AnthemNxt.Tests/ButtonsAndLabels.aspx");
Assert.Null(ie.Span(Find.ById("ctl00_ContentPlaceHolder_label")).Text);
ie.Button(Find.ByName("ctl00$ContentPlaceHolder$button")).Click();
Assert.NotEqual("", ie.Span(Find.ById("ctl00_ContentPlaceHolder_label")).Text);
// TODO: Check no postback occurred - how can we do this?
ie.Close();
}
示例3: Home_HasMvcStoreHasTitle_True
public void Home_HasMvcStoreHasTitle_True()
{
var browser = new IE("http://localhost:1100/");
browser.BringToFront();
Assert.IsTrue(browser.ContainsText("ASP.NET MVC MUSIC STORE"));
browser.Close();
}
示例4: Write
public XmlDocument Write()
{
IE.Settings.MakeNewIeInstanceVisible = false;
var browser = new IE("menu.htm".File());
var writer = new XmlWriter();
foreach (Link link in browser.Links)
{
if (link.Url.StartsWith("file:///") && !link.Url.Contains("TableOfContents.htm") &&
link.Url.EndsWith("htm"))
{
processFile(link, writer);
}
}
browser.Close();
return writer.XmlDocument;
}
示例5: Descargar
public static void Descargar(string rfc, string contrasena, string carpeta, DateTime fechaDesde, DateTime fechaHasta, TipoBusqueda busqueda)
{
using (IE browser = new IE())
{
//limpiar sesion y login
browser.ClearCookies();
Thread.Sleep(1000);
//java login
browser.GoTo("https://portalcfdi.facturaelectronica.sat.gob.mx");
browser.WaitForComplete();
//entrar por contraseña
browser.GoTo("https://cfdiau.sat.gob.mx/nidp/app/login?id=SATUPCFDiCon&sid=0&option=credential&sid=0");
browser.TextField(Find.ByName("Ecom_User_ID")).AppendText(rfc);
browser.TextField(Find.ByName("Ecom_Password")).AppendText(contrasena);
browser.Button("submit").Click();
browser.WaitForComplete();
//ver si nos pudimos loggear
if (browser.ContainsText("Login failed, please try again") || browser.ContainsText("La entrada no se ha completado"))
{
browser.Close();
throw new Exception("Los datos de acceso son incorrectos para: " + rfc);
}
//seleccionar emitidas o recibidas
if (busqueda == TipoBusqueda.Emitidas)
{
browser.RadioButton("ctl00_MainContent_RdoTipoBusquedaEmisor").Click();
}
else
{
browser.RadioButton("ctl00_MainContent_RdoTipoBusquedaReceptor").Click();
}
browser.Button("ctl00_MainContent_BtnBusqueda").Click();
Log.Write("Tipo busqueda", Log.Information);
//Creating the directory if it doesn't exists
if (!System.IO.Directory.Exists(carpeta))
{
System.IO.Directory.CreateDirectory(carpeta);
}
//facturas emitidas
if (busqueda == TipoBusqueda.Emitidas)
{
browser.WaitUntilContainsText("Fecha Inicial de Emisión");
browser.RadioButton("ctl00_MainContent_RdoFechas").Click();
Thread.Sleep(1000);
//fecha desde
browser.TextField("ctl00_MainContent_CldFechaInicial2_Calendario_text").Value = fechaDesde.ToString("dd/MM/yyyy");
//hasta
browser.TextField("ctl00_MainContent_CldFechaFinal2_Calendario_text").Value = fechaHasta.ToString("dd/MM/yyyy");
Thread.Sleep(1000);
//buscar muchas veces por si marca error de lentitud la pagina del sat >(
while (true)
{
browser.Button("ctl00_MainContent_BtnBusqueda").Click();
Thread.Sleep(3000);
if (browser.ContainsText("lentitud"))
{
browser.Link("closeBtn").Click();
}
else
{
break;
}
}
DescargarFacturasListadas(browser, carpeta);
}
else
{
DateTime mesActual = fechaDesde;
bool primeraVez = true;
while (mesActual < fechaHasta)
{
browser.WaitUntilContainsText("Fecha de Emisión");
browser.RadioButton("ctl00_MainContent_RdoFechas").Click();
Thread.Sleep(1000);
//seleccionar año adecuado
browser.SelectList("DdlAnio").SelectByValue(mesActual.Year.ToString());
//seleccionar mes adecuado
browser.SelectList("ctl00_MainContent_CldFecha_DdlMes").SelectByValue(mesActual.Month.ToString());
if (mesActual.Day < 10 && primeraVez)
{
//seleccionar dia adecuado
//click en buscar por que si no no jala
//buscar muchas veces por si marca error de lentitud la pagina del sat >(
//.........這裏部分代碼省略.........
示例6: Go_Click
//.........這裏部分代碼省略.........
}
while (_Work.IsBusy || _Work1.IsBusy)
{
Application.DoEvents();
}
_lblerror.Visible = true;
_lblerror.Text = "We are going to read product info.";
_IsCategory = false;
_IsProduct = true;
gridindex = 0;
totalrecord.Text = "Total No Products :" + Producturl.Count.ToString();
foreach (var url in Producturl)
{
while (_Work.IsBusy && _Work1.IsBusy)
{
Application.DoEvents();
}
if (!_Work.IsBusy)
{
Url1 = url.Key;
_Work.RunWorkerAsync();
}
else
{
Url2 = url.Key;
_Work1.RunWorkerAsync();
}
}
while (_Work.IsBusy || _Work1.IsBusy)
{
Application.DoEvents();
}
#region InsertScrappedProductInDatabase
if (Products.Count() > 0)
{
_Prd.ProductDatabaseIntegration(Products, "factorydirect.ca", 1);
}
else
{
BusinessLayer.DB _Db = new BusinessLayer.DB();
_Db.ExecuteCommand("update Schduler set LastProcessedStatus=0 where StoreName='factorydirect.ca'");
_Prd.ProductDatabaseIntegration(Products, "factorydirect.ca", 1);
_Mail.SendMail("OOPS there is no any product scrapped by app for factorydirect.ca Website." + DateTime.Now.ToString(), "Urgent issue in Scrapper.", false, false, 1);
}
#endregion InsertScrappedProductInDatabase
}
else
{
BusinessLayer.DB _Db = new BusinessLayer.DB();
_Prd.ProductDatabaseIntegration(Products, "factorydirect.ca", 1);
_Db.ExecuteCommand("update Schduler set LastProcessedStatus=0 where StoreName='factorydirect.ca'");
_lblerror.Text = "Oops there is change in html code on client side. You need to contact with developer in order to check this issue for factorydirect.ca Website";
/****************Email****************/
_Mail.SendMail("Oops there is change in html code on client side. You need to contact with developer in order to check this issue for factorydirect.ca Website as soon as possible because noscrapping of given store is stopped working." + DateTime.Now.ToString(), "Urgent issue in Scrapper.", false, false, 1);
/*******************End********/
}
}
else
{
BusinessLayer.DB _Db = new BusinessLayer.DB();
_Prd.ProductDatabaseIntegration(Products, "factorydirect.ca", 1);
_Db.ExecuteCommand("update Schduler set LastProcessedStatus=0 where StoreName='factorydirect.ca'");
_lblerror.Text = "Oops there is change in html code on client side. You need to contact with developer in order to check this issue for factorydirect.ca Website";
/****************Email****************/
_Mail.SendMail("Oops there is change in html code on client side. You need to contact with developer in order to check this issue for factorydirect.ca Website as soon as possible because noscrapping of given store is stopped working." + DateTime.Now.ToString(), "Urgent issue in Scrapper.", false, false, 1);
/*******************End********/
}
}
catch
{
BusinessLayer.DB _Db = new BusinessLayer.DB();
_Db.ExecuteCommand("update Schduler set LastProcessedStatus=0 where StoreName='factorydirect.ca'");
_lblerror.Visible = true;
_Mail.SendMail("Oops Some issue Occured in scrapping data factorydirect.ca Website" + DateTime.Now.ToString(), "Urgent issue in Scrapper.", false, false, 1);
}
while (_Work.IsBusy || _Work1.IsBusy)
{
Application.DoEvents();
}
# endregion Factory.CA
writer.Close();
try { _Worker1.Close(); _Worker2.Close(); }
catch
{
}
this.Close();
}
示例7: SignupPage
//.........這裏部分代碼省略.........
string Url = Item.OuterHtml.ToString();
if (Item.Id == "recaptcha_image")
{
int startIndex = Url.IndexOf("src=\"");
string start = Url.Substring(startIndex).Replace("src=\"", "");
int endIndex = start.IndexOf("\"");
string end = start.Substring(0, endIndex);
capcthaUrl = end;
break;
}
}
int i = 0;
WebClient webclient = new WebClient();
StartWebClient:
Thread.Sleep(2000);
try
{
byte[] args = webclient.DownloadData(capcthaUrl);
string[] arr1 = new string[] { BaseLib.Globals.DBCUsername, BaseLib.Globals.DBCPassword, "" };
string CapcthaString = DecodeDBC(arr1, args);
foreach (TextField item in explorer.TextFields)
{
string Html = item.OuterHtml.ToString();
if (item.Id == "recaptcha_response_field")
{
AddToProxyAccountCreationLog("Adding Capctha Response");
item.TypeText(CapcthaString);
break;
}
}
explorer.Button(Find.ByValue("Create my account")).Click();
}
catch (Exception ex)
{
i++;
if (ex.Message.Contains("An exception occurred during a WebClient request."))
{
AddToProxyAccountCreationLog("Error In Capctha Download Trying Again - " + i);
if (i <= 3)
{
goto StartWebClient;
}
else
{
GlobusFileHelper.AppendStringToTextfileNewLine(email + ":" + password + ":" + ProxyAdress + ":" + ProxyPort, Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\TwtDominator\\UnsuccessfullBrowserAcounts.txt");
}
}
}
}
catch (Exception ex)
{
}
string ConfirmId = explorer.Html.ToString();
AddToProxyAccountCreationLog("Confirming created Account");
if (!ConfirmId.Contains("Sign out"))
{
AddToProxyAccountCreationLog("Account Not Created : " + email + ":" + password);
GlobusFileHelper.AppendStringToTextfileNewLine(email + ":" + password + ":" + ProxyAdress + ":" + ProxyPort, Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\TwtDominator\\UnsuccessfullBrowserAcounts.txt");
}
else if (ConfirmId.Contains("Sign out"))
{
GlobusFileHelper.AppendStringToTextfileNewLine(email + ":" + password + ":" + ProxyAdress + ":" + ProxyPort, Globals.Path_BrowserCreatedAccounts);
explorer.GoTo("https://twitter.com/");
explorer.Link(Find.ById("signout-button")).Click();
Thread.Sleep(1000);
}
}
}
}
catch (Exception ex)
{
if (ex.Message == "The remote server returned an error: (504) Gateway Timeout.")
{
AddToProxyAccountCreationLog("Remote Server Returned Error - Time out");
}
explorer.Close();
AddToProxyAccountCreationLog("Closing Explorer Due To Error");
goto StartAgain;
}
explorer.Close();
countForInstance++;
}
catch (Exception ex)
{
Console.WriteLine("Error :: - " + DateTime.Now.ToString() + " || Error - " + ex.Message);
if (ex.Message.Contains("Creating an instance of the COM component with"))
{
goto StartAgain;
}
}
}
}
示例8: Process
//.........這裏部分代碼省略.........
{
}
}
// Code to write in file
if (_IsCategorypaging)
{
using (StreamWriter writer = new StreamWriter(Application.StartupPath + "/Files/Url.txt"))
{
foreach (var PrdUrl in Url)
{
writer.WriteLine(PrdUrl.Key + "@#$#" + PrdUrl.Value);
}
}
}
#endregion Code to get and write urls from File
_IsCategorypaging = false;
DisplayRecordProcessdetails("We are going to read Product information for " + chkstorelist.Items[0].ToString() + " Website", "Total products :" + Url.Count());
_IsProduct = true;
foreach (var PrdUrl in Url)
{
try
{
while (_Work.IsBusy && _Work1.IsBusy)
{
Application.DoEvents();
}
while (_Stop)
{
Application.DoEvents();
}
if (!_Work.IsBusy)
{
Url1 = PrdUrl.Key;
BrandName1 = PrdUrl.Value;
_Work.RunWorkerAsync();
}
else
{
Url2 = PrdUrl.Key;
BrandName2 = PrdUrl.Value;
_Work1.RunWorkerAsync();
}
}
catch (Exception exp)
{
MessageBox.Show(exp.Message);
}
}
while (_Work.IsBusy || _Work1.IsBusy)
{
Application.DoEvents();
}
if (Products.Count() > 0)
{
System.Threading.Thread.Sleep(1000);
_lblerror.Visible = true;
BusinessLayer.ProductMerge _Prd = new BusinessLayer.ProductMerge();
_Prd.ProductDatabaseIntegration(Products, "tigerdirect.ca", 1);
}
else
{
BusinessLayer.DB _Db = new BusinessLayer.DB();
_Db.ExecuteCommand("update Schduler set LastProcessedStatus=0 where StoreName='tigerdirect.ca'");
_Mail.SendMail("OOPS there is no any product scrapped by app for tigerdirect.ca Website." + DateTime.Now.ToString(), "Urgent issue in Scrapper.", false, false, 1);
}
}
catch
{
BusinessLayer.DB _Db = new BusinessLayer.DB();
_Db.ExecuteCommand("update Schduler set LastProcessedStatus=0 where StoreName='tigerdirect.ca'");
_lblerror.Visible = true;
_Mail.SendMail("Oops Some issue Occured in scrapping data tigerdirect.ca Website" + DateTime.Now.ToString(), "Urgent issue in Scrapper.", false, false, 1);
}
#region closeIEinstance
try
{
_Worker1.Close();
_Worker2.Close();
}
catch
{
}
#endregion closeIEinstance
#endregion
_writer.Close();
this.Close();
}
示例9: Goto
public static string Goto(String text, IE ie)
{
int i = 0;
while (i < Loop)
{
i++;
try
{
ie.GoTo(text);
ie.WaitForComplete();
//ie.WaitUntilContainsText("message");
return string.Empty;
}
catch (Exception ex)
{
if (i == Loop)
{
return ex.Message;
}
ie.Close();
Thread.Sleep(60000);
ie.Reopen();
}
}
return string.Empty;
}
示例10: Goto
public static string Goto(string Url, IE ie)
{
int i = 0;
while (i < Loop)
{
i++;
try
{
ie.GoTo(Url);
ie.WaitForComplete();
return string.Empty;
}
catch (Exception ex)
{
if (i == Loop)
{
return ex.Message;
}
ie.Close();
Thread.Sleep(60000);
ie.Reopen();
}
}
return string.Empty;
}
示例11: processFile
private void processFile(Link link, XmlWriter writer)
{
string path = link.Url;
string title = link.InnerHtml;
writer.WritePage(title, path);
Debug.WriteLine(title + " = " + path);
var browser = new IE(path, false);
foreach (Element header in browser.Elements)
{
if (header.TagName == "H2")
{
processHeader(header, writer, path);
}
if (header.TagName == "H4")
{
processSubHeader(header, writer, path);
}
}
browser.Close();
}
示例12: DeepHarvestShoeNode
private IEnumerable<string> DeepHarvestShoeNode(HtmlNode node, ProductData product)
{
//Debugger.Launch();
var productLink = BaseAddress + node.SelectNodes("p[@class='view_buy']/a").First().Attributes["href"].Value;
var browser = new IE(productLink, false);
browser.GoTo(productLink);
browser.ShowWindow(NativeMethods.WindowShowStyle.Hide);
var mainProductHtml = new HtmlDocument();
var doc = HtmlNode.CreateNode("");
IEnumerable<string> images = new string[0];
try
{
mainProductHtml.LoadHtml(GetHtmlString(productLink));
// //div[@id="productright"]/div[@class=product_info]/p
doc = mainProductHtml.DocumentNode;
images = GetVariantImages(browser);
browser.Close();
product.Handle = new Uri(productLink).AbsolutePath.Replace("/products/", string.Empty).Replace("/", "-");
product.Body = "\"" + doc.SelectNodes("//div[@id='productright']/div[@class='product_info']/p").First().InnerText.Replace("\"", "'") + "\"";
product.Type = "Mens Shoes"; DiscernType(product.Body, product.Title);
}
catch (Exception e)
{
Console.WriteLine("Exception thrown trying to parse: {0}", productLink);
}
HtmlNodeCollection colours = null;
HtmlNodeCollection sizes = null;
var productForm = doc.SelectNodes("//div[@id='product_form']").First();
product.Option1Name = "Title";
product.Option1Value = "Title";
if (productForm.InnerHtml.Contains("Colour"))
{
colours = doc.SelectNodes("//div[@id='colours_js_box']").First().SelectNodes("//a[contains(@class,'product_colour')]");
product.Option1Name = "Colour";
product.Option1Value = colours.First().InnerText;
}
if (productForm.InnerHtml.Contains("Size"))
{
sizes = doc.SelectNodes("//div[@id='sizes_js_box']").First().SelectNodes("//a[contains(@class,'product_sizes')]");
if (product.Option1Name == "Title")
{
product.Option1Name = "Colour";
product.Option1Value = sizes.First().InnerText;
}
else
{
product.Option2Name = "Size";
product.Option2Value = sizes.First().InnerText;
}
}
product.Sku = productLink;
product.Taxable = "FALSE";
product.RequiresShipping = "TRUE";
product.FulfillmentService = "manual";
product.InventoryPolicy = "continue";
product.Vendor = "Henry James";
product.InventoryQuantity = "0";
product.Tags = "Mens Shoes";
product.Sizes = sizes;
product.Colours = colours;
return images;
}
示例13: GetVariantImages
private IEnumerable<string> GetVariantImages(Browser browser)
{
var variantImages = new List<string>();
var links = browser.Div("colours_js_box").Divs.First().Links.Select(x => x.Title);
foreach (var link in links)
{
Browser b = new IE(browser.Url);
b.ShowWindow(NativeMethods.WindowShowStyle.Hide);
b.Link(Find.ByTitle(link)).Click();
var d = new HtmlDocument();
d.LoadHtml(GetHtmlString(b.Url));
b.Close();
var node = d.DocumentNode.SelectNodes("//img[@id='productimage']").First();
variantImages.Add(BaseAddress + node.Attributes["src"].Value);
}
return variantImages;
}
示例14: Process
//.........這裏部分代碼省略.........
}
catch
{
}
}
// Code to write in file
if (_IsCategorypaging)
{
using (StreamWriter writer = new StreamWriter(Application.StartupPath + "/Files/Url.txt"))
{
foreach (var PrdUrl in Url)
{
writer.WriteLine(PrdUrl.Key + "@#$#" + PrdUrl.Value);
}
}
}
#endregion Code to get and write urls from File
_IsCategorypaging = false;
DisplayRecordProcessdetails("We are going to read Product information for " + chkstorelist.Items[0].ToString() + " Website", "Total products :" + Url.Count());
_IsProduct = true;
foreach (var PrdUrl in Url)
{
try
{
while (_Work.IsBusy || _Work1.IsBusy)
{
Application.DoEvents();
}
while (_Stop)
{
Application.DoEvents();
}
if (!_Work.IsBusy)
{
Url1 = "http://store.401games.ca" + PrdUrl.Key;
BrandName1 = PrdUrl.Value;
_Work.RunWorkerAsync();
}
else
{
Url2 = "http://store.401games.ca" + PrdUrl.Key;
BrandName2 = PrdUrl.Value;
_Work1.RunWorkerAsync();
}
}
catch
{
}
}
while (_Work.IsBusy || _Work1.IsBusy)
{
Application.DoEvents();
}
if (Products.Count() > 0)
{
System.Threading.Thread.Sleep(1000);
_lblerror.Visible = true;
BusinessLayer.ProductMerge _Prd = new BusinessLayer.ProductMerge();
_Prd.ProductDatabaseIntegration(Products, "store.401games", 1);
}
else
{
BusinessLayer.DB _Db = new BusinessLayer.DB();
_Db.ExecuteCommand("update Schduler set LastProcessedStatus=0 where StoreName='store.401games'");
_Mail.SendMail("OOPS there is no any product scrapped by app for store.401games Website." + DateTime.Now.ToString(), "Urgent issue in Scrapper.", false, false, 1);
}
}
catch
{
BusinessLayer.DB _Db = new BusinessLayer.DB();
_Db.ExecuteCommand("update Schduler set LastProcessedStatus=0 where StoreName='store.401games'");
_lblerror.Visible = true;
_Mail.SendMail("Oops Some issue Occured in scrapping data store.401games Website" + DateTime.Now.ToString(), "Urgent issue in Scrapper.", false, false, 1);
}
#region closeIEinstance
try
{
_Worker1.Close();
_Worker2.Close();
}
catch
{
}
#endregion closeIEinstance
#endregion
_writer.Close();
this.Close();
}
示例15: Process
//.........這裏部分代碼省略.........
CategoryUrl.Remove("http://store.401games.cahttp://payd.moneris.com/#st=&begin=1&nhit=40");
CategoryUrl.Remove("http://store.401games.ca/service/privacy/#st=&begin=1&nhit=40");
CategoryUrl.Remove("http://store.401games.ca/catalog/93370C/pre-orders#st=&begin=1&nhit=40");
if (CategoryUrl.Count() > 0)
{
DisplayRecordProcessdetails("We are going to read product url from category pages for " + chkstorelist.Items[0].ToString() + " Website", "Total Category :" + CategoryUrl.Count());
_IsCategorypaging = true;
foreach (string Caturl in CategoryUrl)
{
while (_Work.IsBusy && _Work1.IsBusy)
{
Application.DoEvents();
}
while (_Stop)
{
Application.DoEvents();
}
if (!_Work.IsBusy)
{
Url1 = Caturl;
_Work.RunWorkerAsync();
}
else
{
Url2 = Caturl;
_Work1.RunWorkerAsync();
}
break;
}
while (_Work.IsBusy || _Work1.IsBusy)
{
Application.DoEvents();
}
_Bar1.Value = 0;
_401index = 0;
_IsCategorypaging = false;
_ProductUrl = _ProductUrlthread1.Concat(_ProductUrlthread2).ToList();
DisplayRecordProcessdetails("We are going to read Product information for " + chkstorelist.Items[0].ToString() + " Website", "Total products :" + _ProductUrl.Count());
_IsProduct = true;
foreach (string PrdUrl in _ProductUrl)
{
while (_Work.IsBusy && _Work1.IsBusy)
{
Application.DoEvents();
}
while (_Stop)
{
Application.DoEvents();
}
if (!_Work.IsBusy)
{
Url1 = "http://store.401games.ca"+PrdUrl;
_Work.RunWorkerAsync();
}
else
{
Url2 ="http://store.401games.ca"+ PrdUrl;
_Work1.RunWorkerAsync();
}
}
}
while (_Work.IsBusy || _Work1.IsBusy)
{
Application.DoEvents();
}
MessageBox.Show("Process Completed.");
}
catch
{
}
#region closeIEinstance
try
{
_Worker1.Close();
_Worker2.Close();
}
catch
{
}
#endregion closeIEinstance
#endregion
}