开发者

How to test web layout using javascript testing frameworks

Has any one tried testing the actual layout of the we开发者_StackOverflow中文版b application in different browsers? I can only think of getting the actual dimensions of all the elements and then matching it with expected values. I think it is crude way to do it. Is there a better way to actually test the layout?

Thanks Bharani


What do you plan to test? If you need to know whether an element is flush with the border of the window, clientLeft == 0 is the best option. If you want to make sure two elements are next to each other, you must compare the position of the common border.

OTOH, it doesn't make much sense to check every single value. Layout can be dynamic, and depend on factors like screen resolution, zoom factor and base font size. So the golden rule (as always) is: Know what you want to test and then test just that.


I’ve never tried this, but I think it’s much more effort than it’s worth.

Layout issues are only important if they’re obvious, and if they’re obvious, human beings will spot them with much less effort than it would take to write and maintain scripts that check the same thing.

Also, layout issues are never that important. They don’t result in user data being lost, for example.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜