I'm trying to use the HTMLUnit testing framework with a web application using the KnockoutJS javascript binding library. KnockoutJS is dependent on a custom HTML 开发者_StackOverflow中文版attribute named 'data-bind'. My HTMLUnit tests are not passing -- it appears that knockout is not running at all, and my current best-guess as to why is that HTMLUnit does not support custom attributes.
Does anyone have any experience in this area, or have a working test for a knockout-based solution using htmlunit?
For custom attributes to work on HtmlUnit, construct the WebClient object using BrowserVersion.FIREFOX_3_6 as browserVersion.
Check the WebClient class documentation: http://htmlunit.sourceforge.net/apidocs/com/gargoylesoftware/htmlunit/WebClient.html
By default, WebClient is constructed using BrowserVersion.INTERNET_EXPLORER_7, which deletes all custom attributes set by Javascript.
精彩评论