【发布时间】:2020-08-31 15:33:12
【问题描述】:
我在 try catch 中有几个字符串,它们使用相同的变量 location
try
{
IWebElement bi7_reportHolder = ieDriver.FindElement(By.ClassName("iframe-qlik-view"));
//Check if Pop-up is present
location = ssLocation["SaveScreenShotLocation"] + "bi7_ScreenShot.png";
CheckPopUpAndTakeScreenShot(ieDriver, executor, location);
}
catch (System.Exception e)
{
Console.WriteLine(e.Message);
}
//Open bi8 Report - Concentration Risk
ieDriver.Navigate().GoToUrl("https://insightsmp.accenture.com/reports/9615a4f8-765f-4bed-9ccd-f8fa7cf3cbae/");
Thread.Sleep(60000);
wait.Until(d => ((IJavaScriptExecutor)d).ExecuteScript("return document.readyState").Equals("complete"));
try
{
IWebElement bi8_reportHolder = ieDriver.FindElement(By.Id("reportParent"));
//Check if Pop-up is present
location = ssLocation["SaveScreenShotLocation"] + "bi8_ScreenShot.png";
CheckPopUpAndTakeScreenShot(ieDriver, executor, location);
}
catch (System.Exception e)
{
Console.WriteLine(e.Message);
}
//Open Detailed Reporting
ieDriver.Navigate().GoToUrl("https://insightsmp.accenture.com/detailedReporting/");
Thread.Sleep(60000);
wait.Until(d => ((IJavaScriptExecutor)d).ExecuteScript("return document.readyState").Equals("complete"));
try
{
IWebElement dr_reportHolder = ieDriver.FindElement(By.Id("search-bar"));
//Check if Pop-up is present
location = ssLocation["SaveScreenShotLocation"] + "DR_ScreenShot.png";
CheckPopUpAndTakeScreenShot(ieDriver, executor, location);
}
catch (System.Exception e)
{
Console.WriteLine(e.Message);
}
我需要捕获所有这些字符串并将其作为 List 参数传递给我正在调用的方法,以便我可以在方法中使用它们。
List<string> screenshotLocation = location.ToString();
SendEmail(Application, screenshotLocation, bi6Accessible, bi7Accessible, bi8Accessible, detailedReportingAccessible);
我该怎么做?
【问题讨论】:
-
你快到了。创建一个列表,然后将add 字符串传递给它。完成。
标签: c# string selenium arraylist c#-4.0