【发布时间】:2018-05-06 17:44:30
【问题描述】:
我正在尝试在 C# 中使用 Selenium 学习和设置 NUnit。
我的框架中包含以下内容
- Visual Studio 社区 2017
- NUnit 3 测试适配器,版本 3.9.0.0
- NUnit v3.9.0
- Selenium Webdriver 3.7.0
- Selenium Webdriver IEDriver v3.7.0
当我运行我的代码时,什么也没有发生。测试资源管理器没有显示任何执行。我无法解决这个问题。
查看此视频以了解问题:https://screencast-o-matic.com/watch/cbX3rQ2t6Z
下面是代码
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.IE;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TestTut
{
class Program
{
//Declaring Internet Explorer driver
IWebDriver driver = new InternetExplorerDriver();
static void Main(string[] args)
{
}
[SetUp]
public void Initialize()
{
// Navigate to test URL
driver.Navigate().GoToUrl("http://www.google.com/");
}
[Test]
public void ExecuteTest()
{
// Enter in Google search
IWebElement element = driver.FindElement(By.Name("q"));
// Perform action
element.SendKeys("This is a test");
Console.WriteLine("Type the text in search box");
}
[TearDown]
public void CloseDriver()
{
// Close the browser
driver.Close();
}
}
}
【问题讨论】:
标签: c# selenium automation nunit nunit-3.0