gpt4 book ai didi

unit-testing - 使用 WatiN 和 NUnit 进行单元测试

转载 作者:行者123 更新时间:2023-12-04 16:56:41 25 4
gpt4 key购买 nike

似乎有关 WatiN 的 SO 问题之间的共同主题与实际使事情正常工作有关,我也不异常(exception)。

我已经下载了最新版本的 WatiN (2.0.20.1089),并且正在尝试创建与 Hello, World 等效的 NUnit/WatiN:

using WatiN.Core;
using NUnit.Framework;

namespace Foo.Browser.Tests
{
[TestFixture]
public class BrowserTests
{
[Test]
[STAThread]
public void ExampleTest()
{

IE ie = new IE("http://www.google.com");

ie.TextField(Find.ByName("q")).TypeText("WatiN");
ie.Button(Find.ByValue("Google Search")).Click();
Link link = ie.Link(Find.ByUrl("http://watin.sourceforge.net/"));

Assert.That(link.Text == "WatiN Home");
}

[Test]
public void FirefoxTest()
{
FireFox ff = new FireFox("http://www.google.com");

ff.TextField(Find.ByName("q")).TypeText("WatiN");

ff.Button(Find.ByValue("Google Search")).Click();
Link link = ff.Link(Find.ByUrl("http://watin.sourceforge.net/"));

Assert.That(link.Text == "WatiN Home");
}
}

这会在最终超时后使用以下堆栈跟踪提示 IE(8):

at WatiN.Core.UtilityClasses.TryFuncUntilTimeOut.ThrowTimeOutException(Exception lastException, String message) at WatiN.Core.UtilityClasses.TryFuncUntilTimeOut.HandleTimeOut() at WatiN.Core.UtilityClasses.TryFuncUntilTimeOut.Try[T](DoFunc'1 func) at WatiN.Core.WaitForCompleteBase.WaitUntil(DoFunc'1 waitWhile, BuildTimeOutExceptionMessage exceptionMessage) at WatiN.Core.Native.InternetExplorer.IEWaitForComplete.WaitWhileFrameDocumentNotAvailable(IWebBrowser2 frame) at WatiN.Core.Native.InternetExplorer.IEWaitForComplete.WaitForFramesToComplete(IHTMLDocument2 maindocument) at WatiN.Core.Native.InternetExplorer.IEWaitForComplete.WaitForFramesToComplete(IHTMLDocument2 maindocument) at WatiN.Core.Native.InternetExplorer.IEWaitForComplete.WaitForCompleteOrTimeout() at WatiN.Core.WaitForCompleteBase.DoWait() at WatiN.Core.DomContainer.WaitForComplete(IWait waitForComplete) at WatiN.Core.IE.WaitForComplete(Int32 waitForCompleteTimeOut) at WatiN.Core.DomContainer.WaitForComplete() at WatiN.Core.Browser.GoTo(Uri url) at WatiN.Core.IE.FinishInitialization(Uri uri) at WatiN.Core.IE.CreateNewIEAndGoToUri(Uri uri, IDialogHandler logonDialogHandler, Boolean createInNewProcess) at WatiN.Core.IE..ctor(String url) at Foo.Browser.Tests.BrowserTests.ExampleTest() in C:\Development\Foo\Foo.Browser.Tests\BrowserTests.cs:line 19



我的 bin\debug 文件夹(Foo.Browser.Tests.dll.config)中有必要的配置文件,如 WatiN documentation page 所指定的,那么还有可能是什么?
有没有人对可能导致问题的原因有任何建议?

最佳答案

菲尔,

看看抛出的 TimeoutExcepetion 的 InnerException。这很可能包含更多信息来解决您的问题。

HTH
杰伦·范·梅嫩
首席开发人员 WatiN

关于unit-testing - 使用 WatiN 和 NUnit 进行单元测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2097907/

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