我需要TestContext.Properties在 a 之前访问,TestMethod以便测试可以接收正确的环境进行测试。
我的内容test.runsettings:
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<TestRunParameters>
<Parameter name="colegio" value="7" />
</TestRunParameters>
Run Code Online (Sandbox Code Playgroud)
如您所见,该文件仅包含一个参数,称为 colegio (school)
这是内容TestBase.cs:
using Microsoft.VisualStudio.TestTools.UnitTesting;
using InfraestructureSelenium.Helper;
using System.Collections.Generic;
using InfraestructureSelenium.Configuration.Enumerados;
namespace TestSelenium
{
[DeploymentItem("chromedriver.exe")]
[DeploymentItem("IEDriverServer.exe")]
[DeploymentItem("phantomjs.exe")]
[DeploymentItem("geckodriver.exe")]
[TestClass]
public class TestBase
{
protected TestBase()
{ }
public TestBase(int id = (int)ColegioEnum.ColegioDemoMovilidad2_Supervisor)
{
DiccionarioCompartido = new Dictionary<string, string>();
SeleniumHelper = new HelperSelenium(id, WebDriverSelector.ObtenerWebDriver());
}
public TestBase(HelperSelenium seleniumHelper, Dictionary<string, string> diccionarioCompartido = null)
{
SeleniumHelper = seleniumHelper;
} …Run Code Online (Sandbox Code Playgroud) 我们正在使用 Azure DevOps 来运行使用 Visual Studio Test 运行测试的构建。
一切工作正常,Console.WriteLine行正在写入Standard Console Output.log,但TestContext.WriteLine没有出现在详细报告中。
相同的行确实出现在Visual Studio 中的Output链接中Test Explorer。
构建解决方案: Visual Studio 2017`
VS测试:最新
测试框架: MSTest.TestFramework 1.3.2
测试适配器: MSTest.TestAdapter 1.3.2
重申一下,TestContext正在正确实例化,我们可以检查本地计算机上的输出 ( Visual Studio 2015 Update 3),但是输出不会发布到 Azure Pipelines 版本
谢谢,问候
我试图将以下循环更改为 LINQ 表达式,但未成功:
int index = 0;
IList<IWebElement> divNota = new List<IWebElement>();
foreach (IWebElement element in tablaNotas)
{
divNota.Add(element.FindElement(By.Id("accion-1-celda-0-" + index + "-0")));
index++;
}
Run Code Online (Sandbox Code Playgroud)
我尝试使用
IList <IWebElement> divNota = tablaNotas.Select(element => element.FindElement(By.Id("accion-1-celda-0-"+ tablaNotas.IndexOf(element) + "-0"))).ToList();
Run Code Online (Sandbox Code Playgroud)
但tablaNotas.IndexOf(element)总是返回-1,意思element是里面没有找到tablaNotas。
该字符串"accion-1-celda-0-"+ tablaNotas.IndexOf(element) + "-0"旨在更改为
"accion-1-celda-0-"+ 1 + "-0"
"accion-1-celda-0-"+ 2 + "-0"
"accion-1-celda-0-"+ 3 + "-0"
...
"accion-1-celda-0-"+ n + "-0"
Run Code Online (Sandbox Code Playgroud)
根据元素的索引
任何帮助表示赞赏