Watin 2.1 error with Firefox 3.6 ContainsText and jssh - firefox

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 code 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;
}

Related

Firefox Annotator SDK tutorial, cannot get the annotator button to work

Link to the tutorial
I am trying to get to grips with Firefox SDK development using the tutorials on MDN. The annotator tutorials seem very good but CFX Run fails on the first control stage.
The tutorial uses the widget API that was deprecated in Firefox 29 but I tried downgrading Firefox 28 and the tutorial still doesn't work even when I am copy and pasting the code directly from the page code. When I come to the end of the Implementing the widget page I only get the following message when trying to click the widget icon (the first time, then nothing hapens).
(C:\Users\myname\Firefoxplayground\addon-sdk-1.16) C:\Users\myname\Firefoxplay
ground\pageMod>cfx run
Using binary at 'C:\Program Files (x86)\Mozilla Firefox\firefox.exe'.
Using profile at 'c:\users\sigvard\appdata\local\temp\tmpg3kq0j.mozrunner'.
console.error: pagemod:
Error opening input stream (invalid filename?)
JavaScript strict warning: chrome://browser/content/urlbarBindings.xml, line 666
: reference to undefined property this._value
JavaScript error: chrome://browser/content/urlbarBindings.xml, line 648: aUrl is
undefined
The issue was caused by a bug in the Firefox SDK.
Updating to Firefox SDK 1.16 and initializing a new folder for the project solved it.

ASP.NET MVC 3: Microsoft JScript runtime error: Object doesn't support property or method 'addEventListener'

Error context:
Visual Studio 2010 Service Pack 1
ASP.NET MVC 3 Application
IE9 with Script Debugging enabled for Internet Explorer
Error conditions:
Execution stops int a JavaScript file called "script block [dynamic]" at the following line
doc.addEventListener("DOMNodeInserted", onDOMNodeInserted, false);
that line of code is nested inside the following if block
if (ver >= 9.0)
{
doc.addEventListener("DOMNodeInserted", onDOMNodeInserted, false);
doc.addEventListener("DOMNodeInsertedIntoDocument", onDOMNodeInsertedIntoDocument, false);
}
This is a very persistent error that started happening after I re-imaged my hard drive and reinstalled VS 2010 SP1 and ASP.NET MVC 3. I did it twice to make sure I did it right.
I am going to take a guess and suggest that this bug is the side affect of an un-handled exception in ASP.NET MVC 3 or a bug in IE9. The error seems to ocurr when a (GET?) action method cannot be found that is specified in the ActionLink HTML helper method such as
#Html.ActionLink("Link Text", "Action")
I believe that IE9 does support addEventListener so the error itself is incorrect. Unless I can get more info this error is beyond my ability to fix its cause. I can prevent it by making sure that my action method is there and that it works. That is a workaround not a fix. Fixing the error would prevent it from being erroneously reported because IE9 does in fact support addEventListener.
An answer has been found to this question. The problem was caused by the Divix browser plugin
Solution: Object doesn't support property or method 'addEventListener'
Thank you to a poster on the asp.net forums for helping to solve this problem. The Divix browser plugin has recently been updated. The update may have fixed this issue. However, it remains disabled on my system. Disabling the Divx plug-in definitely fixed this issue for myself and others. I have reported this bug to Divx support.
I've been getting this error today while working on a VS 2010 project, I was using IE9 for my browser. Turns out it's an erroneous message, I should have been getting a page not found error. I tried disabling Divx as mentioned above, but that didn't help. I then tried using Chrome and it reported my error correctly and I was able to solve my problem.
If you get this error, try a different browser which may point you in the right direction.
I turned off Compatibility Mode (was running on local intranet) and the problem went away.

ABCPDF6 issue: "HTML render is blank" but web page output is fine

Like the title says, we are using ABCPdf6 to render PDFs from XSLT. Everything was working fine, but now we are getting an error that states "HTML render is blank". Using a browser (tested on IE/Firefox/Chrome) I am able to browse to the generated HTML (formatted XSL) and it displays perfectly fine in the browser. ABCPDF6 is not able to convert the file. I have tried giving control to the page that outputs the XSL, but I am still getting this error.
Does anyone have experience with ABCPdf and have encountered this before? The code was working fine before without a problem, and another page that uses the exact same generating code (even pointing to the same placeholder page that spits out the HTML!) is working fine.
I know what the problem was in my case now.
When i ran Windows update on my 2008 server, Internet Explorer 9 was installed.
IE 9 has a different way of rendering HTML which brakes abcPDF.
Updating to the latest version (8) solved all my problems. In this version you can also try another HTML engine called Gecko.
Even though you have resolved your problem, if anyone else gets this error, I would suggest that you install the trial version and try this out with the latest version.
I had same error on windows 7 machine with AbcPdf4.0. During MS updates IE8 was upgraded to IE10. Issue got fixed by uninstalling IE10.
Note: Abcpdf4.0 does not work with IE9 onwards. Either upgrade Abcpdf or uninstall latest IE.
I had a similar issue this morning with AbcPdf9. I added code to test the engine types and GECKO worked, then I swapped it back to MSHTML, and it still worked. So it was a temporary issue.
This is how you specify the engine type:
using (var document = new Doc())
{
document.HtmlOptions.Engine = EngineType.Gecko;
...
...
}
This code calls the method that converts the html to PDF, but calls it twice if necessary, since it will only fail once:
try
{
return GeneratePdfFromHtml(html, width, EngineType.MSHtml);
}
catch (Exception ex)
{
/* detect this known issue, swapping the rendering engine once seems to fix it */
if (ex.Message.ToUpper().Contains("BLANK"))
{
return GeneratePdfFromHtml(html, width, EngineType.Gecko);
}
throw;
}
Then you can add a parameter to the method that does the conversion:
public byte[] GeneratePdfFromHtml(string html, int width, EngineType engineType)
{
if (string.IsNullOrWhiteSpace(html)) throw new ArgumentNullException("html");
if (width < 100) throw new ArgumentOutOfRangeException("width");
try
{
using (var document = new Doc())
{
document.HtmlOptions.Engine = engineType;
...
...
If you have a suggestion or different solution, please leave a comment.
In regedit use the following steps
1)HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node
2)Create a key DWORD 32 Bit
3) Rename it "w3wp.exe"
4) Set Value Date = 1

Watin support for IE 9 - Part 2 (Specific)

Watin Runtime Version: v2.0.50727
Browser: IE 9
I have found a specific issue:
BaseIEController.IE.Element(fieldname).Exists throws an Exception as under:
"It's not possible to find the element because no element finder is available."
The fieldname here is a Regex for a link, a simple Regex where the Link's Id is passed.
This works with IE 8.
I cannot use the Final Release of Watin 2.0 since the LogonHandler is not complete (not fully functional as mentioned in the Release Document. I have tried testing it as well).
Any idea on how I can get this Element thingy to work??
Thanks,
K
Today I have upgraded to IE9 on my windows 2008 system and run all the 745 WatiN 2.x unittests and found no issues (accept for one dialog handling the javascript::return dialog fired by onbeforeunload event).
Let me know if you have more specific info/ code example will help too to reproduce the issue you reported.
Jeroen
Lead dev WatiN
Thank you for the response. Firstly, Awesome job with Watin :)
I am trying to run the test using VS2008 and IE 9. The goal is to Click a Link but before that I am verifying if the Link is exists.
The Regex I use for this link is LnkSignIn = new Regex(".*linkSignIn$");
I then use BaseIEController.IE.Element(fieldname).Exists where the fieldname is an Attribute Constraint (in this case the Regex). This would return a true or false if the Link is found. If found, I then click the Link. Instead it returns the Error MyTestInitialize threw exception. WatiN.Core.Exceptions.WatiNException: WatiN.Core.Exceptions.WatiNException: It's not possible to find the element because no element finder is available.. at WatiN.Core.Element.WaitUntilExistsOrNot(Int32 timeout, Boolean waitUntilExists)
...
This works just fine with IE 8. Further, I noticed that if I change Element to Link, it returns true. But since this is a generic method, I want to keep it as element. Hope this helps. Please let me know if you need more information. Thanks.

Watin - IE8 hangs on FileUpload.Set

Whenever I call FileUpload.Set, IE8 will open up the file browser window and just sit there without typing any text. This is on Windows XP and it used to work just fine until I upgraded from Ie7 to IE8. Anyone else run into this?
Turns out this line in the WatiN source was the problem:
if (Process.GetProcessById(window.ProcessID).ProcessName != "iexplore") return;
For some reason, the iexplore process on this machine appears as "IEXPLORE", in all caps. Adding a .ToLower() to the process name fixes the problem.
edit: looks like this bug has already been reported.
Because of the way WatiN looks for the dialog box (by style number), it's understandable that IE8 would be broken in versions less than 2.0. You may want to try it with the 2.0 beta.
Alternatively, you can dive the style numbers on the FileUpload DialogHandler and add the style numbers for IE7 and 8 (96CC20C4 and 96CC02C4).
I'd like to post an update for this problem since it came up again in Win7 OS.
If you have the same problem in the latest WatiN release you can override the function CanHandleDialog in the FileUploadDialogHandler class:
public override bool CanHandleDialog(Window window, System.IntPtr mainWindowHwnd)
{
return true;
}
It's not a clean solution but it is the simple and works.

Resources