When testing with WatiN: "'DebuggerDisplayProxy()' threw an exception of type 'System.InvalidCastException'" - watin

FrameworkActionsLink = CurrentBuyerSite.BuyerWorkAreaFrame.Link(Find.ById("actions"));
I have code which finds a link element by finding by ID.
The HTML on the page is:
<a id="actions" href="Javascript:ShowMenuItem('options','actions'); ... >
I have excluded the full Javascript code in the href where you see "...".
On test execution, sometimes this code works correctly, but sometimes I get the following error:
'DebuggerDisplayProxy()' threw an exception of type
'System.InvalidCastException'
It's a pretty straightforward bit of code, I just wondered if anyone had experienced similar problems or error messages. Do you think this is an issue with the WatiN tool, the web application, the internet browser, or perhaps something else entirely?

Can you try the following code:
FrameworkActionsLink = (WatiN.Core.Link)CurrentBuyerSite.BuyerWorkAreaFrame.Link(Find.ById("actions"));
I'm pretty sure that it doesn't like the link being JavaScript:...
Edit: Try maybe this:
CurrentBuyerSite.Eval("ShowMenuItem('options','actions'); ...");

What runner are you using? if nUnit 64bit then try 32bit or other runner.
Maybe the issue is that page didn't fully download and that makes problem with javascript function, try replace Click() for ClickNoWait().

Related

Is the htmlunit "WARNING: CSSValue '0\0' has to be a 'px', 'em', '%', 'mm', 'ex', or 'pt' value." really just a warning?

I'm trying to load a web page with htmlunit 2.33 and my app displays the above CSS warning in a seemingly endless, repeating list.
I'm specifying FIREFOX_60.
I've tried setting the "silent" css error handler, but that doesn't help.
wc.setCssErrorHandler(new SilentCssErrorHandler());
I'm not sure that setting the log level to OFF is the right answer, either.
It looked to me like the htmlunit library was stuck in a loop. Sure enough, when I let the page complete, I was presented with this error:
Exception in thread "main"
Exception: java.lang.OutOfMemoryError thrown from the
UncaughtExceptionHandler in thread "main"
Looks like an issue; please open one in the HtmlUnit bug tracker or on github and provide all the details you have (complete stack traces, souce code, url of the page your are testing and so on). If i'm able to reproduce i can fix it.

invalidselector exception + selenium

I have been hit with InvalidSelectorException on a regular basis when i run my selenium web driver test script
My test fails with this InvalidSelector Exception and throws message as :
The xpath expression '//form[#name=somelocator]' cannot be evaluated or does not result in a WebElement
The element locator i use is perfect which return a correct web element when i cross verify it using xpath checker / or with browser console, so no issue with the element locator
I click on some button and then wait for the above xpath locator element to load in the application UI and giving enough waitTilllElementVisible() methods before checking the above locator
I found that many faced this issue, but could not get the concrete reason for this failure.
Selenium asks to visit: http://seleniumhq.org/exceptions/invalid_selector_exception.html for the documentation on this error, but this link looks not up
Reproduced it with selenium 2.45 and 2.46 version with IE11
Please let me know if you knows the reason for this and why it throws invalidSelector exception on browser open with webdriver
I think the problem is the SPACE character in the #name tag. Try "//form[#name='some locator']" or '//form[#name=\'some locator\']'.
#peetya's answer is probably correct and a better answer but I prefer CSS Selectors... they are less error prone if you have the option to not use XPath.
driver.findElement(By.cssSelector("form[name='some locator']"));
CSS Selector reference

Selenium RC test passes when it should fail on verifyTrue(selenium.isTextPresent("string"))

I have a suite of Selenium tests that I created in the Selenium IDE and ported over to Java. In several tests I use the Java equivalent of the verifyTextPresent command to confirm some text on the page (verifyTrue(selenium.isTextPresent())).
I found an spelling error in the text on the page when running the test from the IDE, but the error was not caught when running the test via Selenium RC/TestNG. Here's an example of the code that I have and the text that is causing the problem (spelling error in bold):
Text:
Please correct the errors indicated below.
You need to add a least one restriction.
IDE:
verifyTextPresent | Please correct the errors indicated below.
verifyTextPresent | You need to add at least one restriction.
Java:
verifyTrue(selenium.isTextPresent("Please correct the errors indicated below."));
verifyTrue(selenium.isTextPresent("You need to add at least one restriction."));
Since both versions of the test have the correct text, why is the Selenium RC version not catching the error? Has anyone else had this problem?
The reason why this happens is that the test continues to run after the call to verifyTrue(). Verifications in Selenium catch the exceptions that would be thrown by a failed verification, as opposed to an assertion which throws an exception and causes the test to fail. Because verifications catch exceptions instead of throwing them, the test passes.
At the end of the test, the method checkForVerificationErrors() needs to be called to see if any of the verifications failed. If the method is not called, any verification errors will be ignored and the test will still pass (absent any other problems).
A discussion on the Selenium Google Group about the error itself is here. A discussion about the various verifications vs. assertions is here.
I had a similar problem... My workaround is to use assertTrue() instead of verifyTrue(). I hope it works for you to.

MS Unit Testing in VS 2010, Test Method [my method] threw an exception: ..., WT*?

I've got an ASP.NET MVC 2 Web app in VS 2010 and decided to try using MS unit testing stuff. What do you know, on the first test I created it gives me grief and refuses to elaborate.
I have created a single test class and a single test method. I am using Moq to create a HttpContext (including Request, Response, Session, QueryString, Form and Cookies). The method is testing an action on one of my controllers and an exception is occurring in that action when it use MVCs model binding capabilities. However that is not the problem.
When I run the test in VS it simply says: "Test Method [myTestMethodNameHere] threw exception: ..."! So it doesn't give me any idea what the exception is it literally says ... at the end, like a cliffhanger on TV - "... find out in VS 2011, coming soon" 8(.
Debugging the test doesn't help as it's occuring on the UpdateModel(T) line that I'm calling. I am using my own custom binder class but it doesn't get to the breakpoint on the first line of code in that so the exception must be happening in the MVC framework.
I guess this is all a long winded way of asking is there some configuration or code that needs to be written to get the MS unit testing framework to show me the exception in the test results window, is it me or does it sound like an MS issue that others have had?
Any help much appreciated,
Peter
Right click the failed test in the Test Results pane, and click View Test Result Details. You'll be given a document that specifies the exception, its message and stack trace.
Since you're using Moq, I'm guessing the type will be MoqVerificationException - MSTest unfortunately doesn't pick it up the same way it picks up AssertFailedExceptions, so no nice error messages there...

Facebook Application - Url-rewriting with fbml?

I have an app that I'm creating with CakePHP, which rewrites the url from something illegible to most users to something a little easier to comprehend. I'm having a problem when I use the FBML canvas.
When I try to access, say, http://apps.facebook.com/myapp/articles, I get the following error:
Received HTTP error code 404 while
loading
http://www.myapp.com/myapparticles/
I did notice that when I try to access http://apps.facebook.com/myapp/articles/posts, it changes the error to show the following url, which is slightly different: http://www.myapp.com/myapparticles/posts
Which lead me to try accessing it with this: http://apps.facebook.com/myapp//articles, which does work most of the time, though for some reason sometimes it will give the previous error. (And it also seems like a hack-y way of getting it to work).
I'm at a loss for how to fix this.
Turns out I was missing the trailing slash (http://www.myapp.com/myapp/) on the url that I specified as my canvas callback, which is in the app settings. Putting it there fixes the problem.
This happens when you are not using semantic markup or you have an error or some code not supported by fb. Also that famous error is generated by fb when it is down or slow too.
I would suggest you checking your code thoroughly and going through fb documentation. That should help you the most. thanks

Resources