开发者

Watin 2.1 error with Firefox 3.6 ContainsText and jssh

开发者 https://www.devze.com 2023-03-03 06:21 出处:网络
I have had problems using Firefox with Watin 2.0 and the recent 2.1 release. FireFox: 3.6.17 Watin: 2.1.0.1196

I have had problems using Firefox with Watin 2.0 and the recent 2.1 release.

  • FireFox: 3.6.17
  • Watin: 2.1.0.1196
  • Gallio / mbUnit: 3.2.601
  • Windows Server 2008 32 bit
  • .NET 4.0 assemblies
  • Visual Studio 2010

I went over these instructions repeatedly: http://watin.org/documentation/setting-up-firefox/

I went to Firefox, File->Open, navigated to the file: jssh-3.6-WINNT.xpi

Installed the XPI in Firefox without any problem.

A few things do work fine in FF with Watin. Finding text fields, TypeText, Click, all that works. But this line of c开发者_开发技巧ode blows up:

Assert.IsTrue(theBrowser.ContainsText(validationText), "Listing '{0}' was not found in the results.", validationText);

See below for the error. Any idea what I did wrong?

WatiN.Core.Native.Mozilla.FireFoxException: Error sending last message to jssh server: SyntaxError: missing ) after argument list
C:\QEDev\tools\WatiN\source\src\Core\Native\Mozilla\FireFoxClientPort.cs(422,0): at WatiN.Core.Native.Mozilla.FireFoxClientPort.CheckForError(String response)


Another user here on StackOverflow answered this question in a separate thread. Here is one workaround:

  • Sub-class based off of Watin's Firefox class
  • Override the ContainsText method
  • Use the HTML Agility Pack to load the document and call the Contains method.

This seemed to work fine for a while. On other computers I saw the same JSSH error as before.

public override bool ContainsText(string text)
{
    WaitForComplete();

    var htmldoc = new HtmlDocument();
    htmldoc.LoadHtml(Html);

    bool result = htmldoc.DocumentNode.InnerText.Contains(text);

    return result;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消