我运行一个非常简单的watin控制台应用程序,如下所示
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WatiN.Core;
namespace ConsoleApplication2
{
class Program
{
[STAThread]
static void Main(string[] args)
{
IE ie = new IE();
// point it to http://www.google.com
ie.GoTo("http://www.google.com");
// fill the search box
ie.TextField(Find.ByName("q")).TypeText("WatiN");
// performs click event
ie.Button(Find.ByValue("Google Search")).Click();
}
}
}这不管用。一个弹出窗口说有一个丢失的.exe文件。我无法理解,因为它只是一个控制台应用程序。为什么我需要.exe文件?
发布于 2012-11-02 11:53:32
如果您尝试通过Internet Explorer使用WatiN进行web应用程序测试,请确保首先完成正确的配置。
NUnit不使用STA apartment state在线程中运行测试;它使用multithreaded apartment (MTA),但这不是一个大问题,您可以将配置文件附加到NUnit测试项目并指定您想要的单元状态模式:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="NUnit">
<section name="TestRunner" type="System.Configuration.NameValueSectionHandler"/>
</sectionGroup>
</configSections>
<NUnit>
<TestRunner>
<!-- Valid values are STA, MTA. Others ignored. -->
<add key="ApartmentState" value="STA" />
</TestRunner>
</NUnit>
</configuration>文章参考:
WatiN, Internet Explorer and Thread.Apartmentstate
这篇文章解释了为什么以及如何将线程的ApartmentState设置为单踏步单元(
)。这在使用Internet Explorer运行测试时是必需的。它还向您展示了如何在将WatiN与NUnit、MBUnit、MSTest、TestDriven.Net、Fitnesse或SharpDevelop配合使用时执行此操作。
https://stackoverflow.com/questions/13188903
复制相似问题