开发者

Does htmlunit work with custom HTML attributes ("expando attributes")?

开发者 https://www.devze.com 2023-02-10 05:28 出处:网络
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 na

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.

0

精彩评论

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

关注公众号