Telerik RadDatePicker 的自动控制
我正在使用 WatIn 为使用 Telerik 控件的 Web 应用程序创建自动化测试:我的第一个挑战是驱动 Telerik 日期控件 - RadDatePicker。
仅仅在最可能的输入字段中输入文本是行不通的:在表单发布时,该值将重置为空白。所以我想我需要一组更复杂的自动化交互 - 例如,我发现 Telerik 站点上的此线程 讨论如何从 Telerik 组合框自动进行选择。
谁能提供我需要的神奇互动组合?
(我确信这个答案会对使用任何自动化测试工具的任何人有所帮助,因此我也用其他几个测试框架标记了这个问题:-))
I'm using WatIn to create an automated test for a Web App that uses Telerik controls: my first challenge is to drive a Telerik date control - a RadDatePicker.
Simply entering the text in the likeliest input field doesn't work: the value is reset to blank as the form is posted. So I imagine I need a more complex set of automated interactions -- for example, I found this thread on the Telerik site discussing how to automated a selection from a Telerik combo box.
Can anyone supply the magic combination of interactions I need?
(I'm sure that the answer would help anyone using any automated test tool, hence I've also flagged this question with a couple of other test frameworks too :-))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我正在使用 Selenium RC,几天前也遇到了类似的问题。我花了很长时间才找到正确的方法,所以我想我会分享对我有用的解决方案:(
注意:我无法使用 $find)
在 RadDatePicker 上设置日期的 javascript 是:
然后使用selenium GetEval 在您的测试中调用 javascript 代码来设置日期:
您绝对应该将其包装在一些参数化的帮助程序类中,每次您想要通过传递 id 来设置测试中的日期时,该类都会为您生成 javascript 代码控制和日期。
I'm using Selenium RC and had a similar problem few days ago. It took me ages to find the right way of doing it so I thought I will share the solution that worked for me:
(NOTE: I couldn't use $find)
The javascript to set the date on the RadDatePicker is:
and then use selenium GetEval in your test to call javascript code to set the date:
You should definitely wrap it around some parametrised helper class that will generate the javascript code for you each time you want to set the date in the test by passing id of the control and date.
我终于有了一个可行的解决方案。关键是使用 javascript 调用 telerik 控件的客户端 API。所有复杂的 Telerik 控件(例如 RadInput)都需要相同的技术。
我使用了 WatiN 网站上推荐的技术来编写自己的控件 http://watinandmore.blogspot.com/2009/12/wrapping-complex-logic-in-control.html 得出这个:
I finally have a solution that works. The key is to use javascript to call the client-side API for the telerik control. The same technique is required for all complex Telerik controls, e.g. RadInput.
I used the technique recommended on the WatiN website for writing your own control http://watinandmore.blogspot.com/2009/12/wrapping-complex-logic-in-control.html to come up with this:
我对 RadDatePicker 也有同样的问题,在输入值后会发回空。
我设法通过以下步骤在输入字段中自动输入日期:
MouseClick()
在Manager.Desktop.KeyBoard.TypeText("1/1/1990")
.MouseClick()
在页面上的任何其他元素上,例如某些 div,我发现需要 #4 来触发事件以使控件模糊,从而“保存”其值。
然后您可以提交,并且该值应该随之而来。
I had the same issue with a RadDatePicker that would post back empty after typing in values.
I managed to automate typing in the date into the input field with these steps:
MouseClick()
on itManager.Desktop.KeyBoard.TypeText("1/1/1990")
.MouseClick()
on any other element on the page, e.g. some divI found that #4 was needed to fire the events to make the control blur therefore "saving" its value.
Then you can submit and the value should go along with it.
解决了 SeleniumIDE 的问题 - 在使用“sendKeys”或“type”方法设置值后,必须使用“fireEvent”方法,“ControlID”的值为“blur”。奇怪的是,使用 WebDriver 进行自动化时不会出现此问题。
Solved that problem for SeleniumIDE - you have to use "fireEvent" method with value "blur" for "ControlID" after you've set value using "sendKeys" or "type" methods. Strange that this problem does not occur when automating with WebDriver.