|
@@ -128,10 +128,12 @@ namespace wispro.sp.utility
|
|
|
|
|
|
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("safebrowsing.enabled", true);
|
|
|
+ options.AddArgument($"--unsafely-treat-insecure-origin-as-secure={ConfigHelper.GetSectionValue("IPEasySetting:IPEasyWeb").Replace("/Login.aspx","")}");//替换自己的域名,多域名可用逗号分隔。
|
|
|
if (isheadless)
|
|
|
{
|
|
|
options.AddArgument("headless");
|
|
@@ -141,6 +143,11 @@ namespace wispro.sp.utility
|
|
|
{
|
|
|
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));
|
|
|
+
|
|
|
Log($"{DateTime.Now}\tIWebDriver配置");
|
|
|
driver.Manage().Window.Maximize();
|
|
|
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(50);
|
|
@@ -218,7 +225,22 @@ namespace wispro.sp.utility
|
|
|
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"));
|
|
|
+
|
|
|
+ var endDate = wait.Until((d) =>
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ return d.FindElement(By.XPath("//input[contains(@id,'dt_e_')]"));//.Id("dt_e_4F8FE88D-9040-45F1-9723-45699BCD4CAF"));
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ //var endDate = driver.FindElement(By.XPath("//input[contains(@id,'dt_e_')]"));//.Id("dt_e_4F8FE88D-9040-45F1-9723-45699BCD4CAF"));
|
|
|
+ System.Threading.Thread.Sleep(20000);
|
|
|
+ //driver.ExecuteJavaScript("arguments[0].click();", endDate);
|
|
|
endDate.Click();
|
|
|
System.Threading.Thread.Sleep(500);
|
|
|
endDate.SendKeys(new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddDays(-1).ToString("yyyy-MM-dd"));
|
|
@@ -258,6 +280,11 @@ namespace wispro.sp.utility
|
|
|
string strStatus = tdStatus.Text;
|
|
|
while (strStatus.Trim() != "导出成功!")
|
|
|
{
|
|
|
+ if(strStatus.Trim() == "导出失败,请稍后重试!")
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
System.Threading.Thread.Sleep(5000);
|
|
|
firstTr = driver.FindElement(By.TagName("tr"));
|
|
|
tdStatus = firstTr.FindElement(By.XPath("//td")).FindElement(By.XPath("following-sibling::td[4]"));
|