gpt4 book ai didi

c# - 在 Visual Studio 中运行 Selenium 测试时出现 PNUnit 错误消息

转载 作者:太空宇宙 更新时间:2023-11-03 13:02:00 25 4
gpt4 key购买 nike

我正在尝试让 PNunit 为一些 Sauce Labs 测试工作。但是当我尝试使用 PNUnit Launcher.exe 启动它时,我收到以下错误消息:

“在程序集 PNUnit.Test.dll 中找不到测试 PNUnit_Test.SauceTest.TestCase”

这是我的示例测试代码:

using NUnit.Framework;
using PNUnit.Framework;
using System;
using System.Web;
using System.Text;
using System.Net;
using OpenQA.Selenium;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Support.UI;

namespace PNUnit_Test
{
[TestFixture()]
public class SauceTest
{
private IWebDriver driver;
private string[] testParams;

[SetUp]
public void Init()
{
testParams = PNUnitServices.Get().GetTestParams();
String params1 = String.Join(",", testParams);
Console.WriteLine(params1);
String browser = testParams[0];
String version = testParams[1];
String os = testParams[2];
String os_version = testParams[3];
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.SetCapability("browserName", browser);
capabilities.SetCapability(CapabilityType.Version, version);
capabilities.SetCapability("os", os);
capabilities.SetCapability("os_version", os_version);
capabilities.SetCapability("username", Constants.SAUCE_LABS_ACCOUNT_NAME);
capabilities.SetCapability("accessKey", Constants.SAUCE_LABS_ACCOUNT_KEY);

Console.WriteLine("Capabilities" + capabilities.ToString());

driver = new RemoteWebDriver(new Uri("http://ondemand.saucelabs.com:80/wd/hub"), capabilities);
}


[Test]
public void TestCase()
{
driver.Navigate().GoToUrl("http://www.google.com");
StringAssert.Contains("Google", driver.Title);
IWebElement query = driver.FindElement(By.Name("q"));
query.SendKeys("Sauce Labs");
query.Submit();
}

[TearDown]
public void Cleanup()
{
driver.Quit();
}
}
}

这是我用来设置我将用于测试的浏览器的 conf 文件:

<TestGroup>
<ParallelTests>
<ParallelTest>
<Name>Testing</Name>
<Tests>
<TestConf>
<Name>TestFF-40-Win8</Name>
<Assembly>PNUnit_Test.dll</Assembly>
<TestToRun>PNUnit_Test.SauceTest.TestCase</TestToRun>
<Machine>localhost:8081</Machine>
<TestParams>
<string>firefox</string> <!--browserName -->
<string>40.0</string> <!-- version -->
<string>Windows</string><!-- os -->
<string>8</string><!-- os_version -->
</TestParams>
</TestConf>
<TestConf>
<Name>TestFF-21-win7</Name>
<Assembly>PNUnit_Test.dll</Assembly>
<TestToRun>PNUnit_Test.SauceTest.TestCase</TestToRun>
<Machine>localhost:8081</Machine>
<TestParams>
<string>firefox</string> <!--browserName -->
<string>21.0</string> <!-- version -->
<string>Windows</string><!-- os -->
<string>7</string><!-- os_version -->
</TestParams>
</TestConf>
</Tests>
</ParallelTest>
</ParallelTests>
</TestGroup>

不确定我可能做错了什么并且找到有关使用 PNUnit 进行 C# Selenium 测试的信息很少,因此任何有用的提示都将不胜感激。谢谢!

最佳答案

想通了。我的 C# 项目是使用 .NET 4 框架构建的。 PNUnit 仅适用于 .NET 3.5。就个人而言,很高兴 NUnit 3 能够运行在 Net40 及更高版本上构建的并行项目

关于c# - 在 Visual Studio 中运行 Selenium 测试时出现 PNUnit 错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32043024/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com