首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用watin

无法使用watin
EN

Stack Overflow用户
提问于 2012-11-02 11:28:30
回答 1查看 1.3K关注 0票数 1

我运行一个非常简单的watin控制台应用程序,如下所示

代码语言:javascript
复制
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文件?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-11-02 11:53:32

如果您尝试通过Internet Explorer使用WatiN进行web应用程序测试,请确保首先完成正确的配置。

NUnit不使用STA apartment state在线程中运行测试;它使用multithreaded apartment (MTA),但这不是一个大问题,您可以将配置文件附加到NUnit测试项目并指定您想要的单元状态模式:

代码语言:javascript
复制
<?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配合使用时执行此操作。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13188903

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档