Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
了解在使用C#、Excel和Selenium时如何/何时处理内存管理?_C#_Excel_Visual Studio_Selenium_Selenium Webdriver - Fatal编程技术网

了解在使用C#、Excel和Selenium时如何/何时处理内存管理?

了解在使用C#、Excel和Selenium时如何/何时处理内存管理?,c#,excel,visual-studio,selenium,selenium-webdriver,C#,Excel,Visual Studio,Selenium,Selenium Webdriver,最近,我一直在使用C#和Selenium创建循环,将数据导入网站的搜索参数,并将结果粘贴回excel工作表(全部在visual Studio中)。我注意到,当我通过越来越多的搜索(如n++;)时,程序的速度会稳步下降,甚至我位于表格顶部的进度条的帧速率也会下降,这让我相信程序的速度正在变慢。在程序运行的每一小时后,我都在收集结果,似乎我的程序完成的搜索次数会随着时间的推移而减少 这是因为垃圾收集器没有像我期望的那样工作,因为缺乏知识吗?我应该修改我这边的内存管理吗?这个循环足够担心内存管理吗?我

最近,我一直在使用C#和Selenium创建循环,将数据导入网站的搜索参数,并将结果粘贴回excel工作表(全部在visual Studio中)。我注意到,当我通过越来越多的搜索(如n++;)时,程序的速度会稳步下降,甚至我位于表格顶部的进度条的帧速率也会下降,这让我相信程序的速度正在变慢。在程序运行的每一小时后,我都在收集结果,似乎我的程序完成的搜索次数会随着时间的推移而减少

这是因为垃圾收集器没有像我期望的那样工作,因为缺乏知识吗?我应该修改我这边的内存管理吗?这个循环足够担心内存管理吗?我知道垃圾收集器应该为我分配空间,我假设它也会删除不再使用的对象。我几乎没有内存管理的经验,所以我只是想澄清一下。如果这是我应该处理的事情,有人能给我指出正确的方向并帮助我学习如何去做吗

这是我的脚本供参考(我在Excel中浏览了大约16000行来完成这个特定的脚本)

编辑:额外问题:这是否与我正在使用一个像Try-Catch一样的内存占用很大的调用有关

public partial class Sheet1
{
    private void Sheet1_Startup(object sender, System.EventArgs e)
    {
    }

    private void Sheet1_Shutdown(object sender, System.EventArgs e)
    {
    }

    #region VSTO Designer generated code

    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InternalStartup()
    {
        this.button1.Click += new System.EventHandler(this.button1_Click);
        this.backgroundWorker1.DoWork += new System.ComponentModel.DoWorkEventHandler(this.backgroundWorker1_DoWork);
        this.backgroundWorker1.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.backgroundWorker1_ProgressChanged_1);
        this.Startup += new System.EventHandler(this.Sheet1_Startup);
        this.Shutdown += new System.EventHandler(this.Sheet1_Shutdown);

    }

    #endregion

    private void button1_Click(object sender, EventArgs e)
    {
        backgroundWorker1.RunWorkerAsync();
        var CurrentPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
    }

    //Globals -- for DOBFormatter();
    string day = "";
    string month = "";
    string year = "";
    int n = 0;
    int l = 0;
    string errorfix = "";
    int red = 0;
    int green = 0;
    int r = 6;
    int total = 0;

    private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
    {
        try
        {
            object misValue = System.Reflection.Missing.Value;
            var Excel = Globals.ThisWorkbook.Application;
            var activesheet = Excel.ActiveSheet;
            string z = textBox1.Text.ToString();
            n = Convert.ToInt32(z);
            String ActiveCell = Excel.ActiveSheet.Range["A" + n, misValue].Text;
            IWebDriver driver = new FirefoxDriver();
            if (r == 6)
            {
                while (activesheet.Range["A" + r].Text.ToString().Length > 0)
                {
                    l++;
                    r++;
                    activesheet.Range["E" + 4].Value = "Counting Number of Searches: " + r;
                }
            }
            total = red + green;
            activesheet.Range["E" + 1].Value = "Successful Searches: " + green;
            activesheet.Range["E" + 2].Value = "Failed Searches: " + red;
            activesheet.Range["E" + 3].Value = "Total Searches: " + total;
            activesheet.Range["E" + 4].Value = "Searches Remaining: " + r;
            progressBar1.Invoke((MethodInvoker)delegate { progressBar1.Maximum = l; });
            //Login to Homepage
            driver.Navigate().GoToUrl("url");
            driver.FindElement(By.Name("login-send")).Click();
            driver.FindElement(By.Name("EMAIL")).SendKeys("####");
            driver.FindElement(By.Name("PASSWORD")).SendKeys("####");
            driver.FindElement(By.Id("submitButton")).Click();
            Thread.Sleep(TimeSpan.FromSeconds(10));
            driver.SwitchTo().Frame("homeFrame");
            driver.FindElement(By.XPath("html/body/div[2]/div[3]/div[1]/h3/a[1]")).Click();
            driver.FindElement(By.XPath("html/body/div[2]/div[3]/section/ul/li[2]/a/img")).Click();
            driver.SwitchTo().Window(driver.WindowHandles[1]);
            driver.FindElement(By.XPath("html/body/table[2]/tbody/tr[4]/td[3]/input")).Click();
            driver.Navigate().GoToUrl("url");
            while (activesheet.Range["A" + n].Text.ToString().Length > 0)
            {
                //Update %, progress bar, and details.                   
                progressBar1.Invoke((MethodInvoker)delegate { progressBar1.Value = progressBar1.Value + 1; });

                //Variables
                string DOS = activesheet.Range["B" + n].Text;
                string PolicyNum = activesheet.Range["C" + n].Text;
                string DOB = activesheet.Range["D" + n].Text;
                string TaxIdOwner = activesheet.Range["A" + n].Text;
                activesheet.Range["A" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Aqua);
                activesheet.Range["B" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Aqua);
                activesheet.Range["C" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Aqua);
                activesheet.Range["D" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Aqua);
                activesheet.Range["E" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Aqua);
                activesheet.Range["F" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Aqua);
                activesheet.Range["G" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Aqua);
                //To get the textboxes in the correct thread that it was created on.
                textBox1.Invoke((MethodInvoker)delegate { textBox1.Text = "Currently on row: " + n; });
                textBox2.Invoke((MethodInvoker)delegate { textBox2.Text = "Successful searches: " + green; });
                textBox3.Invoke((MethodInvoker)delegate { textBox3.Text = "Failed Searches: " + red; });
                textBox4.Invoke((MethodInvoker)delegate { textBox4.Text = "Total Count: " + total; });
                textBox5.Invoke((MethodInvoker)delegate { textBox5.Text = "Searches Left: " + r; });
                activesheet.Range["E" + 1].Value = textBox2.Text;
                activesheet.Range["E" + 2].Value = textBox3.Text;
                activesheet.Range["E" + 3].Value = textBox4.Text;
                activesheet.Range["E" + 4].Value = textBox5.Text;

                //Select the Correct Search (Policy# + DOB)
                driver.FindElement(By.XPath("//tr[2]/td[1]/div/div/table[2]/tbody/tr/td/form[2]/table/tbody/tr[2]/td[2]/input")).Click();
                DOBFormatter(DOB);
                //Making a selectors, because it makes the code more simple.
                IWebElement element = driver.FindElement(By.XPath("//tr/td/form[2]/table/tbody/tr[7]/td[2]/select"));
                SelectElement selector = new SelectElement(element);
                if (TaxIdOwner == "Company1" || TaxIdOwner == "Company2")
                {
                    selector.SelectByText("Option1");
                    Thread.Sleep(2000);
                    driver.FindElement(By.XPath("//tr[9]/td[2]/select")).Click();
                    driver.FindElement(By.XPath("//tr[9]/td[2]/select")).SendKeys(OpenQA.Selenium.Keys.ArrowDown);
                    driver.FindElement(By.XPath("//tr[9]/td[2]/select")).SendKeys(OpenQA.Selenium.Keys.ArrowDown);
                    driver.FindElement(By.XPath("//tr[9]/td[2]/select")).SendKeys(OpenQA.Selenium.Keys.Enter);

                }
                else if (TaxIdOwner == "Company3" || TaxIdOwner == "Company 4")
                {
                    selector.SelectByText("Option2");
                    Thread.Sleep(2000);
                    driver.FindElement(By.XPath("//tr/td/form[2]/table/tbody/tr[9]/td[2]/select")).Click();
                    driver.FindElement(By.XPath("//tr/td/form[2]/table/tbody/tr[9]/td[2]/select")).SendKeys(OpenQA.Selenium.Keys.ArrowDown);
                    driver.FindElement(By.XPath("//tr/td/form[2]/table/tbody/tr[9]/td[2]/select")).SendKeys(OpenQA.Selenium.Keys.ArrowDown);
                    driver.FindElement(By.XPath("//tr/td/form[2]/table/tbody/tr[9]/td[2]/select")).SendKeys(OpenQA.Selenium.Keys.ArrowDown);
                    driver.FindElement(By.XPath("//tr/td/form[2]/table/tbody/tr[9]/td[2]/select")).SendKeys(OpenQA.Selenium.Keys.ArrowDown);
                    driver.FindElement(By.XPath("//tr/td/form[2]/table/tbody/tr[9]/td[2]/select")).SendKeys(OpenQA.Selenium.Keys.ArrowDown);
                    driver.FindElement(By.XPath("//tr/td/form[2]/table/tbody/tr[9]/td[2]/select")).SendKeys(OpenQA.Selenium.Keys.Enter);

                }
                else if (TaxIdOwner == "Company5")
                {
                    selector.SelectByText("Option3");
                    Thread.Sleep(2000);
                    driver.FindElement(By.XPath("//tr/td/form[2]/table/tbody/tr[9]/td[2]/select")).Click();
                    driver.FindElement(By.XPath("//tr/td/form[2]/table/tbody/tr[9]/td[2]/select")).SendKeys(OpenQA.Selenium.Keys.ArrowDown);
                    driver.FindElement(By.XPath("//tr/td/form[2]/table/tbody/tr[9]/td[2]/select")).SendKeys(OpenQA.Selenium.Keys.ArrowDown);
                    driver.FindElement(By.XPath("//tr/td/form[2]/table/tbody/tr[9]/td[2]/select")).SendKeys(OpenQA.Selenium.Keys.ArrowDown);
                    driver.FindElement(By.XPath("//tr/td/form[2]/table/tbody/tr[9]/td[2]/select")).SendKeys(OpenQA.Selenium.Keys.Enter);

                }
                else if (TaxIdOwner == "Company6")
                {
                    selector.SelectByText("Option4");
                    Thread.Sleep(2000);
                    driver.FindElement(By.XPath("//tbody/tr/td/form[2]/table/tbody/tr[9]/td[2]/select")).Click();
                    driver.FindElement(By.XPath("//tbody/tr/td/form[2]/table/tbody/tr[9]/td[2]/select")).SendKeys(OpenQA.Selenium.Keys.ArrowDown);
                    driver.FindElement(By.XPath("//tbody/tr/td/form[2]/table/tbody/tr[9]/td[2]/select")).SendKeys(OpenQA.Selenium.Keys.ArrowDown);
                    driver.FindElement(By.XPath("//tbody/tr/td/form[2]/table/tbody/tr[9]/td[2]/select")).SendKeys(OpenQA.Selenium.Keys.ArrowDown);
                    driver.FindElement(By.XPath("//tbody/tr/td/form[2]/table/tbody/tr[9]/td[2]/select")).SendKeys(OpenQA.Selenium.Keys.Enter);
                }
                Thread.Sleep(3000);
                driver.FindElement(By.Name("checkDate")).Clear();
                driver.FindElement(By.Name("checkDate")).SendKeys(DOS);
                driver.FindElement(By.Name("endDate")).Clear();
                driver.FindElement(By.Name("endDate")).SendKeys(DOS);
                driver.FindElement(By.Name("enrolleeNo")).Clear();
                driver.FindElement(By.Name("enrolleeNo")).SendKeys(PolicyNum);
                driver.FindElement(By.Name("dobMM")).Clear();
                driver.FindElement(By.Name("dobMM")).SendKeys(month);
                driver.FindElement(By.Name("dobDD")).Clear();
                driver.FindElement(By.Name("dobDD")).SendKeys(day);
                driver.FindElement(By.Name("dobYYYY")).Clear();
                driver.FindElement(By.Name("dobYYYY")).SendKeys(year);
                driver.FindElement(By.Name("Submit")).Click();
                if (driver.FindElements(By.XPath("//tr[2]/td[1]/div/div/table[2]/tbody/tr/td/form[2]/table/tbody/tr[1]/td/b/font")).Count > 0)
                {
                    activesheet.Range["E" + n].Value = errorfix;
                    activesheet.Range["A" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightPink);
                    activesheet.Range["B" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightPink);
                    activesheet.Range["C" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightPink);
                    activesheet.Range["D" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightPink);
                    activesheet.Range["E" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightPink);
                    activesheet.Range["F" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightPink);
                    activesheet.Range["G" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightPink);
                    red++;
                }
                else if (driver.FindElements(By.XPath("//tr/td/form[2]/table/tbody/tr[1]/td/font/b")).Count > 0)
                {
                    errorfix = driver.FindElement(By.XPath("//tr/td/form[2]/table/tbody/tr[1]/td/font/b")).Text;
                    activesheet.Range["E" + n].Value = errorfix;
                    activesheet.Range["A" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightPink);
                    activesheet.Range["B" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightPink);
                    activesheet.Range["C" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightPink);
                    activesheet.Range["D" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightPink);
                    activesheet.Range["E" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightPink);
                    activesheet.Range["F" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightPink);
                    activesheet.Range["G" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightPink);
                    red++;
                }
                else if (driver.FindElements(By.XPath("//table/tbody/tr[1]/td/b[font[contains(text(), 'No claims found.')]]")).Count > 0)
                {
                    activesheet.Range["E" + n].Value = "No claims found.";
                    activesheet.Range["A" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightPink);
                    activesheet.Range["B" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightPink);
                    activesheet.Range["C" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightPink);
                    activesheet.Range["D" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightPink);
                    activesheet.Range["E" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightPink);
                    activesheet.Range["F" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightPink);
                    activesheet.Range["G" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightPink);
                    red++;
                }
                else if (driver.FindElements(By.XPath("//tr[3]/td/div[2]/table/tbody/tr[1]/td[9]")).Count > 0)
                {
                    if (driver.FindElements(By.XPath("//tr[3]/td/div[2]/table/tbody/tr[1]/td[9][contains(text(), 'Denied')]")).Count > 0)
                    {
                        activesheet.Range["F" + n].Value = driver.FindElement(By.XPath("//tr[3]/td/div[2]/table/tbody/tr[1]/td[9][contains(text(), 'Denied')]")).Text;
                        driver.FindElement(By.XPath("//tbody/tr/td[4]/div/table[3]/tbody/tr[3]/td/div[2]/table/tbody/tr[1]/td[12]/a")).Click();
                        activesheet.Range["G" + n].Value = driver.FindElement(By.XPath("//tbody/tr[1]/td[1]/table[1]/tbody/tr[4]/td/table/tbody/tr/td/span/span")).Text;
                        activesheet.Range["A" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Orange);
                        activesheet.Range["B" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Orange);
                        activesheet.Range["C" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Orange);
                        activesheet.Range["D" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Orange);
                        activesheet.Range["E" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Orange);
                        activesheet.Range["F" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Orange);
                        activesheet.Range["G" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Orange);
                        red++;
                    }
                    else
                    {
                        activesheet.Range["F" + n].Value = "Approved";
                        activesheet.Range["A" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightGreen);
                        activesheet.Range["B" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightGreen);
                        activesheet.Range["C" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightGreen);
                        activesheet.Range["D" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightGreen);
                        activesheet.Range["E" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightGreen);
                        activesheet.Range["F" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightGreen);
                        activesheet.Range["G" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightGreen);
                        green++;
                    }
                }
                else
                {
                    activesheet.Range["E" + n].Value = "No claims were found";
                    activesheet.Range["A" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightPink);
                    activesheet.Range["B" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightPink);
                    activesheet.Range["C" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightPink);
                    activesheet.Range["D" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightPink);
                    activesheet.Range["E" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightPink);
                    activesheet.Range["F" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightPink);
                    activesheet.Range["G" + n].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightPink);
                    red++;
                }
                total++;
                r--;
                driver.Navigate().GoToUrl("url");
                driver.Navigate().GoToUrl("url");
                n++;
            }
        }
        catch
        {
            progressBar1.Invoke((MethodInvoker)delegate { progressBar1.Value = progressBar1.Value - 1; });
            n--;
        }

    }
    private void DOBFormatter(string date)
    {
        int count = 0;
        int position = 0;
        while (count < 3)
        {
            //First go around, grab the first 2 numbers -- the month.
            if (count == 0)
            {
                month = date.Substring(position, 2);
            }
            //Second time, grab the day.
            else if (count == 1)
            {
                day = date.Substring(position, 2);
            }
            //Last go through grabs the year.
            else if (count == 2)
            {
                year = date.Substring(position, 4);
            }
            position = position + 3;
            count++;
        }
    }
公共部分类表1
{
私有void Sheet1_启动(对象发送方,System.EventArgs e)
{
}
私有无效表1\u关闭(对象发送器,System.EventArgs e)
{
}
#区域VSTO设计器生成的代码
/// 
///设计器支持所需的方法-不修改
///此方法的内容与代码编辑器一起使用。
/// 
私有void InternalStartup()
{
this.button1.Click+=新系统.EventHandler(this.button1\u Click);
this.backgroundWorker1.DoWork+=新系统.ComponentModel.DoWorkEventHandler(this.backgroundWorker1\u DoWork);
this.backgroundWorker1.ProgressChanged+=新系统.ComponentModel.ProgressChangedEventHandler(this.backgroundWorker1\u ProgressChanged\u 1);
this.Startup+=new System.EventHandler(this.Sheet1\u启动);
this.Shutdown+=new System.EventHandler(this.Sheet1\u Shutdown);
}
#端区
私有无效按钮1\u单击(对象发送者,事件参数e)
{
backgroundWorker1.RunWorkerAsync();
var CurrentPath=Path.GetDirectoryName(Assembly.getExecutionGassembly().Location);
}
//Globals——用于DOBFormatter();
字符串日期=”;
字符串月份=”;
字符串年份=”;
int n=0;
int l=0;
字符串errorfix=“”;
红色整数=0;
绿色整数=0;
int r=6;
int-total=0;
私有void backgroundWorker1\u DoWork(对象发送方,System.ComponentModel.DoWorkEventArgs e)
{
尝试
{
对象错误值=System.Reflection.Missing.Value;
var Excel=Globals.ThisWorkbook.Application;
var activesheet=Excel.activesheet;
字符串z=textBox1.Text.ToString();
n=转换为32(z);
字符串ActiveCell=Excel.ActiveSheet.Range[“A”+n,misValue].Text;
IWebDriver=新的FirefoxDriver();
如果(r==6)
{
while(activesheet.Range[“A”+r].Text.ToString().Length>0)
{
l++;
r++;
activesheet.Range[“E”+4].Value=“计算搜索次数:”+r;
}
}
总计=红色+绿色;
activesheet.Range[“E”+1]。Value=“成功搜索:”+绿色;
activesheet.Range[“E”+2]。Value=“搜索失败:”+red;
activesheet.Range[“E”+3]。Value=“搜索总数:”+Total;
activesheet.Range[“E”+4].Value=“剩余搜索数:”+r;
调用((MethodInvoker)委托{progressBar1.Maximum=l;});
//登入网页
driver.Navigate().gotour(“url”);
driver.FindElement(按.Name(“登录发送”))。单击();
driver.FindElement(By.Name(“EMAIL”)).SendKeys(“####”);
driver.FindElement(By.Name(“密码”)).SendKeys(“#####”);
driver.FindElement(By.Id(“submitButton”))。单击();
睡眠(时间跨度从秒(10));
driver.SwitchTo().Frame(“homeFrame”);
findelelement(By.XPath(“html/body/div[2]/div[3]/div[1]/h3/a[1]”);
findelelement(By.XPath(“html/body/div[2]/div[3]/section/ul/li[2]/a/img”)。单击();
driver.SwitchTo().Window(driver.WindowHandles[1]);
FindElement(By.XPath(“html/body/table[2]/tbody/tr[4]/td[3]/input”))。单击();
driver.Navigate().gotour(“url”);
while(activesheet.Range[“A”+n].Text.ToString().Length>0)
{
//更新%、进度栏和详细信息。
调用((MethodInvoker)委托{progressBar1.Value=progressBar1.Value+1;});
//变数
字符串DOS=activesheet.Range[“B”+n]。文本;
字符串PolicyNum=activesheet.Range[“C”+n]。文本;
字符串DOB=activesheet.Range[“D”+n]。文本;
字符串TaxIdOwner=activesheet.Range[“A”+n]。文本;
activesheet.Range[“A”+n].Interior.Color=System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Aqua);
activesheet.Range[“B”+n].Interior.Color=System.Drawing.colorplator.ToOle(System.Drawing.Color.Aqua);
activesheet.Range[“C”+n].Interior.Color=System.Drawing.colorplator.ToOle(System.Drawing.Color.Aqua);
activesheet.Range[“D