Accessing font properties of wpftext control in co

2019-08-01 10:26发布

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.

1条回答
兄弟一词,经得起流年.
2楼-- · 2019-08-01 11:09

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. 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

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.

-Paul

查看更多
登录 后发表回答