IPEasyUtility.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. using System;
  2. using System.Data;
  3. using System.Diagnostics;
  4. using System.Dynamic;
  5. using System.Linq;
  6. using OpenQA.Selenium;
  7. using OpenQA.Selenium.Chrome;
  8. namespace wispro.sp.utility
  9. {
  10. public class IPEasyUtility
  11. {
  12. public static void DownloadReport(string strId,string filename)
  13. {
  14. string strFileSavePath = ConfigHelper.GetSectionValue("IPEasySetting:DownloadFileSavePath");
  15. bool isheadless = (ConfigHelper.GetSectionValue("IPEasySetting:isHeadless") == "true");
  16. string Account = ConfigHelper.GetSectionValue("IPEasySetting:Account");
  17. string Password = ConfigHelper.GetSectionValue("IPEasySetting:Password");
  18. OpenQA.Selenium.Chrome.ChromeOptions options = new OpenQA.Selenium.Chrome.ChromeOptions();
  19. options.AddUserProfilePreference("download.default_directory", strFileSavePath);
  20. options.AddUserProfilePreference("intl.accept_languages", "nl");
  21. options.AddUserProfilePreference("disable-popup-blocking", "true");
  22. if (isheadless)
  23. {
  24. options.AddArgument("headless");
  25. }
  26. using (IWebDriver driver = new OpenQA.Selenium.Chrome.ChromeDriver(ConfigHelper.GetSectionValue("IPEasySetting:ChormeDriverPath"), options))
  27. {
  28. try
  29. {
  30. driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(50);
  31. driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(500);
  32. //进入登录界面
  33. driver.Navigate().GoToUrl(ConfigHelper.GetSectionValue("IPEasySetting:IPEasyWeb"));
  34. //输入用户名和密码
  35. driver.FindElement(By.Id("txtUser")).SendKeys(Account);
  36. driver.FindElement(By.Id("txtPwd")).SendKeys(Password);
  37. //点击登录按钮
  38. driver.FindElement(By.Id("btnLogin")).Click();
  39. //关闭提示遮罩层
  40. driver.FindElement(By.Id("jpwClose")).Click();
  41. //点击顶部菜单栏中的报表管理菜单
  42. driver.FindElement(By.Name("970d33d5-c728-41b8-a060-4330610706b9")).Click();
  43. //点击左侧 自定义报表 菜单
  44. driver.FindElement(By.Name("642fa96f-1e1f-46fd-aaa4-cb461ee8df5b")).Click();
  45. //切换到自定义报表Frame
  46. driver.SwitchTo().Frame(1);
  47. //调用报表导出JS
  48. ((IJavaScriptExecutor)driver).ExecuteScript($"Report.Export('{strId}');");
  49. //切换到弹出的导出报表窗口,点击导出按钮
  50. driver.SwitchTo().DefaultContent();
  51. var ihg_export = driver.FindElement(By.Name("ihg_export"));
  52. driver.SwitchTo().Frame(ihg_export);
  53. driver.FindElement(By.Id("btnSubmit")).Click();
  54. string strFilePath = System.IO.Path.Combine(strFileSavePath, filename);
  55. while (true)
  56. {
  57. System.IO.FileInfo file = new System.IO.FileInfo(strFilePath);
  58. if (!file.Exists || file.Length == 0)
  59. {
  60. System.Threading.Thread.Sleep(5000);
  61. }
  62. else
  63. {
  64. break;
  65. }
  66. }
  67. }
  68. catch (Exception ex)
  69. {
  70. throw new Exception(ex.Message);
  71. }
  72. finally
  73. {
  74. killChromProcess();
  75. }
  76. }
  77. }
  78. /// <summary>
  79. /// 根据报表名称导出报表
  80. /// </summary>
  81. /// <param name="ReportName">报告名称</param>
  82. /// <param name="isModifyDate">是否手动修改日期范围</param>
  83. public static void DownloadReport(string ReportName,bool isModifyDate)
  84. {
  85. string strFileSavePath = ConfigHelper.GetSectionValue("IPEasySetting:DownloadFileSavePath");
  86. bool isheadless = (ConfigHelper.GetSectionValue("IPEasySetting:isHeadless") == "true");
  87. string Account = ConfigHelper.GetSectionValue("IPEasySetting:Account");
  88. string Password = ConfigHelper.GetSectionValue("IPEasySetting:Password");
  89. OpenQA.Selenium.Chrome.ChromeOptions options = new OpenQA.Selenium.Chrome.ChromeOptions();
  90. options.AddUserProfilePreference("download.default_directory", strFileSavePath);
  91. options.AddUserProfilePreference("intl.accept_languages", "nl");
  92. options.AddUserProfilePreference("disable-popup-blocking", "true");
  93. if (isheadless)
  94. {
  95. options.AddArgument("headless");
  96. }
  97. using (IWebDriver driver = new OpenQA.Selenium.Chrome.ChromeDriver(ConfigHelper.GetSectionValue("IPEasySetting:ChormeDriverPath"), options))
  98. {
  99. try
  100. {
  101. driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(50);
  102. driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(500);
  103. //进入登录界面
  104. driver.Navigate().GoToUrl(ConfigHelper.GetSectionValue("IPEasySetting:IPEasyWeb"));
  105. //输入用户名和密码
  106. driver.FindElement(By.Id("txtUser")).SendKeys(Account);
  107. driver.FindElement(By.Id("txtPwd")).SendKeys(Password);
  108. //点击登录按钮
  109. driver.FindElement(By.Id("btnLogin")).Click();
  110. //关闭提示遮罩层
  111. driver.FindElement(By.Id("jpwClose")).Click();
  112. //点击顶部菜单栏中的报表管理菜单
  113. driver.FindElement(By.Name("970d33d5-c728-41b8-a060-4330610706b9")).Click();
  114. //点击左侧 自定义报表 菜单
  115. driver.FindElement(By.Name("642fa96f-1e1f-46fd-aaa4-cb461ee8df5b")).Click();
  116. //切换到自定义报表Frame
  117. driver.SwitchTo().Frame(1);
  118. var inputSearch = driver.FindElement(By.Id("customizedList_TxtSheetSearchKey"));
  119. inputSearch.SendKeys(ReportName);
  120. var btnSearch = driver.FindElement(By.ClassName("btn-search"));
  121. btnSearch.Click();
  122. var reportRecord = driver.FindElement(By.XPath($"//td[contains(text(),'{ReportName}')]"));
  123. reportRecord.Click();
  124. System.Threading.Thread.Sleep(1000);
  125. if (isModifyDate)
  126. {
  127. var btnEdit = driver.FindElement(By.ClassName("edit"));
  128. btnEdit.Click();
  129. System.Threading.Thread.Sleep(500);
  130. var doItemFinished = driver.FindElement(By.XPath("//span[contains(@objcvalue,'_date') and contains(@id,'ST;')]"));
  131. doItemFinished.Click();
  132. System.Threading.Thread.Sleep(500);
  133. var startDate = driver.FindElement(By.XPath("//input[contains(@id,'dt_s_')]"));
  134. startDate.Click();
  135. System.Threading.Thread.Sleep(500);
  136. startDate.SendKeys(new DateTime(DateTime.Now.AddMonths(-1).Year, DateTime.Now.AddMonths(-1).Month, 1).ToString("yyyy-MM-dd"));
  137. var endDate = driver.FindElement(By.XPath("//input[contains(@id,'dt_e_')]"));//.Id("dt_e_4F8FE88D-9040-45F1-9723-45699BCD4CAF"));
  138. endDate.Click();
  139. System.Threading.Thread.Sleep(500);
  140. endDate.SendKeys(new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddDays(-1).ToString("yyyy-MM-dd"));
  141. var addDate = driver.FindElement(By.XPath("//a[contains(@onclick,'ReportSub.ConditionDTSelect')]"));
  142. addDate.Click();
  143. System.Threading.Thread.Sleep(500);
  144. var btnSave = driver.FindElement(By.Id("save"));
  145. btnSave.Click();
  146. System.Threading.Thread.Sleep(3000);
  147. }
  148. var linkExport = driver.FindElement(By.XPath("//a[contains(@onclick,'-') and @class='tbexcel']"));
  149. linkExport.Click();
  150. //切换到弹出的导出报表窗口,点击导出按钮
  151. driver.SwitchTo().DefaultContent();
  152. var ihg_export = driver.FindElement(By.Name("ihg_export"));
  153. driver.SwitchTo().Frame(ihg_export);
  154. driver.FindElement(By.Id("btnSubmit")).Click();
  155. string strFilePath = System.IO.Path.Combine(strFileSavePath, $"{ReportName.Trim()}.xlsx");
  156. int iwaiting = 0;
  157. while (true)
  158. {
  159. System.IO.FileInfo file = new System.IO.FileInfo(strFilePath.Replace("~", "_"));
  160. if (!file.Exists || file.Length == 0)
  161. {
  162. System.Threading.Thread.Sleep(5000);
  163. iwaiting += 5000;
  164. if (iwaiting > 360000)
  165. {
  166. break;
  167. }
  168. }
  169. else
  170. {
  171. break;
  172. }
  173. }
  174. }
  175. catch (Exception ex)
  176. {
  177. throw new Exception(ex.Message, ex);
  178. }
  179. finally
  180. {
  181. killChromProcess();
  182. }
  183. }
  184. }
  185. /// <summary>
  186. /// 获取案件基本信息
  187. /// </summary>
  188. /// <param name="caseNo">我方文号</param>
  189. /// <returns></returns>
  190. public static dynamic GetCaseInfo(string caseNo)
  191. {
  192. string strFileSavePath = ConfigHelper.GetSectionValue("IPEasySetting:DownloadFileSavePath");
  193. bool isheadless = (ConfigHelper.GetSectionValue("IPEasySetting:isHeadless") == "true");
  194. string Account = ConfigHelper.GetSectionValue("IPEasySetting:Account");
  195. string Password = ConfigHelper.GetSectionValue("IPEasySetting:Password");
  196. OpenQA.Selenium.Chrome.ChromeOptions options = new OpenQA.Selenium.Chrome.ChromeOptions();
  197. options.AddUserProfilePreference("download.default_directory", strFileSavePath);
  198. options.AddUserProfilePreference("intl.accept_languages", "nl");
  199. options.AddUserProfilePreference("disable-popup-blocking", "true");
  200. options.AddUserProfilePreference("profile", new { default_content_setting_values = new { images = 2 } });
  201. if (isheadless)
  202. {
  203. options.AddArgument("headless");
  204. }
  205. dynamic retObject = new ExpandoObject();
  206. retObject.CaseNo = caseNo;
  207. using (IWebDriver driver = new OpenQA.Selenium.Chrome.ChromeDriver(ConfigHelper.GetSectionValue("IPEasySetting:ChormeDriverPath"), options))
  208. {
  209. try
  210. {
  211. driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
  212. driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(100);
  213. //进入登录界面
  214. driver.Navigate().GoToUrl(ConfigHelper.GetSectionValue("IPEasySetting:IPEasyWeb"));
  215. //输入用户名和密码
  216. driver.FindElement(By.Id("txtUser")).SendKeys(Account);
  217. driver.FindElement(By.Id("txtPwd")).SendKeys(Password);
  218. //点击登录按钮
  219. driver.FindElement(By.Id("btnLogin")).Click();
  220. //关闭提示遮罩层
  221. driver.FindElement(By.Id("jpwClose")).Click();
  222. //点击顶部菜单栏中的案件管理菜单
  223. driver.FindElement(By.Name("71A7CC35-F597-40E1-9FEF-BE622A3A3B63")).Click();
  224. //点击左侧 查询 菜单
  225. driver.FindElement(By.Name("c3266ab3-521a-4815-8aaf-7dd0bc5a76af")).Click();
  226. //切换到自定义报表Frame
  227. driver.SwitchTo().Frame(1);
  228. var inputSearch = driver.FindElement(By.Id("case_volume"));
  229. inputSearch.SendKeys(caseNo);
  230. var btnSearch = driver.FindElement(By.Id("btn_Search"));
  231. btnSearch.Click();
  232. var caseLink = driver.FindElement(By.XPath($"//a[contains(text(),'{caseNo}')]"));
  233. caseLink.Click();
  234. System.Threading.Thread.Sleep(500);
  235. driver.SwitchTo().ParentFrame().SwitchTo().Frame(2);
  236. driver.FindElement(By.Id("libase")).Click();
  237. retObject.CaseName = driver.FindElement(By.Id("p_case_info__case_name")).GetAttribute("value"); //案件名称
  238. retObject.CustomerName = driver.FindElement(By.Id("p_case_info__customer_id")).GetAttribute("value"); //客户名称
  239. retObject.BusinessType = driver.FindElement(By.Id("p_case_info__business_type_id")).GetAttribute("value"); //业务类型
  240. retObject.CaseState = GetSelectText(driver.FindElement(By.Id("p_case_info__case_status_id")));
  241. retObject.ApplicationType = GetSelectText(driver.FindElement(By.Id("p_case_info__apply_type_id")));
  242. retObject.CaseType = driver.FindElement(By.Id("p_case_info__case_type_id")).GetAttribute("value"); //案件类型
  243. retObject.EntrustingDate = driver.FindElement(By.Id("p_case_info__charge_date")).GetAttribute("value"); //委案日期
  244. retObject.CaseMemo = driver.FindElement(By.Id("p_case_info__remark")).GetAttribute("value"); //案件备注
  245. driver.FindElement(By.XPath($"//span[contains(text(),'扩展信息')]")).Click();
  246. //select[@id='p_case_info__case_coefficient_id']
  247. retObject.CaseCoefficient = GetSelectText(driver.FindElement(By.Id("p_case_info__case_coefficient_id")));
  248. }
  249. catch (Exception ex)
  250. {
  251. throw new Exception(ex.Message, ex);
  252. }
  253. finally
  254. {
  255. killChromProcess();
  256. }
  257. }
  258. return retObject;
  259. }
  260. /// <summary>
  261. /// 获取案件处理事项记录
  262. /// </summary>
  263. /// <param name="caseNo">我方文号</param>
  264. /// <param name="doItemName">处理事项</param>
  265. /// <returns></returns>
  266. public static dynamic GetPerformanceRecord(string caseNo,string doItemName,string caseStage=null)
  267. {
  268. string strFileSavePath = ConfigHelper.GetSectionValue("IPEasySetting:DownloadFileSavePath");
  269. bool isheadless = (ConfigHelper.GetSectionValue("IPEasySetting:isHeadless") == "true");
  270. string Account = ConfigHelper.GetSectionValue("IPEasySetting:Account");
  271. string Password = ConfigHelper.GetSectionValue("IPEasySetting:Password");
  272. OpenQA.Selenium.Chrome.ChromeOptions options = new OpenQA.Selenium.Chrome.ChromeOptions();
  273. options.AddUserProfilePreference("download.default_directory", strFileSavePath);
  274. options.AddUserProfilePreference("intl.accept_languages", "nl");
  275. options.AddUserProfilePreference("disable-popup-blocking", "true");
  276. options.AddUserProfilePreference("profile", new { default_content_setting_values = new { images = 2 } });
  277. if (isheadless)
  278. {
  279. options.AddArgument("headless");
  280. }
  281. dynamic retObject = new ExpandoObject();
  282. retObject.CaseNo = caseNo;
  283. retObject.DoItem = doItemName;
  284. using (var Service = ChromeDriverService.CreateDefaultService(ConfigHelper.GetSectionValue("IPEasySetting:ChormeDriverPath")))
  285. {
  286. Service.Start();
  287. using (IWebDriver driver = new OpenQA.Selenium.Chrome.ChromeDriver(Service, options))
  288. {
  289. try
  290. {
  291. driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
  292. driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(100);
  293. //进入登录界面
  294. driver.Navigate().GoToUrl(ConfigHelper.GetSectionValue("IPEasySetting:IPEasyWeb"));
  295. //输入用户名和密码
  296. driver.FindElement(By.Id("txtUser")).SendKeys(Account);
  297. driver.FindElement(By.Id("txtPwd")).SendKeys(Password);
  298. //点击登录按钮
  299. driver.FindElement(By.Id("btnLogin")).Click();
  300. //关闭提示遮罩层
  301. driver.FindElement(By.Id("jpwClose")).Click();
  302. //点击顶部菜单栏中的案件管理菜单
  303. driver.FindElement(By.Name("71A7CC35-F597-40E1-9FEF-BE622A3A3B63")).Click();
  304. System.Threading.Thread.Sleep(500);
  305. //点击左侧 查询 菜单
  306. driver.FindElement(By.Name("c3266ab3-521a-4815-8aaf-7dd0bc5a76af")).Click();
  307. System.Threading.Thread.Sleep(500);
  308. //切换到自定义报表Frame
  309. driver.SwitchTo().Frame(1);
  310. var inputSearch = driver.FindElement(By.Id("case_volume"));
  311. inputSearch.SendKeys(caseNo);
  312. var btnSearch = driver.FindElement(By.Id("btn_Search"));
  313. btnSearch.Click();
  314. System.Threading.Thread.Sleep(500);
  315. var caseLink = driver.FindElement(By.XPath($"//a[normalize-space()='{caseNo}']"));
  316. caseLink.Click();
  317. System.Threading.Thread.Sleep(500);
  318. driver.SwitchTo().ParentFrame().SwitchTo().Frame(2);
  319. var DoItemLinks = driver.FindElements(By.XPath($"//td[@colname='ctrl_proc'][normalize-space()='{doItemName}']"));
  320. if (DoItemLinks.Count > 0)
  321. {
  322. if (!string.IsNullOrEmpty(caseStage))
  323. {
  324. foreach (var DoItemLink in DoItemLinks)
  325. {
  326. var temCaseStage = DoItemLink.FindElement(By.XPath("following-sibling::td[1]")).Text;
  327. if (temCaseStage == caseStage)
  328. {
  329. retObject.CaseStage = DoItemLink.FindElement(By.XPath("following-sibling::td[1]")).Text; //案件阶段
  330. retObject.DoItemState = DoItemLink.FindElement(By.XPath("following-sibling::td[2]")).Text; //处理事项处理状态
  331. retObject.InternalDate = DoItemLink.FindElement(By.XPath("following-sibling::td[4]")).Text; //内部期限
  332. retObject.CustomerLimitDate = DoItemLink.FindElement(By.XPath("following-sibling::td[5]")).Text; //客户期限
  333. retObject.FinishedDate = DoItemLink.FindElement(By.XPath("following-sibling::td[7]")).Text; //处理事项完成日
  334. retObject.DoPersons = DoItemLink.FindElement(By.XPath("following-sibling::td[8]")).Text; //处理人
  335. retObject.DoItemMemo = DoItemLink.FindElement(By.XPath("following-sibling::td[9]")).Text; //处理事项备注
  336. DoItemLink.Click();
  337. break;
  338. }
  339. }
  340. }
  341. else
  342. {
  343. var DoItemLink = DoItemLinks[DoItemLinks.Count - 1];
  344. retObject.CaseStage = DoItemLink.FindElement(By.XPath("following-sibling::td[1]")).Text; //案件阶段
  345. retObject.DoItemState = DoItemLink.FindElement(By.XPath("following-sibling::td[2]")).Text; //处理事项处理状态
  346. retObject.InternalDate = DoItemLink.FindElement(By.XPath("following-sibling::td[4]")).Text; //内部期限
  347. retObject.CustomerLimitDate = DoItemLink.FindElement(By.XPath("following-sibling::td[5]")).Text; //客户期限
  348. retObject.FinishedDate = DoItemLink.FindElement(By.XPath("following-sibling::td[7]")).Text; //处理事项完成日
  349. retObject.DoPersons = DoItemLink.FindElement(By.XPath("following-sibling::td[8]")).Text; //处理人
  350. retObject.DoItemMemo = DoItemLink.FindElement(By.XPath("following-sibling::td[9]")).Text; //处理事项备注
  351. DoItemLink.Click();
  352. }
  353. }
  354. System.Threading.Thread.Sleep(500);
  355. retObject.FinalizationDate = driver.FindElement(By.Id("p_proc_info__finish_doc_date")).GetAttribute("value"); //定稿日
  356. retObject.ReturnDate = driver.FindElement(By.Id("p_proc_info__back_date")).GetAttribute("value"); //返稿日
  357. retObject.Reviewer = driver.FindElement(By.Id("p_proc_info__revise_user")).GetAttribute("value"); //核稿人
  358. retObject.DoItemCoefficient = driver.FindElement(By.Id("p_proc_info__proc_coefficient")).GetAttribute("value"); //处理事项系数
  359. retObject.WordCount = driver.FindElement(By.Id("p_proc_info__translate_count")).GetAttribute("value"); //翻译字数
  360. driver.FindElement(By.Id("libase")).Click();
  361. System.Threading.Thread.Sleep(500);
  362. retObject.CaseName = driver.FindElement(By.Id("p_case_info__case_name")).GetAttribute("value"); //案件名称
  363. retObject.CustomerName = driver.FindElement(By.Id("p_case_info__customer_id")).GetAttribute("value"); //客户名称
  364. retObject.BusinessType = driver.FindElement(By.Id("p_case_info__business_type_id")).GetAttribute("value"); //业务类型
  365. retObject.CaseState = GetSelectText(driver.FindElement(By.Id("p_case_info__case_status_id")));
  366. retObject.ApplicationType = GetSelectText(driver.FindElement(By.Id("p_case_info__apply_type_id")));
  367. retObject.CaseType = driver.FindElement(By.Id("p_case_info__case_type_id")).GetAttribute("value"); //案件类型
  368. retObject.EntrustingDate = driver.FindElement(By.Id("p_case_info__charge_date")).GetAttribute("value"); //委案日期
  369. retObject.CaseMemo = driver.FindElement(By.Id("p_case_info__remark")).GetAttribute("value"); //案件备注
  370. driver.FindElement(By.XPath($"//span[contains(text(),'扩展信息')]")).Click();
  371. //select[@id='p_case_info__case_coefficient_id']
  372. retObject.CaseCoefficient = GetSelectText(driver.FindElement(By.Id("p_case_info__case_coefficient_id")));
  373. }
  374. catch (Exception ex)
  375. {
  376. throw new Exception(ex.Message, ex);
  377. }
  378. finally
  379. {
  380. killChromProcess();
  381. }
  382. }
  383. Service.Dispose();
  384. }
  385. return retObject;
  386. }
  387. private static void killChromProcess()
  388. {
  389. try
  390. {
  391. Process[] workers = Process.GetProcessesByName("Chrome");
  392. foreach (Process worker in workers)
  393. {
  394. worker.Kill();
  395. worker.WaitForExit();
  396. worker.Dispose();
  397. }
  398. workers = Process.GetProcessesByName("Chromedriver");
  399. foreach (Process worker in workers)
  400. {
  401. worker.Kill();
  402. worker.WaitForExit();
  403. worker.Dispose();
  404. }
  405. }
  406. catch { }
  407. }
  408. private static string GetSelectText(IWebElement element)
  409. {
  410. var strValue = element.GetAttribute("value");
  411. if (string.IsNullOrEmpty(strValue))
  412. {
  413. return null;
  414. }
  415. var ops = element.FindElements(By.TagName("option"));
  416. foreach (var op in ops)
  417. {
  418. if (op.GetAttribute("value") == strValue)
  419. {
  420. return op.Text;
  421. }
  422. }
  423. return null;
  424. }
  425. }
  426. }