简体   繁体   English

在codedUI测试中访问wpftext控件的字体属性

[英]Accessing font properties of wpftext control in codedUI testing

I want to check whether font is bold or not and also its color in codedui testing. 我想检查字体是否为粗体,以及是否在codedui测试中检查其颜色。 I am using wpftext control . 我正在使用wpftext控件。 Please help me. 请帮我。

Saran, 莎兰

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

Read over this: http://blogs.msdn.com/b/gautamg/archive/2010/01/05/series-on-coded-ui-test-extensibility.aspx 阅读以下内容: http : //blogs.msdn.com/b/gautamg/archive/2010/01/05/series-on-coded-ui-test-extensibility.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 然后看看这里的示例,以获取有关创建自己的扩展程序以暴露字体的想法: 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. 请记住,您将需要修改此示例以获取所需的信息。

-Paul 保罗

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM