1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213 |
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Data;
- using System.Diagnostics;
- using System.Dynamic;
- using System.IO;
- using System.Linq;
- using System.Threading;
- using OpenQA.Selenium;
- using OpenQA.Selenium.Chrome;
- using OpenQA.Selenium.Support.Extensions;
- using OpenQA.Selenium.Support.UI;
- namespace wispro.sp.utility
- {
- public class IPEasyUtility
- {
- public static void DownloadReport(string strId,string filename)
- {
- string strFileSavePath = ConfigHelper.GetSectionValue("IPEasySetting:DownloadFileSavePath");
- bool isheadless = (ConfigHelper.GetSectionValue("IPEasySetting:isHeadless") == "true");
- string Account = ConfigHelper.GetSectionValue("IPEasySetting:Account");
- string Password = ConfigHelper.GetSectionValue("IPEasySetting:Password");
- OpenQA.Selenium.Chrome.ChromeOptions options = new OpenQA.Selenium.Chrome.ChromeOptions();
- options.AddUserProfilePreference("download.default_directory", strFileSavePath);
- options.AddUserProfilePreference("intl.accept_languages", "nl");
- options.AddUserProfilePreference("disable-popup-blocking", "true");
- if (isheadless)
- {
- options.AddArgument("headless");
- }
- using (IWebDriver driver = new OpenQA.Selenium.Chrome.ChromeDriver(ConfigHelper.GetSectionValue("IPEasySetting:ChormeDriverPath"), options))
- {
- try
- {
- driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(50);
- driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(500);
- //进入登录界面
- driver.Navigate().GoToUrl(ConfigHelper.GetSectionValue("IPEasySetting:IPEasyWeb"));
- //输入用户名和密码
- driver.FindElement(By.Id("txtUser")).SendKeys(Account);
- driver.FindElement(By.Id("txtPwd")).SendKeys(Password);
- //点击登录按钮
- driver.FindElement(By.Id("btnLogin")).Click();
- //关闭提示遮罩层
- driver.FindElement(By.Id("jpwClose")).Click();
- //点击顶部菜单栏中的报表管理菜单
- driver.FindElement(By.Name("970d33d5-c728-41b8-a060-4330610706b9")).Click();
- //点击左侧 自定义报表 菜单
- driver.FindElement(By.Name("642fa96f-1e1f-46fd-aaa4-cb461ee8df5b")).Click();
- //切换到自定义报表Frame
- driver.SwitchTo().Frame(1);
- //调用报表导出JS
- ((IJavaScriptExecutor)driver).ExecuteScript($"Report.Export('{strId}');");
- //切换到弹出的导出报表窗口,点击导出按钮
- driver.SwitchTo().DefaultContent();
- var ihg_export = driver.FindElement(By.Name("ihg_export"));
- driver.SwitchTo().Frame(ihg_export);
- driver.FindElement(By.Id("btnSubmit")).Click();
- string strFilePath = System.IO.Path.Combine(strFileSavePath, filename);
- while (true)
- {
- System.IO.FileInfo file = new System.IO.FileInfo(strFilePath);
- if (!file.Exists || file.Length == 0)
- {
- System.Threading.Thread.Sleep(5000);
- }
- else
- {
- break;
- }
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- finally
- {
- driver.Quit();
- driver.Dispose();
- killChromProcess();
- }
- }
- }
- private static void Log(string strMessage)
- {
- StreamWriter sw = File.AppendText("c:\\temp\\log.txt");
- sw.WriteLine($"{strMessage}");
- sw.Flush();
- sw.Close();
- sw.Dispose();
- }
- /// <summary>
- /// 根据报表名称导出报表
- /// </summary>
- /// <param name="ReportName">报告名称</param>
- /// <param name="isModifyDate">是否手动修改日期范围</param>
- public static DataTable DownloadReport(string ReportName,bool isModifyDate)
- {
- Log($"{DateTime.Now}\t开始下载:{ReportName}");
- DataTable retDatatable;
- string strFileSavePath = ConfigHelper.GetSectionValue("IPEasySetting:DownloadFileSavePath");
- bool isheadless = (ConfigHelper.GetSectionValue("IPEasySetting:isHeadless") == "true");
- string Account = ConfigHelper.GetSectionValue("IPEasySetting:Account");
- string Password = ConfigHelper.GetSectionValue("IPEasySetting:Password");
- OpenQA.Selenium.Chrome.ChromeOptions options = new OpenQA.Selenium.Chrome.ChromeOptions();
- options.AddUserProfilePreference("download.default_directory", strFileSavePath);
- options.AddUserProfilePreference("intl.accept_languages", "nl");
- options.AddUserProfilePreference("disable-popup-blocking", "true");
- if (isheadless)
- {
- options.AddArgument("headless");
- }
- Log($"{DateTime.Now}\t开始启动Chrome");
- using (IWebDriver driver = new OpenQA.Selenium.Chrome.ChromeDriver(ConfigHelper.GetSectionValue("IPEasySetting:ChormeDriverPath"), options))
- {
- try
- {
- Log($"{DateTime.Now}\tIWebDriver配置");
- driver.Manage().Window.Maximize();
- driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(50);
- driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(500);
- //进入登录界面
- Log($"{DateTime.Now}\t开始进入登录界面");
- driver.Navigate().GoToUrl(ConfigHelper.GetSectionValue("IPEasySetting:IPEasyWeb"));
- //输入用户名和密码
- driver.FindElement(By.Id("txtUser")).SendKeys(Account);
- driver.FindElement(By.Id("txtPwd")).SendKeys(Password);
- //点击登录按钮
- Log($"{DateTime.Now}\t开始点击登录按钮");
- driver.FindElement(By.Id("btnLogin")).Click();
- //关闭提示遮罩层
- Log($"{DateTime.Now}\t关闭提示遮罩层");
- driver.FindElement(By.Id("jpwClose")).Click();
- //点击顶部菜单栏中的报表管理菜单
- Log($"{DateTime.Now}\t点击顶部菜单栏中的报表管理菜单");
- var reportMenu = driver.FindElement(By.Name("970d33d5-c728-41b8-a060-4330610706b9"));
- driver.ExecuteJavaScript("arguments[0].click();", reportMenu);
- //点击左侧 自定义报表 菜单
- Log($"{DateTime.Now}\t点击左侧 自定义报表 菜单");
- var customerReportMenu = driver.FindElement(By.Name("642fa96f-1e1f-46fd-aaa4-cb461ee8df5b"));
- driver.ExecuteJavaScript("arguments[0].click();", customerReportMenu);
-
- //切换到自定义报表Frame
- Log($"{DateTime.Now}\t切换到自定义报表Frame");
- driver.SwitchTo().Frame(1);
- Log($"{DateTime.Now}\t开始搜索报告");
- var inputSearch = driver.FindElement(By.Id("customizedList_TxtSheetSearchKey"));
- Log($"{DateTime.Now}\t在搜索框中输入报告名称");
- inputSearch.SendKeys(ReportName);
- Log($"{DateTime.Now}\t点击搜索按钮");
- var btnSearch = driver.FindElement(By.ClassName("btn-search"));
- btnSearch.Click();
- Log($"{DateTime.Now}\t选中报告");
- var reportRecord = driver.FindElement(By.XPath($"//td[contains(text(),'{ReportName}')]"));
- reportRecord.Click();
- System.Threading.Thread.Sleep(1000);
- if (isModifyDate)
- {
- Log($"{DateTime.Now}\t点击编辑");
- var btnEdit = driver.FindElement(By.ClassName("edit"));
- btnEdit.Click();
- System.Threading.Thread.Sleep(500);
- Log($"{DateTime.Now}\t清除以选择的处理事项完成日条件");
- try
- {
- var doItemFinished = driver.FindElement(By.XPath("//span[contains(@objcvalue,'_date') and contains(@id,'ST;')]"));
- doItemFinished.Click();
- System.Threading.Thread.Sleep(500);
- }
- catch { }
- Log($"{DateTime.Now}\t输入处理事项完成日期:开始日期");
- var startDate = driver.FindElement(By.XPath("//input[contains(@id,'dt_s_')]"));
- startDate.Click();
- System.Threading.Thread.Sleep(500);
- startDate.SendKeys(new DateTime(DateTime.Now.AddMonths(-1).Year, DateTime.Now.AddMonths(-1).Month, 1).ToString("yyyy-MM-dd"));
- Log($"{DateTime.Now}\t输入处理事项完成日期:结束日期");
- var endDate = driver.FindElement(By.XPath("//input[contains(@id,'dt_e_')]"));//.Id("dt_e_4F8FE88D-9040-45F1-9723-45699BCD4CAF"));
- endDate.Click();
- System.Threading.Thread.Sleep(500);
- endDate.SendKeys(new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddDays(-1).ToString("yyyy-MM-dd"));
- Log($"{DateTime.Now}\t添加处理事项检索条件");
- var addDate = driver.FindElement(By.XPath("//a[contains(@onclick,'ReportSub.ConditionDTSelect')]"));
- addDate.Click();
- System.Threading.Thread.Sleep(500);
- Log($"{DateTime.Now}\t保存检索条件");
- var btnSave = driver.FindElement(By.Id("save"));
- btnSave.Click();
- System.Threading.Thread.Sleep(3000);
- }
- Log($"{DateTime.Now}\t点击导出Excel链接");
- var linkExport = driver.FindElement(By.XPath("//a[contains(@onclick,'-') and @class='tbexcel']"));
- linkExport.Click();
- //切换到弹出的导出报表窗口,点击导出按钮
- Log($"{DateTime.Now}\t切换到弹出的导出报表窗口,点击导出按钮");
- driver.SwitchTo().DefaultContent();
- var ihg_export = driver.FindElement(By.Name("ihg_export"));
- driver.SwitchTo().Frame(ihg_export);
- driver.FindElement(By.Id("btnSubmit")).Click();
- //切换到弹出的下载报表界面,点击下载按钮
- Log($"{DateTime.Now}\t切换到弹出的下载报表界面,点击下载按钮");
- System.Threading.Thread.Sleep(3000);
- driver.SwitchTo().DefaultContent();
- var frameDownload = driver.FindElement(By.Name("DownloadList"));
- driver.SwitchTo().Frame(frameDownload);
- var firstTr = driver.FindElement(By.TagName("tr"));
- var tdStatus = firstTr.FindElement(By.XPath("//td")).FindElement(By.XPath("following-sibling::td[4]"));
- string strStatus = tdStatus.Text;
- while (strStatus.Trim() != "导出成功!")
- {
- System.Threading.Thread.Sleep(5000);
- firstTr = driver.FindElement(By.TagName("tr"));
- tdStatus = firstTr.FindElement(By.XPath("//td")).FindElement(By.XPath("following-sibling::td[4]"));
- strStatus = tdStatus.Text;
- }
- Log($"{DateTime.Now}\t点击下载按钮下载文档");
- firstTr = driver.FindElement(By.TagName("tr"));
- firstTr.FindElement(By.XPath("//td/a[@title='下载']")).Click();
- //System.Threading.Thread.Sleep(5000);
- //btnDownload.Click();
- string strFilePath = System.IO.Path.Combine(strFileSavePath, $"{ReportName.Trim()}.xlsx");
-
- int iwaiting = 0;
- while (true)
- {
-
- System.IO.FileInfo file = new System.IO.FileInfo(strFilePath.Replace("~", "_"));
- if (!file.Exists || file.Length == 0)
- {
- System.Threading.Thread.Sleep(5000);
- iwaiting += 5000;
- if (iwaiting > 360000)
- {
- break;
- }
- }
- else
- {
- break;
- }
- }
- //删除下载记录
- Log($"{DateTime.Now}\t删除下载记录");
- firstTr = driver.FindElement(By.TagName("tr"));
- firstTr.FindElement(By.XPath("//td/a[@title='删除']")).Click();
- //System.IO.FileInfo file = new System.IO.FileInfo(strFilePath.Replace("~", "_"));
- retDatatable = NPOIExcel.ExcelToDataTable(strFilePath.Replace("~", "_"),true);
- System.IO.File.Delete(strFilePath.Replace("~", "_"));
- }
- catch (Exception ex)
- {
- Log(ex.ToString());
- throw new Exception(ex.Message, ex);
- }
- finally
- {
- Log("关闭Chrome");
- driver.Quit();
- driver.Dispose();
- killChromProcess();
- }
- }
- Log($"{DateTime.Now}\t返回数据");
- return retDatatable;
- }
- /// <summary>
- /// 获取案件基本信息
- /// </summary>
- /// <param name="caseNo">我方文号</param>
- /// <returns></returns>
- public static dynamic GetCaseInfo(string caseNo)
- {
- string strFileSavePath = ConfigHelper.GetSectionValue("IPEasySetting:DownloadFileSavePath");
- bool isheadless = (ConfigHelper.GetSectionValue("IPEasySetting:isHeadless") == "true");
- string Account = ConfigHelper.GetSectionValue("IPEasySetting:Account");
- string Password = ConfigHelper.GetSectionValue("IPEasySetting:Password");
- OpenQA.Selenium.Chrome.ChromeOptions options = new OpenQA.Selenium.Chrome.ChromeOptions();
- options.AddUserProfilePreference("download.default_directory", strFileSavePath);
- options.AddUserProfilePreference("intl.accept_languages", "nl");
- options.AddUserProfilePreference("disable-popup-blocking", "true");
- options.AddUserProfilePreference("profile", new { default_content_setting_values = new { images = 2 } });
- if (isheadless)
- {
- options.AddArgument("headless");
- }
- dynamic retObject = new ExpandoObject();
- retObject.CaseNo = caseNo.Trim();
- using (IWebDriver driver = new OpenQA.Selenium.Chrome.ChromeDriver(ConfigHelper.GetSectionValue("IPEasySetting:ChormeDriverPath"), options))
- {
- try
- {
- driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
- driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(100);
- //进入登录界面
- driver.Navigate().GoToUrl(ConfigHelper.GetSectionValue("IPEasySetting:IPEasyWeb"));
- //输入用户名和密码
- driver.FindElement(By.Id("txtUser")).SendKeys(Account);
- driver.FindElement(By.Id("txtPwd")).SendKeys(Password);
- //点击登录按钮
- driver.FindElement(By.Id("btnLogin")).Click();
- //关闭提示遮罩层
- driver.FindElement(By.Id("jpwClose")).Click();
- try
- {
- var okBtn = driver.FindElement(By.ClassName("ui_state_highlight"));
- if (okBtn != null && okBtn.TagName == "input")
- {
- okBtn.Click();
- }
- }
- catch { }
-
- //点击顶部菜单栏中的案件管理菜单
- driver.FindElement(By.Name("71A7CC35-F597-40E1-9FEF-BE622A3A3B63")).Click();
- //点击左侧 查询 菜单
- driver.FindElement(By.Name("c3266ab3-521a-4815-8aaf-7dd0bc5a76af")).Click();
- //切换到自定义报表Frame
- driver.SwitchTo().Frame(1);
- var inputSearch = driver.FindElement(By.Id("case_volume"));
- inputSearch.SendKeys(caseNo.Trim());
- var btnSearch = driver.FindElement(By.Id("btn_Search"));
- btnSearch.Click();
- var caseLink = driver.FindElement(By.XPath($"//a[contains(text(),'{caseNo}')]"));
- caseLink.Click();
- driver.SwitchTo().ParentFrame().SwitchTo().Frame(2);
- WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(20));
- //等待页面上ID属性值为submitButton的元素加载完成
- IWebElement myElement = wait.Until((d) =>
- {
- try
- {
- driver.SwitchTo().ParentFrame().SwitchTo().Frame(2);
- return d.FindElement(By.Id("libase"));
- }
- catch {
- return null;
- }
-
- });
- myElement.Click();
- //driver.FindElement(By.Id("libase")).Click();
- retObject.CaseName = driver.FindElement(By.Id("p_case_info__case_name")).GetAttribute("value"); //案件名称
- retObject.CustomerName = driver.FindElement(By.Id("p_case_info__customer_id")).GetAttribute("value"); //客户名称
- retObject.BusinessType = driver.FindElement(By.Id("p_case_info__business_type_id")).GetAttribute("value"); //业务类型
- retObject.CaseState = GetSelectText(driver.FindElement(By.Id("p_case_info__case_status_id")));
- retObject.ApplicationType = GetSelectText(driver.FindElement(By.Id("p_case_info__apply_type_id")));
- retObject.CaseType = driver.FindElement(By.Id("p_case_info__case_type_id")).GetAttribute("value"); //案件类型
- retObject.EntrustingDate = driver.FindElement(By.Id("p_case_info__charge_date")).GetAttribute("value"); //委案日期
- retObject.CaseMemo = driver.FindElement(By.Id("p_case_info__remark")).GetAttribute("value"); //案件备注
- driver.FindElement(By.XPath($"//span[contains(text(),'扩展信息')]")).Click();
- //select[@id='p_case_info__case_coefficient_id']
- retObject.CaseCoefficient = GetSelectText(driver.FindElement(By.Id("p_case_info__case_coefficient_id")));
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message, ex);
- }
- finally
- {
- driver.Quit();
- killChromProcess();
- }
- }
- return retObject;
- }
- public static dynamic GetPerformanceRecord(string caseNo, List<string> doItemNames)
- {
- string strFileSavePath = ConfigHelper.GetSectionValue("IPEasySetting:DownloadFileSavePath");
- bool isheadless = (ConfigHelper.GetSectionValue("IPEasySetting:isHeadless") == "true");
- string Account = ConfigHelper.GetSectionValue("IPEasySetting:Account");
- string Password = ConfigHelper.GetSectionValue("IPEasySetting:Password");
- OpenQA.Selenium.Chrome.ChromeOptions options = new OpenQA.Selenium.Chrome.ChromeOptions();
- options.AddUserProfilePreference("download.default_directory", strFileSavePath);
- options.AddUserProfilePreference("intl.accept_languages", "nl");
- options.AddUserProfilePreference("disable-popup-blocking", "true");
- options.AddUserProfilePreference("profile", new { default_content_setting_values = new { images = 2 } });
- if (isheadless)
- {
- options.AddArgument("headless");
- }
- dynamic retObject = new ExpandoObject();
- retObject.CaseNo = caseNo.Trim();
- //retObject.DoItem = doItemName;
- using (var Service = ChromeDriverService.CreateDefaultService(ConfigHelper.GetSectionValue("IPEasySetting:ChormeDriverPath")))
- {
- Service.Start();
- using (IWebDriver driver = new OpenQA.Selenium.Chrome.ChromeDriver(Service, options))
- {
- try
- {
- driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(20);
- driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(100);
- //driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(100);
- WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(20));
- //进入登录界面
- driver.Navigate().GoToUrl(ConfigHelper.GetSectionValue("IPEasySetting:IPEasyWeb"));
- //输入用户名和密码
- driver.FindElement(By.Id("txtUser")).SendKeys(Account);
- driver.FindElement(By.Id("txtPwd")).SendKeys(Password);
- //点击登录按钮
- driver.FindElement(By.Id("btnLogin")).Click();
- //关闭提示遮罩层
- driver.FindElement(By.Id("jpwClose")).Click();
- //try
- //{
- // var okBtn = driver.FindElement(By.ClassName("ui_state_highlight"));
- // if (okBtn != null && okBtn.TagName == "input")
- // {
- // okBtn.Click();
- // }
- //}
- //catch { }
- //点击顶部菜单栏中的案件管理菜单
- driver.FindElement(By.Name("71A7CC35-F597-40E1-9FEF-BE622A3A3B63")).Click();
- System.Threading.Thread.Sleep(500);
- //点击左侧 查询 菜单
- driver.FindElement(By.Name("c3266ab3-521a-4815-8aaf-7dd0bc5a76af")).Click();
- //System.Threading.Thread.Sleep(500);
- var inputSearch = wait.Until((d) =>
- {
- try
- {
- //切换到自定义报表Frame
- d.SwitchTo().Frame(1);
- return d.FindElement(By.Id("case_volume"));
- }
- catch
- {
- return null;
- }
- });
- //切换到自定义报表Frame
- //driver.SwitchTo().Frame(1);
- //var inputSearch = driver.FindElement(By.Id("case_volume"));
- inputSearch.SendKeys(caseNo.Trim());
- var btnSearch = driver.FindElement(By.Id("btn_Search"));
- btnSearch.Click();
- var caseLink = wait.Until((d) =>
- {
- try
- {
- return d.FindElement(By.XPath($"//a[normalize-space()='{caseNo.Trim()}']"));
- }
- catch
- {
- return null;
- }
- });
- //System.Threading.Thread.Sleep(500);
- //var caseLink = driver.FindElement(By.XPath($"//a[normalize-space()='{caseNo.Trim()}']"));
- caseLink.Click();
- System.Threading.Thread.Sleep(500);
- driver.SwitchTo().ParentFrame().SwitchTo().Frame(2);
- IWebElement temDoItemLink = null;
- string temFinishedDate = "";
- foreach (string doItemName in doItemNames)
- {
- var DoItemLinks = driver.FindElements(By.XPath($"//td[@colname='ctrl_proc'][normalize-space()='{doItemName}']"));
- if (DoItemLinks.Count > 0)
- {
- var DoItemLink = DoItemLinks[DoItemLinks.Count - 1];
- if (string.IsNullOrEmpty(temFinishedDate))
- {
- temFinishedDate = DoItemLink.FindElement(By.XPath("following-sibling::td[7]")).Text;
- temDoItemLink = DoItemLink;
- }
- else
- {
- if (DoItemLink.FindElement(By.XPath("following-sibling::td[7]")).Text.CompareTo(temFinishedDate) > 0)
- {
- temFinishedDate = DoItemLink.FindElement(By.XPath("following-sibling::td[7]")).Text;
- temDoItemLink = DoItemLink;
- }
- }
- //new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementToBeClickable(DoItemLink)).Click();
- }
- }
- if(temDoItemLink != null)
- {
- retObject.CaseStage = temDoItemLink.FindElement(By.XPath("following-sibling::td[1]")).Text; //案件阶段
- retObject.DoItemState = temDoItemLink.FindElement(By.XPath("following-sibling::td[2]")).Text; //处理事项处理状态
- retObject.InternalDate = temDoItemLink.FindElement(By.XPath("following-sibling::td[4]")).Text; //内部期限
- retObject.CustomerLimitDate = temDoItemLink.FindElement(By.XPath("following-sibling::td[5]")).Text; //客户期限
- retObject.FinishedDate = temDoItemLink.FindElement(By.XPath("following-sibling::td[7]")).Text; //处理事项完成日
- retObject.DoPersons = temDoItemLink.FindElement(By.XPath("following-sibling::td[8]")).Text; //处理人
- retObject.DoItemMemo = temDoItemLink.FindElement(By.XPath("following-sibling::td[9]")).Text; //处理事项备注
- retObject.Reviewer = temDoItemLink.FindElement(By.XPath("following-sibling::td[10]")).Text; //核稿人
- retObject.DoItem = temDoItemLink.Text;
- //temDoItemLink = DoItemLink;
- System.Threading.Thread.Sleep(4000);
- temDoItemLink.Click();
- }
- else
- {
- throw new ApplicationException("处理事项不存在!");
- }
- var p_proc_finish_doc_date = wait.Until((d) =>
- {
- try
- {
- return d.FindElement(By.Id("p_proc_info__finish_doc_date"));
- }
- catch
- {
- return null;
- }
- });
- //System.Threading.Thread.Sleep(500);
- retObject.FinalizationDate = p_proc_finish_doc_date.GetAttribute("value"); //定稿日
- retObject.ReturnDate = driver.FindElement(By.Id("p_proc_info__back_date")).GetAttribute("value"); //返稿日
- retObject.Reviewer = driver.FindElement(By.Id("p_proc_info__revise_user")).GetAttribute("value"); //核稿人
- retObject.DoItemCoefficient = driver.FindElement(By.Id("p_proc_info__proc_coefficient")).GetAttribute("value"); //处理事项系数
- retObject.WordCount = driver.FindElement(By.Id("p_proc_info__translate_count")).GetAttribute("value"); //翻译字数
- driver.FindElement(By.Id("libase")).Click();
- var p_case_info__case_name = wait.Until((d) =>
- {
- try
- {
- return d.FindElement(By.Id("p_case_info__case_name"));
- }
- catch
- {
- return null;
- }
- });
- //System.Threading.Thread.Sleep(500);
- retObject.CaseName = p_case_info__case_name.GetAttribute("value"); //案件名称
- retObject.CustomerName = driver.FindElement(By.Id("p_case_info__customer_id")).GetAttribute("value"); //客户名称
- retObject.BusinessType = driver.FindElement(By.Id("p_case_info__business_type_id")).GetAttribute("value"); //业务类型
- retObject.CaseState = GetSelectText(driver.FindElement(By.Id("p_case_info__case_status_id")));
- retObject.ApplicationType = GetSelectText(driver.FindElement(By.Id("p_case_info__apply_type_id")));
- retObject.CaseType = driver.FindElement(By.Id("p_case_info__case_type_id")).GetAttribute("value"); //案件类型
- retObject.EntrustingDate = driver.FindElement(By.Id("p_case_info__charge_date")).GetAttribute("value"); //委案日期
- retObject.CaseMemo = driver.FindElement(By.Id("p_case_info__remark")).GetAttribute("value"); //案件备注
- driver.FindElement(By.XPath($"//span[contains(text(),'扩展信息')]")).Click();
- //select[@id='p_case_info__case_coefficient_id']
- retObject.CaseCoefficient = GetSelectText(driver.FindElement(By.Id("p_case_info__case_coefficient_id")));
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message, ex);
- }
- finally
- {
- driver.Quit();
- killChromProcess();
- }
- }
- Service.Dispose();
- }
- return retObject;
- }
- /// <summary>
- /// 获取案件处理事项记录
- /// </summary>
- /// <param name="caseNo">我方文号</param>
- /// <param name="doItemName">处理事项</param>
- /// <returns></returns>
- public static dynamic GetPerformanceRecord(string caseNo,string doItemName,string caseStage=null)
- {
- if (caseNo.StartsWith("APCN"))
- {
- return GetAPCNPerformanceRecord(caseNo, doItemName, caseStage);
- }
- string strFileSavePath = ConfigHelper.GetSectionValue("IPEasySetting:DownloadFileSavePath");
- bool isheadless = (ConfigHelper.GetSectionValue("IPEasySetting:isHeadless") == "true");
- string Account = ConfigHelper.GetSectionValue("IPEasySetting:Account");
- string Password = ConfigHelper.GetSectionValue("IPEasySetting:Password");
- OpenQA.Selenium.Chrome.ChromeOptions options = new OpenQA.Selenium.Chrome.ChromeOptions();
- options.AddUserProfilePreference("download.default_directory", strFileSavePath);
- options.AddUserProfilePreference("intl.accept_languages", "nl");
- options.AddUserProfilePreference("disable-popup-blocking", "true");
- options.AddUserProfilePreference("profile", new { default_content_setting_values = new { images = 2 } });
- if (isheadless)
- {
- options.AddArgument("headless");
- }
- dynamic retObject = new ExpandoObject();
- retObject.CaseNo = caseNo.Trim();
- retObject.DoItem = doItemName;
- using (var Service = ChromeDriverService.CreateDefaultService(ConfigHelper.GetSectionValue("IPEasySetting:ChormeDriverPath")))
- {
- Service.Start();
- using (IWebDriver driver = new OpenQA.Selenium.Chrome.ChromeDriver(Service, options))
- {
- try
- {
- driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(20);
- driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(100);
- //driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(100);
- WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(20));
- //进入登录界面
- driver.Navigate().GoToUrl(ConfigHelper.GetSectionValue("IPEasySetting:IPEasyWeb"));
- //输入用户名和密码
- driver.FindElement(By.Id("txtUser")).SendKeys(Account);
- driver.FindElement(By.Id("txtPwd")).SendKeys(Password);
- //点击登录按钮
- driver.FindElement(By.Id("btnLogin")).Click();
- //关闭提示遮罩层
- driver.FindElement(By.Id("jpwClose")).Click();
- //try
- //{
- // var okBtn = driver.FindElement(By.ClassName("ui_state_highlight"));
- // if (okBtn != null && okBtn.TagName == "input")
- // {
- // okBtn.Click();
- // }
- //}
- //catch { }
- //点击顶部菜单栏中的案件管理菜单
- driver.FindElement(By.Name("71A7CC35-F597-40E1-9FEF-BE622A3A3B63")).Click();
- System.Threading.Thread.Sleep(500);
- //点击左侧 查询 菜单
- driver.FindElement(By.Name("c3266ab3-521a-4815-8aaf-7dd0bc5a76af")).Click();
-
- //System.Threading.Thread.Sleep(500);
- var inputSearch = wait.Until((d) =>
- {
- try
- {
- //切换到自定义报表Frame
- d.SwitchTo().Frame(1);
- return d.FindElement(By.Id("case_volume"));
- }
- catch
- {
- return null;
- }
- });
- //切换到自定义报表Frame
- //driver.SwitchTo().Frame(1);
- //var inputSearch = driver.FindElement(By.Id("case_volume"));
- inputSearch.SendKeys(caseNo.Trim());
- var btnSearch = driver.FindElement(By.Id("btn_Search"));
- btnSearch.Click();
- var caseLink = wait.Until((d) =>
- {
- try
- {
- return d.FindElement(By.XPath($"//a[normalize-space()='{caseNo.Trim()}']"));
- }
- catch
- {
- return null;
- }
- });
- //System.Threading.Thread.Sleep(500);
- //var caseLink = driver.FindElement(By.XPath($"//a[normalize-space()='{caseNo.Trim()}']"));
- caseLink.Click();
- System.Threading.Thread.Sleep(500);
- driver.SwitchTo().ParentFrame().SwitchTo().Frame(2);
- var DoItemLinks = driver.FindElements(By.XPath($"//td[@colname='ctrl_proc'][normalize-space()='{doItemName}']"));
- if (DoItemLinks.Count > 0)
- {
- if (!string.IsNullOrEmpty(caseStage))
- {
- foreach (var DoItemLink in DoItemLinks)
- {
- var temCaseStage = DoItemLink.FindElement(By.XPath("following-sibling::td[1]")).Text;
- if (temCaseStage == caseStage)
- {
- retObject.CaseStage = DoItemLink.FindElement(By.XPath("following-sibling::td[1]")).Text; //案件阶段
- retObject.DoItemState = DoItemLink.FindElement(By.XPath("following-sibling::td[2]")).Text; //处理事项处理状态
- retObject.InternalDate = DoItemLink.FindElement(By.XPath("following-sibling::td[4]")).Text; //内部期限
- retObject.CustomerLimitDate = DoItemLink.FindElement(By.XPath("following-sibling::td[5]")).Text; //客户期限
- retObject.FinishedDate = DoItemLink.FindElement(By.XPath("following-sibling::td[7]")).Text; //处理事项完成日
- retObject.DoPersons = DoItemLink.FindElement(By.XPath("following-sibling::td[8]")).Text; //处理人
- retObject.DoItemMemo = DoItemLink.FindElement(By.XPath("following-sibling::td[9]")).Text; //处理事项备注
- retObject.Reviewer = DoItemLink.FindElement(By.XPath("following-sibling::td[10]")).Text; //核稿人
- System.Threading.Thread.Sleep(4000);
- DoItemLink.Click();
- //driver.ExecuteJavaScript("$(arguments[0]).click()", DoItemLink);
- break;
- }
- }
- }
- else
- {
- var DoItemLink = DoItemLinks[DoItemLinks.Count - 1];
- retObject.CaseStage = DoItemLink.FindElement(By.XPath("following-sibling::td[1]")).Text; //案件阶段
- retObject.DoItemState = DoItemLink.FindElement(By.XPath("following-sibling::td[2]")).Text; //处理事项处理状态
- retObject.InternalDate = DoItemLink.FindElement(By.XPath("following-sibling::td[4]")).Text; //内部期限
- retObject.CustomerLimitDate = DoItemLink.FindElement(By.XPath("following-sibling::td[5]")).Text; //客户期限
- retObject.FinishedDate = DoItemLink.FindElement(By.XPath("following-sibling::td[7]")).Text; //处理事项完成日
- retObject.DoPersons = DoItemLink.FindElement(By.XPath("following-sibling::td[8]")).Text; //处理人
- retObject.DoItemMemo = DoItemLink.FindElement(By.XPath("following-sibling::td[9]")).Text; //处理事项备注
- retObject.Reviewer = DoItemLink.FindElement(By.XPath("following-sibling::td[10]")).Text; //核稿人
- System.Threading.Thread.Sleep(4000);
-
- DoItemLink.Click();
- //new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementToBeClickable(DoItemLink)).Click();
-
- }
- }
- var p_proc_finish_doc_date = wait.Until((d) =>
- {
- try
- {
- return d.FindElement(By.Id("p_proc_info__finish_doc_date"));
- }
- catch
- {
- return null;
- }
- });
- //System.Threading.Thread.Sleep(500);
- retObject.FinalizationDate = p_proc_finish_doc_date.GetAttribute("value"); //定稿日
- retObject.ReturnDate = driver.FindElement(By.Id("p_proc_info__back_date")).GetAttribute("value"); //返稿日
- retObject.Reviewer = driver.FindElement(By.Id("p_proc_info__revise_user")).GetAttribute("value"); //核稿人
- retObject.DoItemCoefficient = driver.FindElement(By.Id("p_proc_info__proc_coefficient")).GetAttribute("value"); //处理事项系数
- retObject.WordCount = driver.FindElement(By.Id("p_proc_info__translate_count")).GetAttribute("value"); //翻译字数
- driver.FindElement(By.Id("libase")).Click();
- var p_case_info__case_name = wait.Until((d) =>
- {
- try
- {
- return d.FindElement(By.Id("p_case_info__case_name"));
- }
- catch
- {
- return null;
- }
- });
- //System.Threading.Thread.Sleep(500);
- retObject.CaseName = p_case_info__case_name.GetAttribute("value"); //案件名称
- retObject.CustomerName = driver.FindElement(By.Id("p_case_info__customer_id")).GetAttribute("value"); //客户名称
- retObject.BusinessType = driver.FindElement(By.Id("p_case_info__business_type_id")).GetAttribute("value"); //业务类型
- retObject.CaseState = GetSelectText(driver.FindElement(By.Id("p_case_info__case_status_id")));
- retObject.ApplicationType = GetSelectText(driver.FindElement(By.Id("p_case_info__apply_type_id")));
- retObject.CaseType = driver.FindElement(By.Id("p_case_info__case_type_id")).GetAttribute("value"); //案件类型
- retObject.EntrustingDate = driver.FindElement(By.Id("p_case_info__charge_date")).GetAttribute("value"); //委案日期
- retObject.CaseMemo = driver.FindElement(By.Id("p_case_info__remark")).GetAttribute("value"); //案件备注
- driver.FindElement(By.XPath($"//span[contains(text(),'扩展信息')]")).Click();
- //select[@id='p_case_info__case_coefficient_id']
- retObject.CaseCoefficient = GetSelectText(driver.FindElement(By.Id("p_case_info__case_coefficient_id")));
-
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message, ex);
- }
- finally
- {
- driver.Quit();
-
- killChromProcess();
- }
- }
- Service.Dispose();
- }
- return retObject;
- }
- private static dynamic GetAPCNPerformanceRecord(string caseNo, string doItemName, string caseStage = null)
- {
- string strFileSavePath = ConfigHelper.GetSectionValue("IPEasySetting:DownloadFileSavePath");
- bool isheadless = (ConfigHelper.GetSectionValue("IPEasySetting:isHeadless") == "true");
- string Account = ConfigHelper.GetSectionValue("IPEasySetting:Account");
- string Password = ConfigHelper.GetSectionValue("IPEasySetting:Password");
- OpenQA.Selenium.Chrome.ChromeOptions options = new OpenQA.Selenium.Chrome.ChromeOptions();
- options.AddUserProfilePreference("download.default_directory", strFileSavePath);
- options.AddUserProfilePreference("intl.accept_languages", "nl");
- options.AddUserProfilePreference("disable-popup-blocking", "true");
- options.AddUserProfilePreference("profile", new { default_content_setting_values = new { images = 2 } });
- if (isheadless)
- {
- options.AddArgument("headless");
- }
- dynamic retObject = new ExpandoObject();
- retObject.CaseNo = caseNo.Trim();
- retObject.DoItem = doItemName;
- using (var Service = ChromeDriverService.CreateDefaultService(ConfigHelper.GetSectionValue("IPEasySetting:ChormeDriverPath")))
- {
- Service.Start();
- using (IWebDriver driver = new OpenQA.Selenium.Chrome.ChromeDriver(Service, options))
- {
- try
- {
- driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(20);
- driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(100);
- //driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(100);
- WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(20));
- //进入登录界面
- driver.Navigate().GoToUrl(ConfigHelper.GetSectionValue("IPEasySetting:IPEasyWeb"));
- //输入用户名和密码
- driver.FindElement(By.Id("txtUser")).SendKeys(Account);
- driver.FindElement(By.Id("txtPwd")).SendKeys(Password);
- //点击登录按钮
- driver.FindElement(By.Id("btnLogin")).Click();
- //关闭提示遮罩层
- driver.FindElement(By.Id("jpwClose")).Click();
- //try
- //{
- // var okBtn = driver.FindElement(By.ClassName("ui_state_highlight"));
- // if (okBtn != null && okBtn.TagName == "input")
- // {
- // okBtn.Click();
- // }
- //}
- //catch { }
- //点击顶部菜单栏中的案件管理菜单
- driver.FindElement(By.Name("71A7CC35-F597-40E1-9FEF-BE622A3A3B63")).Click();
- System.Threading.Thread.Sleep(500);
- //点击左侧 查询 菜单
- driver.FindElement(By.Name("FF4E1FF9-FE36-4F0F-99DF-81E60817722E")).Click();
- //System.Threading.Thread.Sleep(500);
- var inputSearch = wait.Until((d) =>
- {
- try
- {
- //切换到自定义报表Frame
- d.SwitchTo().Frame(1);
- return d.FindElement(By.Id("case_volume"));
- }
- catch
- {
- return null;
- }
- });
- //切换到自定义报表Frame
- //driver.SwitchTo().Frame(1);
- //var inputSearch = driver.FindElement(By.Id("case_volume"));
- inputSearch.SendKeys(caseNo.Trim());
- var btnSearch = driver.FindElement(By.Id("btn_Search"));
- btnSearch.Click();
- var caseLink = wait.Until((d) =>
- {
- try
- {
- return d.FindElement(By.XPath($"//a[normalize-space()='{caseNo.Trim()}']"));
- }
- catch
- {
- return null;
- }
- });
- //System.Threading.Thread.Sleep(500);
- //var caseLink = driver.FindElement(By.XPath($"//a[normalize-space()='{caseNo.Trim()}']"));
- caseLink.Click();
- System.Threading.Thread.Sleep(500);
- driver.SwitchTo().ParentFrame().SwitchTo().Frame(2);
- var DoItemLinks = driver.FindElements(By.XPath($"//td[@colname='ctrl_proc'][normalize-space()='{doItemName}']"));
- if (DoItemLinks.Count > 0)
- {
- if (!string.IsNullOrEmpty(caseStage))
- {
- foreach (var DoItemLink in DoItemLinks)
- {
- var temCaseStage = DoItemLink.FindElement(By.XPath("following-sibling::td[1]")).Text;
- if (temCaseStage == caseStage)
- {
- retObject.CaseStage = DoItemLink.FindElement(By.XPath("following-sibling::td[1]")).Text; //案件阶段
- retObject.DoItemState = DoItemLink.FindElement(By.XPath("following-sibling::td[2]")).Text; //处理事项处理状态
- retObject.InternalDate = DoItemLink.FindElement(By.XPath("following-sibling::td[4]")).Text; //内部期限
- retObject.CustomerLimitDate = DoItemLink.FindElement(By.XPath("following-sibling::td[5]")).Text; //客户期限
- retObject.FinishedDate = DoItemLink.FindElement(By.XPath("following-sibling::td[7]")).Text; //处理事项完成日
- retObject.DoPersons = DoItemLink.FindElement(By.XPath("following-sibling::td[8]")).Text; //处理人
- retObject.DoItemMemo = DoItemLink.FindElement(By.XPath("following-sibling::td[9]")).Text; //处理事项备注
- retObject.Reviewer = DoItemLink.FindElement(By.XPath("following-sibling::td[10]")).Text; //核稿人
- System.Threading.Thread.Sleep(4000);
- DoItemLink.Click();
- //driver.ExecuteJavaScript("$(arguments[0]).click()", DoItemLink);
- break;
- }
- }
- }
- else
- {
- var DoItemLink = DoItemLinks[DoItemLinks.Count - 1];
- //retObject.CaseStage = DoItemLink.FindElement(By.XPath("following-sibling::td[1]")).Text; //案件阶段
- retObject.DoItemState = DoItemLink.FindElement(By.XPath("following-sibling::td[1]")).Text; //处理事项处理状态
- retObject.InternalDate = DoItemLink.FindElement(By.XPath("following-sibling::td[3]")).Text; //内部期限
- retObject.CustomerLimitDate = DoItemLink.FindElement(By.XPath("following-sibling::td[4]")).Text; //客户期限
- retObject.FinishedDate = DoItemLink.FindElement(By.XPath("following-sibling::td[6]")).Text; //处理事项完成日
- retObject.DoPersons = DoItemLink.FindElement(By.XPath("following-sibling::td[7]")).Text; //处理人
- retObject.DoItemMemo = DoItemLink.FindElement(By.XPath("following-sibling::td[10]")).Text; //处理事项备注
- //retObject.Reviewer = DoItemLink.FindElement(By.XPath("following-sibling::td[10]")).Text; //核稿人
- System.Threading.Thread.Sleep(4000);
- DoItemLink.Click();
- //new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementToBeClickable(DoItemLink)).Click();
- }
- }
- var p_proc_finish_doc_date = wait.Until((d) =>
- {
- try
- {
- return d.FindElement(By.Id("p_proc_info__finish_doc_date"));
- }
- catch
- {
- return null;
- }
- });
- //System.Threading.Thread.Sleep(500);
- retObject.FinalizationDate = p_proc_finish_doc_date.GetAttribute("value"); //定稿日
- retObject.ReturnDate = driver.FindElement(By.Id("p_proc_info__back_date")).GetAttribute("value"); //返稿日
- retObject.Reviewer = driver.FindElement(By.Id("p_proc_info__revise_user")).GetAttribute("value"); //核稿人
- retObject.DoItemCoefficient = driver.FindElement(By.Id("p_proc_info__proc_coefficient")).GetAttribute("value"); //处理事项系数
- retObject.WordCount = driver.FindElement(By.Id("p_proc_info__translate_count")).GetAttribute("value"); //翻译字数
- driver.FindElement(By.Id("libase")).Click();
- var p_case_info__case_name = wait.Until((d) =>
- {
- try
- {
- return d.FindElement(By.Id("p_case_info__case_name"));
- }
- catch
- {
- return null;
- }
- });
- //System.Threading.Thread.Sleep(500);
- retObject.CaseName = p_case_info__case_name.GetAttribute("value"); //案件名称
- retObject.CustomerName = driver.FindElement(By.Id("p_case_info__customer_id")).GetAttribute("value"); //客户名称
- retObject.BusinessType = driver.FindElement(By.Id("p_case_info__business_type_id")).GetAttribute("value"); //业务类型
- retObject.CaseState = GetSelectText(driver.FindElement(By.Id("p_case_info__case_status_id")));
- retObject.ApplicationType = GetSelectText(driver.FindElement(By.Id("p_case_info__apply_type_id")));
- retObject.CaseType = driver.FindElement(By.Id("p_case_info__case_type_id")).GetAttribute("value"); //案件类型
- retObject.EntrustingDate = driver.FindElement(By.Id("p_case_info__charge_date")).GetAttribute("value"); //委案日期
- retObject.CaseMemo = driver.FindElement(By.Id("p_case_info__remark")).GetAttribute("value"); //案件备注
- //driver.FindElement(By.XPath($"//span[contains(text(),'扩展信息')]")).Click();
- //select[@id='p_case_info__case_coefficient_id']
- //retObject.CaseCoefficient = GetSelectText(driver.FindElement(By.Id("p_case_info__case_coefficient_id")));
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message, ex);
- }
- finally
- {
- driver.Quit();
- killChromProcess();
- }
- }
- Service.Dispose();
- }
- return retObject;
- }
- private static void killChromProcess()
- {
- try
- {
- Process[] workers = Process.GetProcessesByName("Chrome");
- foreach (Process worker in workers)
- {
- worker.Kill();
- worker.WaitForExit();
- worker.Dispose();
- }
- workers = Process.GetProcessesByName("Chromedriver");
- foreach (Process worker in workers)
- {
- worker.Kill();
- worker.WaitForExit();
- worker.Dispose();
- }
- }
- catch { }
- }
- private static string GetSelectText(IWebElement element)
- {
- var strValue = element.GetAttribute("value");
- if (string.IsNullOrEmpty(strValue))
- {
- return null;
- }
- var ops = element.FindElements(By.TagName("option"));
- foreach (var op in ops)
- {
- if (op.GetAttribute("value") == strValue)
- {
- return op.Text;
- }
- }
- return null;
- }
- }
- }
|