c#中SendKeys的跨平台实现?

时间:2022-01-26 02:14:16

I need to automate desktop applications (not a web browser) testing on Windows, Mac and Linux. On Windows I use SendKeys, what do I use on Mac and Linux? Are there any cross-platform .NET Core SendKeys implementation that I can preferably use from xUnit?

我需要在Windows、Mac和Linux上自动化桌面应用程序(而不是web浏览器)测试。在Windows上我使用SendKeys,我在Mac和Linux上使用什么?是否有任何跨平台的。net Core SendKeys实现,我最好能从xUnit中使用?

2 个解决方案

#1


8  

I'm not sure what you are asking for makes sense.

我不知道你要的是什么。

.Net Core only has a subset of APIs in order to provide cross-platform functionality. i.e. shared libraries that will work on different platforms.

net内核只有一个api子集,以便提供跨平台的功能。即在不同平台上工作的共享库。

By definition this cannot include any platform-specific functionality and things like SendKeys or displaying message boxes (System.Windows.Forms) ARE platform-specific (even WPF and WinForms have different APIs for this).

根据定义,它不能包含任何特定于平台的功能,而像SendKeys或显示消息框(System.Windows.Forms)这样的东西是特定于平台的(甚至WPF和WinForms对此也有不同的api)。

Is there a .NET Core SendKeys implementation that I can preferably use from xUnit?

是否有一个。net Core SendKeys实现,我最好能从xUnit中使用?

I think this is what is confusing me about your question. Unless you're using Selenium or a fat client test tool like SikuliX, EggPlant, HP Functional you don't actually write unit tests for the GUI.

我想这就是你的问题让我困惑的地方。除非您使用Selenium或胖客户机测试工具,如SikuliX、EggPlant和HP Functional,否则实际上不会为GUI编写单元测试。

These are often referred to as Integration, System or GUI tests.

这些通常被称为集成、系统或GUI测试。

Both Selenium & SikuliX are free and will run cross-platform. They can be used to Send Keys. Since you're not interested in Web, SikuliX is what you want.

Selenium和SikuliX都是免费的,将运行跨平台。它们可以用来发送密钥。既然你对Web不感兴趣,SikuliX就是你想要的。

Overview of SikuliX:

SikuliX概述:

https://www.scribd.com/document/87620043/sikuliscript-Overview-by-student

https://www.scribd.com/document/87620043/sikuliscript-Overview-by-student

Training Videos:

培训视频:

SikuliX Tutorial #1 - Intro & Setup https://www.youtube.com/watch?v=VdCOg1bCmGo

SikuliX教程#1 -介绍和设置https://www.youtube.com/watch?v=VdCOg1bCmGo

SikuliX Tutorial #2 - The Basics https://www.youtube.com/watch?v=I-UYoezac4Q

SikuliX教程#2 -基础https://www.youtube.com/watch?v=I-UYoezac4Q

SikuliX Tutorial #3 - Conditional Automation https://www.youtube.com/watch?v=vuqfDdPlI88

SikuliX教程#3 -有条件的自动化https://www.youtube.com/watch?v=vuqfDdPlI88。

SikuliX Tutorial #4 - Conditional Looping https://www.youtube.com/watch?v=Bb513yh6RGE

SikuliX教程#4 -条件循环https://www.youtube.com/watch?v=Bb513yh6RGE

SikuliX Tutorial #5 - Game Example https://www.youtube.com/watch?v=xTTIikzxFfc&t=816s

SikuliX教程#5 -游戏示例:https://www.youtube.com/watch?v=xTTIikzxFfc&t=816s。

#2


6  

You can use the the mono/.net core SendKeys class for cross platform.

您可以使用mono/.net核心SendKeys类用于跨平台。

Linux native - xdotool
Mac native - here and here.

Linux本机- xdotool Mac本机-这里和这里。

#1


8  

I'm not sure what you are asking for makes sense.

我不知道你要的是什么。

.Net Core only has a subset of APIs in order to provide cross-platform functionality. i.e. shared libraries that will work on different platforms.

net内核只有一个api子集,以便提供跨平台的功能。即在不同平台上工作的共享库。

By definition this cannot include any platform-specific functionality and things like SendKeys or displaying message boxes (System.Windows.Forms) ARE platform-specific (even WPF and WinForms have different APIs for this).

根据定义,它不能包含任何特定于平台的功能,而像SendKeys或显示消息框(System.Windows.Forms)这样的东西是特定于平台的(甚至WPF和WinForms对此也有不同的api)。

Is there a .NET Core SendKeys implementation that I can preferably use from xUnit?

是否有一个。net Core SendKeys实现,我最好能从xUnit中使用?

I think this is what is confusing me about your question. Unless you're using Selenium or a fat client test tool like SikuliX, EggPlant, HP Functional you don't actually write unit tests for the GUI.

我想这就是你的问题让我困惑的地方。除非您使用Selenium或胖客户机测试工具,如SikuliX、EggPlant和HP Functional,否则实际上不会为GUI编写单元测试。

These are often referred to as Integration, System or GUI tests.

这些通常被称为集成、系统或GUI测试。

Both Selenium & SikuliX are free and will run cross-platform. They can be used to Send Keys. Since you're not interested in Web, SikuliX is what you want.

Selenium和SikuliX都是免费的,将运行跨平台。它们可以用来发送密钥。既然你对Web不感兴趣,SikuliX就是你想要的。

Overview of SikuliX:

SikuliX概述:

https://www.scribd.com/document/87620043/sikuliscript-Overview-by-student

https://www.scribd.com/document/87620043/sikuliscript-Overview-by-student

Training Videos:

培训视频:

SikuliX Tutorial #1 - Intro & Setup https://www.youtube.com/watch?v=VdCOg1bCmGo

SikuliX教程#1 -介绍和设置https://www.youtube.com/watch?v=VdCOg1bCmGo

SikuliX Tutorial #2 - The Basics https://www.youtube.com/watch?v=I-UYoezac4Q

SikuliX教程#2 -基础https://www.youtube.com/watch?v=I-UYoezac4Q

SikuliX Tutorial #3 - Conditional Automation https://www.youtube.com/watch?v=vuqfDdPlI88

SikuliX教程#3 -有条件的自动化https://www.youtube.com/watch?v=vuqfDdPlI88。

SikuliX Tutorial #4 - Conditional Looping https://www.youtube.com/watch?v=Bb513yh6RGE

SikuliX教程#4 -条件循环https://www.youtube.com/watch?v=Bb513yh6RGE

SikuliX Tutorial #5 - Game Example https://www.youtube.com/watch?v=xTTIikzxFfc&t=816s

SikuliX教程#5 -游戏示例:https://www.youtube.com/watch?v=xTTIikzxFfc&t=816s。

#2


6  

You can use the the mono/.net core SendKeys class for cross platform.

您可以使用mono/.net核心SendKeys类用于跨平台。

Linux native - xdotool
Mac native - here and here.

Linux本机- xdotool Mac本机-这里和这里。