Coded UI - Unable to identify a html controls on a Wpfbrowser

落花浮王杯 提交于 2019-12-10 17:13:12

问题


I am new to CodedUI & C#.

I am trying to automate a wpf application which has a WPF Browser. So basically, It's WPF container with html content inside. I have created a similar sample small application and shared it here. This application opens the amazon.in website within wpfwindow.

WPF Browser application

My problem is Coded UI is not able to identify the Html-Controls/elements like 'Buttons', 'Text input fields' properly.

Below, the top image is from the WPF Browser app [Link which i have shared]. Here you can see a blue square box on the top-left. The coded UI identifies that area has the Search Go button.

Bottom part of the image is of the amazon website in IE browser where coded ui is properly highliting/ identifying the Search Go button.

Does this mean i cannot automate WPFBrowser apps using Coded UI.?

Can someone please tell what to do to identify the buttons properly in coded ui


回答1:


You need to specify Id attributes for the controls that you want exposed to Coded UI.




回答2:


To me this looks like CodedUI is getting some control that's similar, rather than the correct one.

You haven't mentioned if you're recording and executing tests or handwriting them in a separate CodedUI solution.

If you're recording them: Be sure that you're recording using your WPF application and interactions inside of them, rather than recording using your browser and then trying to execute tests using the WPF application

If you're writing them by hand: Be sure that you're correctly creating trees of inheritance when writing your tests. For instance, in a traditional CodedUI scenario the absolute top level object that all other controls inherit from is a web browser. In your scenario, that object should be the WPF object. There are probably going to be some other windows or various controls that are children of the WPF application which in turn will finally have the browser as a child.



来源:https://stackoverflow.com/questions/40872791/coded-ui-unable-to-identify-a-html-controls-on-a-wpfbrowser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!