c#ui自动化

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2100978/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 23:30:16  来源:igfitidea点击:

c# ui automation

c#ui-automation

提问by manish patel

i am trying to automate the gui in c# .Is this same as browser automation .how can i start ui automation

我正在尝试在 c# 中自动化 gui。这与浏览器自动化相同。我如何启动 ui 自动化

采纳答案by Nat Ritmeyer

You can use Microsoft's UI Automation library, but it isn't much fun. "White" is a better alternative... see: http://www.codeplex.com/white

您可以使用 Microsoft 的 UI 自动化库,但它并不是很有趣。“白色”是一个更好的选择......见:http: //www.codeplex.com/white

EDIT:

编辑:

New url to "White" project as it was moved to TestStack on GitHub: https://github.com/TestStack/White

“White”项目移至 GitHub 上的 TestStack 时的新网址:https: //github.com/TestStack/White

回答by Alastair Pitts

If you are using WPF, Microsoft has a very detailed UI Automation library.

如果您使用 WPF,Microsoft 有一个非常详细的 UI 自动化库。

http://msdn.microsoft.com/en-us/library/ms747327.aspx

http://msdn.microsoft.com/en-us/library/ms747327.aspx

I had a look around but I couldn't find an equivalent for WinForms.

我环顾四周,但找不到 WinForms 的等效项。

回答by Klee

WiPFlashis good, easy to use, open source wrapper on top of Microsofts UI automation library. But they're limited by the underlying Microsoft Automation structure.

WiPFlash是基于 Microsoft 的 UI 自动化库的优秀、易于使用的开源包装器。但它们受到底层 Microsoft 自动化结构的限制。

回答by Andreas Reiff

http://msdn.microsoft.com/en-us/library/ms747327.aspxlike Alastair Pitts pointed out can be used. From my knowledge it should be good for any automation tasks - as long as Windows recognizes the control your application uses as standard controls or controls that have automation support. Which should be the case for just about all major control vendors. And defnitely MFC, Win32, WinForms and probably WPF and Silverlight as well.

http://msdn.microsoft.com/en-us/library/ms747327.aspx就像 Alastair Pitts 指出的那样可以使用。据我所知,它应该适用于任何自动化任务 - 只要 Windows 将您的应用程序使用的控件识别为标准控件或具有自动化支持的控件。几乎所有主要的控制供应商都应该是这种情况。当然还有 MFC、Win32、WinForms,可能还有 WPF 和 Silverlight。

You can get an idea of what you are up to (against) by firing up Spy++ and having a look at what it displays.

您可以通过启动 Spy++ 并查看它显示的内容来了解​​您(反对)什么。

You might also want to listen to the other ideas, using Tools like White (opensource) or Rannorex (which is commercial).

您可能还想听听其他想法,使用 White(开源)或 Rannorex(商业)等工具。

回答by Richard

Be careful if your GUI is using any 3rd party Windows controls, like Devexpress controls, or Telerik controls.

如果您的 GUI 使用任何 3rd 方 Windows 控件(如 Devexpress 控件或 Telerik 控件),请务必小心。

MS UI Automation would have difficulties to locate those fancy grids, lovely menus and pretty icons.

MS UI 自动化很难找到那些花哨的网格、可爱的菜单和漂亮的图标。

Talking about TestStack.White, it's using MS UI Automation as the cornerstone, so it would face the same problem locating detailed GUI elements.

谈到 TestStack.White,它使用 MS UI 自动化作为基石,所以它会面临同样的问题,定位详细的 GUI 元素。

You will know when you need to manipulate the grid by row but UI Automation or TestStack.White could furthest only return you the table object, then you will find your R&D efforts before the project starts were all wasted. That's how I learned that lesson, but now I am the expert.

你会知道什么时候需要逐行操作网格,但UI Automation或者TestStack.White最远只能返回table对象,然后你会发现项目开始前的研发工作都白费了。我就是这样吸取教训的,但现在我是专家。

回答by ilCosmico

FlaUIis a good alternative to "White" library, based on native UI Automation libraries from Microsoft.

FlaUI是“White”库的一个很好的替代品,它基于 Microsoft 的原生 UI 自动化库。

回答by Bj?rn Ammon

9 Years later Appiumis a good option, also a reference side from Microsoft, since CodedUIis obsolet. Microsoft build the WinAppDriverfor Appium. You can also just use the WinAppDriver to test your gui. you need Appium, just if you want to do contionouos integration.

9 年后Appium是一个不错的选择,也是微软的一个参考,因为CodedUI已经过时了。微软打造的WinAppDriver的Appium。您也可以仅使用 WinAppDriver 来测试您的 gui。你需要 Appium,只要你想做 contionouos 集成。

Differences:
Teststack.White is an efficient Testframework. It doens′t need as much time as WinAppDriver (Appium) to go through the tests and its very easy to implement in your testproject. But the support isn′t as good as WinAppDriver. Teststack.White as example still doesn′t support UWP (maybe no one want to develope with UWP :P ). On the other side, you need Windows 10 or Windows Server 2016 to work with the WinAppDriver. Both have an easy implementation of tests, but you need to set some JSON-Values, to get a http-connection with the WinAppDriver.
At least the WinAppDriver with Appium has much more possibilities, but TestStack.White is easy implemented.

区别:
Teststack.White 是一个高效的测试框架。它不需要像 WinAppDriver (Appium) 那样多的时间来完成测试,并且很容易在您的测试项目中实现。但支持不如 WinAppDriver。以 Teststack.White 为例,仍然不支持 UWP(可能没人想用 UWP 开发 :P )。另一方面,您需要 Windows 10 或 Windows Server 2016 才能使用 WinAppDriver。两者都有一个简单的测试实现,但您需要设置一些 JSON 值,以获取与 WinAppDriver 的 http 连接。
至少带有 Appium 的 WinAppDriver 有更多的可能性,但 TestStack.White 很容易实现。