CodedUI测试:Keyboard.SendKeys不工作 [英] CodedUI Test: Keyboard.SendKeys not working

查看:617
本文介绍了CodedUI测试:Keyboard.SendKeys不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用Visual Studio 2010的
我已经重放时的各种行动对我的HTML组件之一,有一个问题的CodedUI测试功能。该Keyboard.SendKeys产生不工作(例如,如果没有输入)



生成的代码是:



<在SaisieSD_DS自定义控件
Keyboard.SendKeys pre> //类型{F4} {F4} {F2} {滴度输入}(uISaisieSD_DSCustom,this.Params.UISaisieSD_DSCustomSendKeys ,ModifierKeys.None);

如果我通过向系统调用替换调用Keyboard.SendKeys。 Windows.Forms.SendKeys.SendWait ,它的工作。



我在想一个问题,由于重心的损失。但是,如果我做类似 uISaisieSD_DSCustom.SetFocus(),它不会改变的行为。



待办事项你有什么想法?



THX。


解决方案

你试过

  uISaisieSD_DSCustom.WaitForReady()

或者其他waitfors?



时它未能在此行中的一个?抑或是后来失败缘于此不能正常工作



您还可以使用以下方法来等待所有线程,然后再继续完成:

  Playback.PlaybackSettings.WaitForReadyLevel = WaitForReadyLevel.AllThreads; 
Keyboard.SendKeys(uISaisieSD_DSCustom,this.Params.UISaisieSD_DSCustomSendKeys,ModifierKeys.None);
Playback.PlaybackSettings.WaitForReadyLevel = WaitForReadyLevel.UIThreadOnly;



只要确保你包含的最后一行,将其回UIThreadOnly,或会慢一切办法下来。


I'm trying to use the CodedUI Test feature of Visual Studio 2010. I've got a problem while replaying the various actions for one of my html component. The Keyboard.SendKeys generated do not work (like if there was no input).

The code generated is :

// Type '{F4}{F4}{F2}titre{Enter}' in 'SaisieSD_DS' custom control
Keyboard.SendKeys(uISaisieSD_DSCustom, this.Params.UISaisieSD_DSCustomSendKeys, ModifierKeys.None);

If I replace the call to Keyboard.SendKeys by a call to System.Windows.Forms.SendKeys.SendWait, it does work.

I was thinking about a problem due to a loss of focus. However, if i do something like uISaisieSD_DSCustom.SetFocus(), it doesn't change the behavior.

Do you have any idea ?

thx.

解决方案

Have you tried

uISaisieSD_DSCustom.WaitForReady()

Or one of the other waitfors?

Is it failing on this line? Or is it failing afterward due to this not working correctly?

You can also use the following to wait for all threads to complete before proceeding:

Playback.PlaybackSettings.WaitForReadyLevel = WaitForReadyLevel.AllThreads;
Keyboard.SendKeys(uISaisieSD_DSCustom, this.Params.UISaisieSD_DSCustomSendKeys, ModifierKeys.None);
Playback.PlaybackSettings.WaitForReadyLevel = WaitForReadyLevel.UIThreadOnly;

Just make sure you include the last line to turn it back to UIThreadOnly, or it will slow everything way down.

这篇关于CodedUI测试:Keyboard.SendKeys不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆