本文介绍了在codedUI测试中访问wpftext控件的字体属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在codedui测试中检查字体是否为粗体,以及其颜色.我正在使用wpftext控件.请帮助我.

I want to check whether font is bold or not and also its color in codedui testing. I am using wpftext control . Please help me.

推荐答案

Saran,

不幸的是,这并不像它应该的那么简单,但是可以通过创建CodedUI测试框架扩展来完成,该扩展将AutomationProperties.ItemStatusProperty设置为当前Font.这样做的好处之一是,它可以与测试记录器一起使用,并允许您生成断言和/或手工验证代码.

Unfortunately, this is not as straightforward as it probably should be, but it can be done by creating a CodedUI Test Framework Extension which sets an AutomationProperties.ItemStatusProperty to the current Font. One benefit of doing it this way is that it works with the test recorder and allows you to generate assertions and/or hand-code validations.

请阅读以下内容: http://blogs.msdn.com/b/gautamg/archive/2010/01/05/series-on-coded-ui-test-extensibility.aspx

然后在这里查看示例,以获取有关创建自己的扩展名以暴露字体的想法: http://blogs.msdn.com/b/mathew_aniyan/archive/2011/05/17/custom-wpf-control-s-custom-properties.aspx

Then take a look at the example here for an idea on creating your own extension for exposing font: http://blogs.msdn.com/b/mathew_aniyan/archive/2011/05/17/custom-wpf-control-s-custom-properties.aspx

请记住,您将需要修改此示例以获取所需的信息.

Keep in mind, you will need to modify this example to get what you are after.

-保罗

这篇关于在codedUI测试中访问wpftext控件的字体属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 12:20